/** * Makes a new set of options for running nodes */ @Override public TemplateOptions templateOptions() { return computeService.templateOptions(); }
/** * Makes a new set of options for running nodes */ @Override public TemplateOptions templateOptions() { return computeService.templateOptions(); }
@Override public TemplateOptions templateOptions() { return delegate.templateOptions(); }
public boolean isUserDataSupported(String provider, String credId, String url, String zones, boolean trustAll) { // GCE uses meta_data['user-data'] if ("google-compute-engine".equals(provider)) { return true; } // Temporary hack for digitalocean2 if ("digitalocean2".equals(provider)) { return true; } try (ComputeServiceContext ctx = ctx(provider, credId, url, zones, trustAll)) { TemplateOptions o = ctx.getComputeService().templateOptions(); o.getClass().getMethod("userData", new byte[0].getClass()); } catch (ReflectiveOperationException x) { return false; } return true; }
public static Template apply(CreateJCloudsContainerOptions options) { ComputeService service = options.getComputeService(); TemplateOptions templateOptions = service.templateOptions(); TemplateBuilder builder = service.templateBuilder().any(); applyInstanceType(builder, options); applyImageType(builder, options); applyLocation(builder, options); applyProviderSpecificOptions(templateOptions, options); Optional<AdminAccess> adminAccess = ToAdminAccess.apply(options); if (adminAccess.isPresent()) { templateOptions.runScript(adminAccess.get()); } builder = builder.options(templateOptions); return builder.build(); }
@Test(groups = "Live") public void testGeneralPurposeTemplateOptionCustomisation() throws Exception { ConfigKey<Map<String, Object>> key = JcloudsLocationConfig.TEMPLATE_OPTIONS; ConfigBag config = ConfigBag.newInstance() .configure(key, ImmutableMap.of("iamInstanceProfileName", (Object)"helloworld")); AWSEC2TemplateOptions templateOptions = jcloudsLocation.getComputeService().templateOptions().as(AWSEC2TemplateOptions.class); invokeCustomizeTemplateOptions(templateOptions, JcloudsLocationConfig.TEMPLATE_OPTIONS, config); assertEquals(templateOptions.getIAMInstanceProfileName(), "helloworld"); }
@Test(groups = "Live") public void testGeneralPurposeTemplateOptionCustomisationWithList() throws Exception { ConfigKey<Map<String, Object>> key = JcloudsLocationConfig.TEMPLATE_OPTIONS; ConfigBag config = ConfigBag.newInstance() .configure(key, ImmutableMap.of( "iamInstanceProfileName", (Object) "helloworld", "mapNewVolumeToDeviceName", (Object) ImmutableList.of("/dev/sda1/", 123, true))); AWSEC2TemplateOptions templateOptions = jcloudsLocation.getComputeService().templateOptions().as(AWSEC2TemplateOptions.class); invokeCustomizeTemplateOptions(templateOptions, JcloudsLocationConfig.TEMPLATE_OPTIONS, config); assertEquals(templateOptions.getIAMInstanceProfileName(), "helloworld"); assertEquals(templateOptions.getBlockDeviceMappings().size(), 1); BlockDeviceMapping blockDeviceMapping = templateOptions.getBlockDeviceMappings().iterator().next(); assertEquals(blockDeviceMapping.getDeviceName(), "/dev/sda1/"); assertEquals(blockDeviceMapping.getEbsVolumeSize(), (Integer)123); assertTrue(blockDeviceMapping.getEbsDeleteOnTermination()); }
public void testOptionToNotBlock() throws Exception { String group = this.group + "block"; try { client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { } // no inbound ports TemplateOptions options = client.templateOptions().blockUntilRunning(false).inboundPorts(); try { long time = currentTimeMillis(); Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options); NodeMetadata node = getOnlyElement(nodes); assert node.getStatus() != Status.RUNNING : node; long duration = (currentTimeMillis() - time) / 1000; assert duration < nonBlockDurationSeconds : format("duration(%d) longer than expected(%d) seconds! ", duration, nonBlockDurationSeconds); } finally { client.destroyNodesMatching(inGroup(group)); } }
public void run() { try { TemplateOptions options = _compute.templateOptions(); options.runAsRoot(false) .wrapInInitScript(true)
TemplateOptions options = client.templateOptions();
public void testCreatePreemptibleNodeWithSsd() throws Exception { String group = this.group + "ssd"; try { TemplateOptions options = client.templateOptions(); options.as(GoogleComputeEngineTemplateOptions.class).bootDiskType("pd-ssd").preemptible(true); // create a node Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options); assertEquals(nodes.size(), 1, "One node should have been created"); // Verify the disk on the instance is an ssd. NodeMetadata node = Iterables.get(nodes, 0); GoogleComputeEngineApi api = client.getContext().unwrapApi(GoogleComputeEngineApi.class); Instance instance = api.instancesInZone(node.getLocation().getId()).get(node.getName()); Disk disk = api.disksInZone(node.getLocation().getId()).get(toName(instance.disks().get(0).source())); assertTrue(disk.type().toString().endsWith("pd-ssd")); assertTrue(instance.scheduling().preemptible()); } finally { client.destroyNodesMatching(inGroup(group)); } } /**
@Test public void testExtendedOptionsWithCustomizationScript() throws Exception { String PARSE_VMTOOLSD = "vmtoolsd --cmd=\"info-get guestinfo.ovfenv\" |grep vCloud_CustomizationInfo|sed 's/.*value=\"\\(.*\\)\".*/\\1/g'"; String group = prefix + "cus"; NodeMetadata node = null; try { TemplateOptions options = client.templateOptions(); options.blockOnPort(22, 180); options.as(VCloudTemplateOptions.class).customizationScript(script); options.as(VCloudTemplateOptions.class).description(group); node = getOnlyElement(client.createNodesInGroup(group, 1, options)); VApp vapp = client.getContext().unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi().getVAppClient().getVApp( node.getUri()); assertEquals(vapp.getDescription(), group); Vm vm = Iterables.get(vapp.getChildren(), 0); String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript(); checkApiOutput(apiOutput); ExecResponse vmTools = client.runScriptOnNode(node.getId(), PARSE_VMTOOLSD, wrapInInitScript(false).runAsRoot(false)); checkApiOutput(new String(base64().decode(vmTools.getOutput().trim()), UTF_8)); ExecResponse foo = client.runScriptOnNode(node.getId(), "cat /root/foo.txt", wrapInInitScript(false) .runAsRoot(false)); checkCustomizationOccurred(foo); } finally { if (node != null) client.destroyNode(node.getId()); } }
TemplateOptions options = client.templateOptions();
view.getComputeService().destroyNodesMatching(inGroup(group)); TemplateOptions options = view.getComputeService().templateOptions();
TemplateOptions options = client.templateOptions();
TemplateOptions options = client.templateOptions().blockOnPort(22, 120); try { Set<? extends NodeMetadata> nodes = client.createNodesInGroup(group, 1, options);
GoogleComputeEngineTemplateOptions options = computeService.templateOptions() .as(GoogleComputeEngineTemplateOptions.class).autoCreateKeyPair(false) .tags(ImmutableSet.of("aTag")).blockUntilRunning(false);
GoogleComputeEngineTemplateOptions options = computeService.templateOptions() .as(GoogleComputeEngineTemplateOptions.class).autoCreateKeyPair(false) .tags(ImmutableSet.of("aTag")).blockUntilRunning(false)
GoogleComputeEngineTemplateOptions options = computeService.templateOptions() .as(GoogleComputeEngineTemplateOptions.class).autoCreateKeyPair(false) .tags(ImmutableSet.of("aTag")).blockUntilRunning(false)
GoogleComputeEngineTemplateOptions options = computeService.templateOptions() .as(GoogleComputeEngineTemplateOptions.class).autoCreateKeyPair(false) .tags(ImmutableSet.of("aTag")).blockUntilRunning(false)