@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest newGuest = client.getVirtualGuestClient().getVirtualGuest(guest.getId()); boolean hasBackendIp = newGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = newGuest.getPrimaryIpAddress() != null; boolean hasPasswords = newGuest.getOperatingSystem() != null && newGuest.getOperatingSystem().getPasswords().size() > 0; return hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest newGuest = client.getVirtualGuestApi().getObject(guest.getId()); boolean hasBackendIp = newGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = newGuest.getPrimaryIpAddress() != null; boolean hasPasswords = newGuest.getOperatingSystem() != null && newGuest.getOperatingSystem().getPasswords().size() > 0; return hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest newGuest = client.getVirtualGuestClient().getVirtualGuest(guest.getId()); boolean hasBackendIp = newGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = newGuest.getPrimaryIpAddress() != null; boolean hasPasswords = newGuest.getOperatingSystem() != null && newGuest.getOperatingSystem().getPasswords().size() > 0; return hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest virtualGuest = client.getVirtualGuestApi().getVirtualGuest(guest.getId()); boolean hasBackendIp = virtualGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = virtualGuest.getPrimaryIpAddress() != null; boolean hasPasswords = virtualGuest.getOperatingSystem() != null && !virtualGuest.getOperatingSystem().getPasswords().isEmpty(); return virtualGuest.isPrivateNetworkOnly() ? hasBackendIp && hasPasswords : hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest virtualGuest = client.getVirtualGuestApi().getVirtualGuest(guest.getId()); boolean hasBackendIp = virtualGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = virtualGuest.getPrimaryIpAddress() != null; boolean hasPasswords = virtualGuest.getOperatingSystem() != null && !virtualGuest.getOperatingSystem().getPasswords().isEmpty(); return virtualGuest.isPrivateNetworkOnly() ? hasBackendIp && hasPasswords : hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Override public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); VirtualGuest virtualGuest = client.getVirtualGuestApi().getVirtualGuest(guest.getId()); boolean hasBackendIp = virtualGuest.getPrimaryBackendIpAddress() != null; boolean hasPrimaryIp = virtualGuest.getPrimaryIpAddress() != null; boolean hasPasswords = virtualGuest.getOperatingSystem() != null && !virtualGuest.getOperatingSystem().getPasswords().isEmpty(); return virtualGuest.isPrivateNetworkOnly() ? hasBackendIp && hasPasswords : hasBackendIp && hasPrimaryIp && hasPasswords; } }
@Override public NodeMetadata apply(VirtualGuest from) { // convert the result object to a jclouds NodeMetadata NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId() + ""); builder.name(from.getHostname()); builder.hostname(from.getHostname()); if (from.getDatacenter() != null) builder.location(from(locations.get()).firstMatch( LocationPredicates.idEquals(from.getDatacenter().getId() + "")).orNull()); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getHostname())); Image image = images.getImage(from); if (image != null) { builder.imageId(image.getId()); builder.operatingSystem(image.getOperatingSystem()); } builder.hardware(hardware.getHardware(from)); builder.status(serverStateToNodeStatus.get(from.getPowerState().getKeyName())); // These are null for 'bad' guest orders in the HALTED state. if (from.getPrimaryIpAddress() != null) builder.publicAddresses(ImmutableSet.<String> of(from.getPrimaryIpAddress())); if (from.getPrimaryBackendIpAddress() != null) builder.privateAddresses(ImmutableSet.<String> of(from.getPrimaryBackendIpAddress())); return builder.build(); }
@Override public NodeMetadata apply(VirtualGuest from) { // convert the result object to a jclouds NodeMetadata NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId() + ""); builder.name(from.getHostname()); builder.hostname(from.getHostname()); if (from.getDatacenter() != null) builder.location(from(locations.get()).firstMatch( LocationPredicates.idEquals(from.getDatacenter().getId() + "")).orNull()); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getHostname())); Image image = images.getImage(from); if (image != null) { builder.imageId(image.getId()); builder.operatingSystem(image.getOperatingSystem()); } builder.hardware(hardware.getHardware(from)); builder.status(serverStateToNodeStatus.get(from.getPowerState().getKeyName())); // These are null for 'bad' guest orders in the HALTED state. if (from.getPrimaryIpAddress() != null) builder.publicAddresses(ImmutableSet.<String> of(from.getPrimaryIpAddress())); if (from.getPrimaryBackendIpAddress() != null) builder.privateAddresses(ImmutableSet.<String> of(from.getPrimaryBackendIpAddress())); return builder.build(); }
@Override public NodeMetadata apply(VirtualGuest from) { NodeMetadataBuilder builder = new NodeMetadataBuilder(); builder.ids(from.getId() + ""); builder.name(from.getHostname()); builder.hostname(from.getHostname()); if (from.getDatacenter() != null) builder.location(from(locations.get()).firstMatch( LocationPredicates.idEquals(from.getDatacenter().getId() + "")).orNull()); builder.group(nodeNamingConvention.groupInUniqueNameOrNull(from.getHostname())); Image image = new VirtualGuestToImage().apply(from); if (image != null) { builder.imageId(image.getId()); builder.operatingSystem(image.getOperatingSystem()); builder.hardware(new VirtualGuestToHardware().apply(from)); } builder.status(serverStateToNodeStatus.get(from.getPowerState().getKeyName())); if (from.getPrimaryIpAddress() != null) builder.publicAddresses(ImmutableSet.<String> of(from.getPrimaryIpAddress())); if (from.getPrimaryBackendIpAddress() != null) builder.privateAddresses(ImmutableSet.<String> of(from.getPrimaryBackendIpAddress())); return builder.build(); }
if (from.getPrimaryBackendIpAddress() != null) builder.privateAddresses(ImmutableSet.of(from.getPrimaryBackendIpAddress()));
@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())); }
@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())); }
@Test public void testCreateVirtualGuest() throws Exception { VirtualGuest virtualGuestRequest = VirtualGuest.builder() .domain("jclouds.org") .hostname("virtualGuestApiLiveTest") .startCpus(1) .maxMemory(1024) .operatingSystem(OperatingSystem.builder().id("CENTOS_6_64").operatingSystemReferenceCode("CENTOS_6_64").build()) .datacenter(Datacenter.builder().name(datacenter.getName()).build()) .build(); virtualGuest = virtualGuestApi.createVirtualGuest(virtualGuestRequest); boolean orderInSystem = loginDetailsTester.apply(virtualGuest); checkState(orderInSystem, "order for guest %s doesn't have login details within %sms", virtualGuest, Long.toString(guestLoginDelay)); virtualGuest = virtualGuestApi.getVirtualGuest(virtualGuest.getId()); checkVirtualGuest(virtualGuest); assertNotNull(virtualGuest.getPrimaryIpAddress(), "primaryIpAddress must be not null"); assertNotNull(virtualGuest.getPrimaryBackendIpAddress(), "backendIpAddress must be not null"); }
private void checkVirtualGuest(VirtualGuest vg) { if (vg.getBillingItemId() == -1) return;// Quotes and shutting down guests assert vg.getAccountId() > 0 : vg; assert vg.getCreateDate() != null : vg; assert vg.getDomain() != null : vg; assert vg.getFullyQualifiedDomainName() != null : vg; assert vg.getHostname() != null : vg; assert vg.getId() > 0 : vg; assert vg.getMaxCpu() > 0 : vg; assert vg.getMaxCpuUnits() != null : vg; assert vg.getMaxMemory() > 0 : vg; assert vg.getMetricPollDate() != null : vg; assert vg.getModifyDate() != null : vg; assert vg.getStartCpus() > 0 : vg; assert vg.getStatusId() >= 0 : vg; assert vg.getUuid() != null : vg; assert vg.getPrimaryBackendIpAddress() != null : vg; assert vg.getPrimaryIpAddress() != null : vg; }
public T fromVirtualGuest(VirtualGuest in) { return this .accountId(in.getAccountId()) .createDate(in.getCreateDate()) .dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly()) .domain(in.getDomain()) .fullyQualifiedDomainName(in.getFullyQualifiedDomainName()) .hostname(in.getHostname()) .id(in.getId()) .lastVerifiedDate(in.getLastVerifiedDate()) .maxCpu(in.getMaxCpu()) .maxCpuUnits(in.getMaxCpuUnits()) .maxMemory(in.getMaxMemory()) .metricPollDate(in.getMetricPollDate()) .modifyDate(in.getModifyDate()) .notes(in.getNotes()) .privateNetworkOnly(in.isPrivateNetworkOnly()) .startCpus(in.getStartCpus()) .statusId(in.getStatusId()) .uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId()) .operatingSystem(in.getOperatingSystem()) .datacenter(in.getDatacenter()) .powerState(in.getPowerState()); } }
public T fromVirtualGuest(VirtualGuest in) { return this .accountId(in.getAccountId()) .createDate(in.getCreateDate()) .dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly()) .domain(in.getDomain()) .fullyQualifiedDomainName(in.getFullyQualifiedDomainName()) .hostname(in.getHostname()) .id(in.getId()) .lastVerifiedDate(in.getLastVerifiedDate()) .maxCpu(in.getMaxCpu()) .maxCpuUnits(in.getMaxCpuUnits()) .maxMemory(in.getMaxMemory()) .metricPollDate(in.getMetricPollDate()) .modifyDate(in.getModifyDate()) .notes(in.getNotes()) .privateNetworkOnly(in.isPrivateNetworkOnly()) .startCpus(in.getStartCpus()) .statusId(in.getStatusId()) .uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId()) .operatingSystem(in.getOperatingSystem()) .datacenter(in.getDatacenter()) .powerState(in.getPowerState()); } }
.statusId(in.getStatusId()) .uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId())
.statusId(in.getStatusId()) .uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId())
.statusId(in.getStatusId()) .uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId())
.statusId(in.getStatusId()) .uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId())