@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; } }
protected void doConnectViaSsh(VirtualGuest guest, LoginCredentials creds) { SshClient ssh = sshFactory.create(HostAndPort.fromParts(guest.getPrimaryIpAddress(), 22), creds); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); assertEquals(hello.getOutput().trim(), "hello"); System.err.println(ssh.exec("df -k").getOutput()); System.err.println(ssh.exec("mount").getOutput()); System.err.println(ssh.exec("uname -a").getOutput()); } finally { if (ssh != null) ssh.disconnect(); } }
@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(); }
protected void doConnectViaSsh(VirtualGuest guest, LoginCredentials creds) { SshClient ssh = sshFactory.create(HostAndPort.fromParts(guest.getPrimaryIpAddress(), 22), creds); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); assertEquals(hello.getOutput().trim(), "hello"); System.err.println(ssh.exec("df -k").getOutput()); System.err.println(ssh.exec("mount").getOutput()); System.err.println(ssh.exec("uname -a").getOutput()); } finally { if (ssh != null) ssh.disconnect(); } }
@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(); }
builder.status(serverStateToNodeStatus.get(from.getPowerState().getKeyName())); if (from.getPrimaryIpAddress() != null) builder.publicAddresses(ImmutableSet.of(from.getPrimaryIpAddress())); if (from.getPrimaryBackendIpAddress() != null) builder.privateAddresses(ImmutableSet.of(from.getPrimaryBackendIpAddress()));
@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()); } }
.uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId()) .operatingSystem(in.getOperatingSystem())
.uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId()) .operatingSystem(in.getOperatingSystem())
.uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId()) .operatingSystem(in.getOperatingSystem())
.uuid(in.getUuid()) .primaryBackendIpAddress(in.getPrimaryBackendIpAddress()) .primaryIpAddress(in.getPrimaryIpAddress()) .billingItemId(in.getBillingItemId()) .operatingSystem(in.getOperatingSystem())