private Set<RunningInstance> createKeyPairAndSecurityGroupsAsNeededThenRunInstances(String group, int count, Template template) { String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation()); String zone = getZoneFromLocationOrNull(template.getLocation()); RunInstancesOptions instanceOptions = createKeyPairAndSecurityGroupsAsNeededAndReturncustomize.execute(region, group, template); return createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions); }
private Set<RunningInstance> createKeyPairAndSecurityGroupsAsNeededThenRunInstances(String group, int count, Template template) { String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation()); String zone = getZoneFromLocationOrNull(template.getLocation()); RunInstancesOptions instanceOptions = createKeyPairAndSecurityGroupsAsNeededAndReturncustomize.execute(region, group, template); return createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions); }
private Set<RunningInstance> createKeyPairAndSecurityGroupsAsNeededThenRunInstances(String group, int count, Template template) { String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation()); String zone = getZoneFromLocationOrNull(template.getLocation()); RunInstancesOptions instanceOptions = createKeyPairAndSecurityGroupsAsNeededAndReturncustomize.execute(region, group, template); return createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions); }
@Override public Map<?, ListenableFuture<Void>> execute(String tag, int count, Template template, Set<NodeMetadata> goodNodes, Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) { assert template.getLocation().getParent().getScope() == LocationScope.REGION : "template location should have a parent of org, which should be mapped to region: " + template.getLocation(); String orgId = template.getLocation().getParent().getId(); assert orgId.startsWith("http") : "parent id should be a rest url: " + template.getLocation().getParent(); createNewKeyPairUnlessUserSpecifiedOtherwise.execute(URI.create(orgId), tag, template.getImage() .getDefaultCredentials().identity, template.getOptions().as(TerremarkVCloudTemplateOptions.class)); return super.execute(tag, count, template, goodNodes, badNodes, customizationResponses); } }
@Override public Set<? extends NodeMetadata> createNodesInGroup(String group, int count, final Template template) throws RunNodesException { Set<? extends NodeMetadata> nodes = super.createNodesInGroup(group, count, template); String region = AWSUtils.getRegionFromLocationOrNull(template.getLocation()); if (client.getTagApiForRegion(region).isPresent()) { Map<String, String> common = metadataAndTagsAsValuesOfEmptyString(template.getOptions()); if (common.size() > 0 || generateInstanceNames) { return addTagsToInstancesInRegion(common, nodes, region, group); } } return nodes; }
/** * {@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 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(groups = { "integration", "live" }, singleThreaded = true) public void testCreateSecurityGroup() throws RunNodesException, InterruptedException, ExecutionException { skipIfSecurityGroupsNotSupported(); ComputeService computeService = view.getComputeService(); Location location = getNodeTemplate().getLocation(); Optional<SecurityGroupExtension> securityGroupExtension = computeService.getSecurityGroupExtension(); assertTrue(securityGroupExtension.isPresent(), "security extension was not present"); SecurityGroup group = securityGroupExtension.get().createSecurityGroup(secGroupName, location); logger.info("Group created: %s", group); assertTrue(group.getName().contains(secGroupName)); groupId = group.getId(); }
@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 boolean apply(Location arg0) { return arg0.getScope() == LocationScope.ZONE && arg0.getParent().getId().equals(template.getLocation().getId()); }
@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 boolean apply(Location arg0) { return arg0.getScope() == LocationScope.ZONE && arg0.getParent().getId().equals(template.getLocation().getId()); }
@Override @Test(dataProvider = "onlyIfAutomaticHardwareSupported", groups = {"integration", "live"}) public void testAutoGeneratedHardwareFromId() { Template template = view.getComputeService().templateBuilder() .hardwareId("automatic:cores=2;ram=1024").build(); assertThat(template.getHardware().getId()).isEqualTo(template.getLocation() .getDescription() + "/machineTypes/custom-2-1024"); assertThat(template.getHardware().getRam()).isEqualTo(1024); assertThat(template.getHardware().getProcessors().get(0).getCores()).isEqualTo(2); assertThat(template.getHardware().getUri()).isEqualTo(URI.create(template.getLocation() .getDescription() + "/machineTypes/custom-2-1024")); }
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); }
@Test public void testDefaultTemplateBuilder() throws IOException { Template defaultTemplate = this.view.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "12.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); assertEquals(defaultTemplate.getLocation().getId(), "go2cloud-jhb1"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); }
@Test public void testTemplateBuilderCanUseImageId() throws Exception { Template defaultTemplate = view.getComputeService().templateBuilder().build(); view.close(); setupContext(); Template template = view.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId()) .locationId(defaultTemplate.getLocation().getId()).build(); assertEquals(template.getImage(), defaultTemplate.getImage()); }
@Test public void testTemplateBuilderCanUseImageId() throws Exception { Template defaultTemplate = view.getComputeService().templateBuilder().build(); view.close(); setupContext(); Template template = view.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId()) .locationId(defaultTemplate.getLocation().getId()).build(); assertEquals(template.getImage(), defaultTemplate.getImage()); }