private Server addServer(String name, Template template, Ip availableIp) { Server addedServer = client.getServerServices().addServer(name, checkNotNull(template.getImage().getProviderId()), sizeToRam.apply(template.getHardware()), availableIp.getIp()); return addedServer; }
@Override public InstantiateVAppTemplateOptions apply(Template from) { InstantiateVAppTemplateOptions options = processorCount(Double.valueOf(getCores(from.getHardware())).intValue()) .memory(from.getHardware().getRam()); if (!from.getOptions().shouldBlockUntilRunning()) options.block(false); String sshKeyFingerprint = TerremarkVCloudTemplateOptions.class.cast(from.getOptions()).getSshKeyFingerprint(); if (sshKeyFingerprint != null) options.sshKeyFingerprint(sshKeyFingerprint); return options; } }
@Test(groups={"Live", "Live-sanity"}) public void testJcloudsCreateWithHardwareIdLongForm() throws Exception { obtainMachine(ImmutableMap.of(JcloudsLocation.HARDWARE_ID, N1_STANDARD_1_HARDWARE_ID_LONG_FORM)); assertEquals(template.getHardware().getId(), N1_STANDARD_1_HARDWARE_ID_LONG_FORM, "template="+template); }
@Override public AtomicReference<NodeMetadata> call() throws Exception { NodeMetadata node = null; logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", template.getLocation().getId(), name, MoreObjects.firstNonNull(template.getImage().getProviderId(), template.getImage().getId()), MoreObjects.firstNonNull(template.getHardware().getProviderId(), template.getHardware().getId())); node = addNodeWithGroupStrategy.createNodeWithGroupEncodedIntoName(group, name, template); logger.debug("<< %s node(%s)", formatStatus(node), node.getId()); return new AtomicReference<NodeMetadata>(node); }
@Test public void testBiggestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 16); assertEquals(getSpace(template.getHardware()), 100.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testFastestTemplateBuilder() throws IOException { Template template = view.getComputeService().templateBuilder().fastest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 1); assertEquals(getSpace(template.getHardware()), 25.0d); assertEquals(template.getHardware().getVolumes().get(0).getType(), Volume.Type.LOCAL); }
@Test public void testTemplateChoiceForInstanceByCChardwareId() throws Exception { Template template = newTemplateBuilder().fastest().build(); assert template != null : "The returned template was null, but it should have a value."; assert CC1_4XLARGE.equals(template.getHardware()) : format( "Incorrect image determined by the template. Expected: %s. Found: %s.", CC1_4XLARGE.getId(), template .getHardware().getId()); }
@Test(groups={"Live", "Live-sanity"}) public void testJcloudsCreateWithHardwareIdLongFormWithNoRegion() throws Exception { // Expect it to default to GCE_USCENTRAL_REGION_NAME - // but is that only because that region is hard-coded in the long hardwareId?! replaceJcloudsLocation(GCE_PROVIDER); obtainMachine(ImmutableMap.of(JcloudsLocation.HARDWARE_ID, N1_STANDARD_1_HARDWARE_ID_LONG_FORM)); assertEquals(template.getHardware().getId(), N1_STANDARD_1_HARDWARE_ID_LONG_FORM, "template="+template); }
@Test(groups={"Live", "Live-sanity"}) public void testJcloudsCreateWithHardwareIdShortFormWithNoRegionInLocationSpec() throws Exception { replaceJcloudsLocation(GCE_PROVIDER); obtainMachine(ImmutableMap.of( JcloudsLocation.CLOUD_REGION_ID, GCE_USCENTRAL_REGION_NAME, JcloudsLocation.HARDWARE_ID, N1_STANDARD_1_HARDWARE_ID)); assertEquals(template.getHardware().getId(), N1_STANDARD_1_HARDWARE_ID_LONG_FORM, "template="+template); }
@Test(groups={"Live", "Live-sanity"}) public void testJcloudsCreateWithHardwareIdLongFormWithNoRegionInLocationSpec() throws Exception { // region will be passed in the obtain() call replaceJcloudsLocation(GCE_PROVIDER); obtainMachine(ImmutableMap.of( JcloudsLocation.CLOUD_REGION_ID, GCE_USCENTRAL_REGION_NAME, JcloudsLocation.HARDWARE_ID, N1_STANDARD_1_HARDWARE_ID_LONG_FORM)); assertEquals(template.getHardware().getId(), N1_STANDARD_1_HARDWARE_ID_LONG_FORM, "template="+template); }
private void checkTemplate(Template defaultTemplate) { assertEquals(defaultTemplate.getImage().getId(), "RegionOne/15"); assertEquals(defaultTemplate.getImage().getProviderId(), "15"); assertEquals(defaultTemplate.getHardware().getId(), "RegionOne/1"); assertEquals(defaultTemplate.getHardware().getProviderId(), "1"); assertEquals(defaultTemplate.getLocation().getId(), "RegionOne"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); }
/** * {@inheritDoc} */ @Override public TemplateBuilder fromTemplate(Template template) { location = template.getLocation(); fromHardware(template.getHardware()); fromImage(template.getImage()); options(template.getOptions()); return this; }
@Override public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String tag, String name, Template template) { // create the backend object using parameters from the template. Server from = client.createServerInDC(template.getLocation().getId(), name, Integer.parseInt(template.getImage().getProviderId()), Integer.parseInt(template.getHardware().getProviderId())); return new NodeAndInitialCredentials<Server>(from, from.id + "", LoginCredentials.builder().user(from.loginUser) .password(from.password).build()); }
/** * {@inheritDoc} */ @Override public TemplateBuilder fromTemplate(Template template) { location = template.getLocation(); fromHardware(template.getHardware()); fromImage(template.getImage()); options(template.getOptions()); return this; }
/** * {@inheritDoc} */ @Override public TemplateBuilder fromTemplate(Template template) { location = template.getLocation(); fromHardware(template.getHardware()); fromImage(template.getImage()); options(template.getOptions()); return this; }
@Override public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String group, String name, Template template) { Server server = client .createServer(name, Integer.parseInt(template.getImage().getProviderId()), Integer.parseInt(template .getHardware().getProviderId()), withMetadata(metadataAndTagsAsCommaDelimitedValue(template.getOptions()))); return new NodeAndInitialCredentials<Server>(server, server.getId() + "", LoginCredentials.builder().password( server.getAdminPass()).build()); }
@Override public AtomicReference<NodeMetadata> call() throws Exception { NodeMetadata node = null; logger.debug(">> adding node location(%s) name(%s) image(%s) hardware(%s)", template.getLocation().getId(), name, template.getImage().getProviderId(), template.getHardware().getProviderId()); node = addNodeWithGroupStrategy.createNodeWithGroupEncodedIntoName(group, name, template); logger.debug("<< %s node(%s)", formatStatus(node), node.getId()); return new AtomicReference<NodeMetadata>(node); }
@Override public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String group, String name, Template template) { Server server = client .createServer(name, Integer.parseInt(template.getImage().getProviderId()), Integer.parseInt(template .getHardware().getProviderId()), withMetadata(metadataAndTagsAsCommaDelimitedValue(template.getOptions()))); return new NodeAndInitialCredentials<Server>(server, server.getId() + "", LoginCredentials.builder().password( server.getAdminPass()).build()); }
@Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 0.5d); }
@Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = view.getComputeService().templateBuilder().build(); assert defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[012].[10][04]") : defaultTemplate .getImage().getOperatingSystem().getVersion(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); }