public static NewInstance create(String name, URI machineType, URI network, List<AttachDisk> disks, String description) { return create(name, machineType, network, disks, description, null); }
newInstance.metadata().putAll(options.getUserMetadata()); newInstance.metadata().put("sshKeys", format("%s:%s %s@localhost", credentials.getUser(), options.getPublicKey(), credentials.getUser())); newInstance.name(), // name newInstance.description(), // description newInstance.tags(), // tags newInstance.machineType(), // machineType newInstance.metadata(), // metadata newInstance.serviceAccounts(), // serviceAccounts
NewInstance newInstance = NewInstance.create( newInstance.tags().items().addAll(options.getTags()); FirewallTagNamingConvention naming = firewallTagNamingConvention.get(group); for (int port : options.getInboundPorts()) { newInstance.tags().items().add(naming.name(port)); newInstance.metadata().putAll(options.getUserMetadata()); newInstance.metadata().put("sshKeys", format("%s:%s %s@localhost", credentials.getUser(), options.getPublicKey(), credentials.getUser())); newInstance.name(), // name newInstance.description(), // description newInstance.tags(), // tags newInstance.machineType(), // machineType
private void assertInstanceEquals(Instance result, NewInstance expected) { assertEquals(result.name(), expected.name()); assertEquals(result.metadata().asMap(), expected.metadata().asMap()); // ignore fingerprint! // Do not assume tags come in the same order List<String> resultTags = Ordering.from(String.CASE_INSENSITIVE_ORDER).sortedCopy(result.tags().items()); List<String> expectedTags = Ordering.from(String.CASE_INSENSITIVE_ORDER).sortedCopy(expected.tags().items()); assertEquals(resultTags, expectedTags); }
public void insert_allOptions() throws Exception { server.enqueue(jsonResponse("/zone_operation.json")); NewInstance newInstance = NewInstance.create( "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")))), "desc", // description null // tags ); newInstance.metadata().put("aKey", "aValue"); assertEquals(instanceApi().create(newInstance), new ParseZoneOperationTest().expected(url("/projects"))); assertSent(server, "POST", "/projects/party/zones/us-central1-a/instances", stringFromResource("/instance_insert.json")); }
newInstance.metadata().putAll(options.getUserMetadata()); newInstance.metadata().put("sshKeys", format("%s:%s %s@localhost", credentials.getUser(), options.getPublicKey(), credentials.getUser())); newInstance.name(), // name newInstance.description(), // description newInstance.tags(), // tags newInstance.machineType(), // machineType newInstance.metadata(), // metadata newInstance.serviceAccounts(), // serviceAccounts
newInstance.metadata().putAll(options.getUserMetadata()); newInstance.metadata().put("sshKeys", format("%s:%s %s@localhost", credentials.getUser(), options.getPublicKey(), credentials.getUser())); newInstance.name(), // name newInstance.description(), // description newInstance.tags(), // tags newInstance.machineType(), // machineType newInstance.metadata(), // metadata newInstance.serviceAccounts(), // serviceAccounts
/** Convenience for creating a new instance with only a boot disk and minimal parameters. */ public static NewInstance create(String name, URI machineType, URI network, URI subnetwork, URI sourceImage) { return create(name, machineType, network, subnetwork, Arrays.asList(AttachDisk.newBootDisk(sourceImage)), null, null); }
/** Convenience for creating a new instance with only a boot disk and minimal parameters. */ public static NewInstance create(String name, URI machineType, URI network, URI subnetwork, URI sourceImage) { return create(name, machineType, network, subnetwork, Arrays.asList(AttachDisk.newBootDisk(sourceImage)), null, null); }
/** Convenience for creating a new instance with only a boot disk and minimal parameters. */ public static NewInstance create(String name, URI machineType, URI network, URI sourceImage) { return create(name, machineType, network, Arrays.asList(AttachDisk.newBootDisk(sourceImage)), null); }
/** Convenience for creating a new instance with only a boot disk and minimal parameters. */ public static NewInstance create(String name, URI machineType, URI network, URI sourceImage) { return create(name, machineType, network, Arrays.asList(AttachDisk.newBootDisk(sourceImage)), null, null); }
public NewInstance build() { return create(name, machineType, canIpForward, networkInterfaces, disks, description, tags != null ? tags : Tags.create(), metadata != null ? metadata : Metadata.create(), serviceAccounts, scheduling); } }
public static NewInstance create(String name, URI machineType, URI network, @Nullable URI subnetwork, List<AttachDisk> disks, @Nullable String description, @Nullable Tags tags) { checkArgument(disks.get(0).boot(), "disk 0 must be a boot disk! %s", disks); boolean foundBoot = false; for (AttachDisk disk : disks) { if (disk.boot()) { checkArgument(!foundBoot, "There must be only one boot disk! %s", disks); foundBoot = true; } } return create(name, machineType, null, ImmutableList.of(NetworkInterface.create(network, subnetwork)), ImmutableList.copyOf(disks), description, tags != null ? tags : Tags.create(), Metadata.create(), null, null); }
public static NewInstance create(String name, URI machineType, URI network, @Nullable URI subnetwork, List<AttachDisk> disks, @Nullable String description, @Nullable Tags tags) { checkArgument(disks.get(0).boot(), "disk 0 must be a boot disk! %s", disks); boolean foundBoot = false; for (AttachDisk disk : disks) { if (disk.boot()) { checkArgument(!foundBoot, "There must be only one boot disk! %s", disks); foundBoot = true; } } return create(name, machineType, null, ImmutableList.of(NetworkInterface.create(network, subnetwork)), ImmutableList.copyOf(disks), description, tags != null ? tags : Tags.create(), Metadata.create(), null, null); }
public NewInstance build() { return create(name, machineType, canIpForward, networkInterfaces, disks, description, tags != null ? tags : Tags.create(), metadata != null ? metadata : Metadata.create(), serviceAccounts, scheduling); } }
public NewInstance build() { return create(name, machineType, canIpForward, networkInterfaces, disks, description, tags != null ? tags : Tags.create(), metadata != null ? metadata : Metadata.create(), serviceAccounts, scheduling); } }
public static NewInstance create(String name, URI machineType, URI network, List<AttachDisk> disks, @Nullable String description, @Nullable Tags tags) { checkArgument(disks.get(0).boot(), "disk 0 must be a boot disk! %s", disks); boolean foundBoot = false; for (AttachDisk disk : disks) { if (disk.boot()) { checkArgument(!foundBoot, "There must be only one boot disk! %s", disks); foundBoot = true; } } return create(name, machineType, null, ImmutableList.of(NetworkInterface.create(network)), ImmutableList.copyOf(disks), description, tags != null ? tags : Tags.create(), Metadata.create(), null, null); }
public static NewInstance create(String name, URI machineType, URI network, List<AttachDisk> disks, String description, Scheduling scheduling) { checkArgument(disks.get(0).boot(), "disk 0 must be a boot disk! %s", disks); boolean foundBoot = false; for (AttachDisk disk : disks) { if (disk.boot()) { checkArgument(!foundBoot, "There must be only one boot disk! %s", disks); foundBoot = true; } } return create(name, machineType, null, ImmutableList.of(NetworkInterface.create(network)), ImmutableList.copyOf(disks), description, Tags.create(), Metadata.create(), null, scheduling); }
@Override protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) { GoogleComputeEngineApi api = super.create(props, modules); reset_windows_password = injector.getInstance(Key.get(new TypeLiteral<Function<Map<String, ?>, String>>() {})); List<Image> list = api.images().listInProject("windows-cloud", filter("name eq windows-server-2012.*")).next(); URI imageUri = FluentIterable.from(list) .filter(new Predicate<Image>() { @Override public boolean apply(Image input) { // filter out all deprecated images return !(input.deprecated() != null && input.deprecated().state() != null); } }) .first() .get() .selfLink(); instance = NewInstance.create( INSTANCE_NAME, getDefaultMachineTypeUrl(), getNetworkUrl(INSTANCE_NETWORK_NAME), null, imageUri ); return api; }