@Test public void testTemplateOption() throws Exception { ServiceAccount serviceAccount = ServiceAccount.create("myemail", ImmutableList.of("myscope1")); RecordingLocationCustomizer customizer = new RecordingLocationCustomizer(); obtainMachine(ImmutableMap.builder() .put(JcloudsLocation.JCLOUDS_LOCATION_CUSTOMIZERS, ImmutableList.of(customizer)) .put(JcloudsLocation.TEMPLATE_OPTIONS, ImmutableMap.of( "serviceAccounts", ImmutableList.of(serviceAccount))) .build()); GoogleComputeEngineTemplateOptions options = (GoogleComputeEngineTemplateOptions) customizer.templateOptions; assertEquals(options.serviceAccounts(), ImmutableList.of(serviceAccount)); }
.put("aKey", "aValue") .put("jclouds-delete-boot-disk", "true"), // metadata ImmutableList.of(ServiceAccount.create("default", ImmutableList.of("myscope"))), // serviceAccounts Instance.Scheduling.create(OnHostMaintenance.MIGRATE, false, false) // scheduling );
(GoogleComputeEngineTemplateOptions) findTemplateOptionsInCustomizerArgs(); assertEquals(options.serviceAccounts(), ImmutableList.of( ServiceAccount.create("myemail", ImmutableList.of("myscope1", "myscope2"))));
.description("description") .tags(Tags.create(null, ImmutableList.of("tag1"))) .serviceAccounts(ImmutableList.of(ServiceAccount.create("default", ImmutableList.of("https://www.googleapis.com/auth/compute")))) .scheduling(Scheduling.create(OnHostMaintenance.MIGRATE, true, false)) .build();
public void insert_builder_allOptions() throws Exception { server.enqueue(jsonResponse("/zone_operation.json")); NewInstance newInstance = new NewInstance.Builder( "test-1", // name URI.create(url("/projects/party/zones/us-central1-a/machineTypes/n1-standard-1")), // machineType URI.create(url("/projects/party/global/networks/default")), // network null, // subnetwork Arrays.asList(AttachDisk.existingBootDisk(URI.create(url("/projects/party/zones/us-central1-a/disks/test"))))) .canIpForward(true) .description("desc") .tags(null) .metadata(Metadata.create().put("aKey", "aValue")) .serviceAccounts(ImmutableList.of(ServiceAccount.create("default", ImmutableList.of("https://www.googleapis.com/auth/compute")))) .scheduling(Scheduling.create(OnHostMaintenance.MIGRATE, true, false)) .build(); assertEquals(instanceApi().create(newInstance), new ParseZoneOperationTest().expected(url("/projects"))); assertSent(server, "POST", "/projects/party/zones/us-central1-a/instances", stringFromResource("/instance_insert_full.json")); }