@Override public OperatingSystem getImage(final String id) { // look for imageId among stock images Optional<OperatingSystem> operatingSystemOptional = tryFind(listImages(), new Predicate<OperatingSystem>() { @Override public boolean apply(OperatingSystem input) { return input.getId().equals(id); } } ); if (operatingSystemOptional.isPresent()) return operatingSystemOptional.get(); // if imageId is not a stock image, it searches among private and public images Stopwatch stopwatch = Stopwatch.createStarted(); VirtualGuestBlockDeviceTemplateGroup image = api.getVirtualGuestBlockDeviceTemplateGroupApi().getObject(id); logger.trace("<< Image(%s) found in (%s)", id, stopwatch.elapsed(TimeUnit.SECONDS)); return tryExtractOperatingSystemFrom(image).orNull(); }
@Override public Iterable<VirtualGuest> listNodesByIds(final Iterable<String> ids) { return filter(listNodes(), new Predicate<VirtualGuest>() { @Override public boolean apply(VirtualGuest server) { return contains(ids, server.getId()); } }); }
final String imageId = template.getImage().getId(); int cores = (int) template.getHardware().getProcessors().get(0).getCores(); String notes = getNotes(templateOptions); .maxMemory(template.getHardware().getRam()) .datacenter(datacenter) .localDiskFlag(isLocalDisk(diskType)) .networkComponents(networkComponents); Optional<OperatingSystem> optionalOperatingSystem = tryExtractOperatingSystemFrom(imageId); if (optionalOperatingSystem.isPresent()) { virtualGuestBuilder.operatingSystem(optionalOperatingSystem.get()); List<VirtualGuestBlockDevice> blockDevices = getBlockDevices(templateOptions.getBlockDevices(), diskType); virtualGuestBuilder.blockDevices(blockDevices);
public boolean apply(VirtualGuest guest) { guest = getNode(guest.getId() + ""); return guest.getActiveTransactionCount() == 0; } }, activeTransactionsDelay).apply(guest), "%s still has active transactions!", guest);
@Override public ProductItem getImage(final String id) { return find(listImages(), new Predicate<ProductItem>(){ @Override public boolean apply(ProductItem input) { return ProductItemToImage.imageId().apply(input).equals(id); } }, null); }
Optional<OperatingSystem> optionalOperatingSystem = tryGetOperatingSystemFrom(imageId); if (optionalOperatingSystem.isPresent()) { virtualGuestBuilder.operatingSystem(optionalOperatingSystem.get()); Set<VirtualGuestBlockDevice> blockDevices = getBlockDevices(templateOptions.getBlockDevices().get()); virtualGuestBuilder.blockDevices(blockDevices); virtualGuestBuilder.localDiskFlag(isLocalDisk(diskType));
@AfterGroups(groups = "live") protected void tearDown() { if (guest != null) adapter.destroyNode(guest.getNodeId() + ""); super.tearDown(); }
@Test public void testListHardwareProfiles() { Iterable<Iterable<ProductItem>> profiles = adapter.listHardwareProfiles(); assertFalse(Iterables.isEmpty(profiles)); for (Iterable<ProductItem> profile : profiles) { // CPU, RAM and Volume assertEquals(Iterables.size(profile), 3); } }
@Test public void testListLocations() { assertFalse(Iterables.isEmpty(adapter.listLocations())); }
@Test public void testCreateNodeWithGroupEncodedIntoNameThenStoreCredentials() { String group = "foo"; String name = "node" + new Random().nextInt(); Template template = templateBuilder.build(); // test passing custom options template.getOptions().as(SoftLayerTemplateOptions.class).domainName("me.org"); guest = adapter.createNodeWithGroupEncodedIntoName(group, name, template); assertEquals(guest.getNode().getHostname(), name); assertEquals(guest.getNodeId(), guest.getNode().getId() + ""); assertEquals(guest.getNode().getDomain(), template.getOptions().as(SoftLayerTemplateOptions.class) .getDomainName()); assert InetAddresses.isInetAddress(guest.getNode().getPrimaryBackendIpAddress()) : guest; doConnectViaSsh(guest.getNode(), prioritizeCredentialsFromTemplate.apply(template, guest.getCredentials())); }
final String imageId = template.getImage().getId(); int cores = (int) template.getHardware().getProcessors().get(0).getCores(); String notes = getNotes(templateOptions); .maxMemory(template.getHardware().getRam()) .datacenter(datacenter) .localDiskFlag(isLocalDisk(diskType)) .networkComponents(networkComponents); Optional<OperatingSystem> optionalOperatingSystem = tryExtractOperatingSystemFrom(imageId); if (optionalOperatingSystem.isPresent()) { virtualGuestBuilder.operatingSystem(optionalOperatingSystem.get()); List<VirtualGuestBlockDevice> blockDevices = getBlockDevices(templateOptions.getBlockDevices(), diskType); virtualGuestBuilder.blockDevices(blockDevices);
public boolean apply(VirtualGuest guest) { return getNode(guest.getId() + "").getActiveTransactionCount() == 0; } }, activeTransactionsDelay).apply(guest), "%s still has active transactions!", guest);
@Override public OperatingSystem getImage(final String id) { return find(listImages(), new Predicate<OperatingSystem>() { @Override public boolean apply(OperatingSystem input) { return input.getId().equals(id); } }, null); }
@AfterGroups(groups = "live") protected void tearDown() { if (guest != null) { adapter.destroyNode(guest.getNodeId() + ""); } super.tearDown(); }
@Test public void testListHardwareProfiles() { Iterable<Hardware> profiles = adapter.listHardwareProfiles(); assertFalse(Iterables.isEmpty(profiles)); for (Hardware profile : profiles) { assertNotNull(profile); } }
@Test public void testListLocations() { Iterable<Datacenter> locations = adapter.listLocations(); assertFalse(Iterables.isEmpty(locations), "locations must not be empty"); }
@Test public void testCreateNodeWithGroupEncodedIntoNameThenStoreCredentials() { String group = "foo"; String name = "node" + new Random().nextInt(); Template template = templateBuilder.build(); // test passing custom options template.getOptions().as(SoftLayerTemplateOptions.class).domainName("me.org"); guest = adapter.createNodeWithGroupEncodedIntoName(group, name, template); assertEquals(guest.getNode().getHostname(), name); assertEquals(guest.getNodeId(), guest.getNode().getId() + ""); assertEquals(guest.getNode().getDomain(), template.getOptions().as(SoftLayerTemplateOptions.class) .getDomainName()); assert InetAddresses.isInetAddress(guest.getNode().getPrimaryBackendIpAddress()) : guest; doConnectViaSsh(guest.getNode(), prioritizeCredentialsFromTemplate.apply(template, guest.getCredentials())); }
final String imageId = template.getImage().getId(); int cores = (int) template.getHardware().getProcessors().get(0).getCores(); String notes = getNotes(templateOptions); .maxMemory(template.getHardware().getRam()) .datacenter(datacenter) .localDiskFlag(isLocalDisk(diskType)) .networkComponents(networkComponents); Optional<OperatingSystem> optionalOperatingSystem = tryExtractOperatingSystemFrom(imageId); if (optionalOperatingSystem != null) { virtualGuestBuilder.operatingSystem(optionalOperatingSystem.get()); List<VirtualGuestBlockDevice> blockDevices = getBlockDevices(templateOptions.getBlockDevices(), diskType); virtualGuestBuilder.blockDevices(blockDevices);
public boolean apply(VirtualGuest guest) { return getNode(guest.getId() + "").getActiveTransactionCount() == 0; } }, activeTransactionsDelay).apply(guest), "%s still has active transactions!", guest);
@Override public OperatingSystem getImage(final String id) { // look for imageId among stock images Optional<OperatingSystem> operatingSystemOptional = tryFind(listImages(), new Predicate<OperatingSystem>() { @Override public boolean apply(OperatingSystem input) { return input.getId().equals(id); } } ); if (operatingSystemOptional.isPresent()) return operatingSystemOptional.get(); // if imageId is not a stock image, it searches among private and public images Stopwatch stopwatch = Stopwatch.createStarted(); VirtualGuestBlockDeviceTemplateGroup image = api.getVirtualGuestBlockDeviceTemplateGroupApi().getObject(id); logger.trace("<< Image(%s) found in (%s)", id, stopwatch.elapsed(TimeUnit.SECONDS)); return tryExtractOperatingSystemFrom(image).orNull(); }