@Override public HostnameAndDomain apply(VirtualGuest virtualGuest) { return new HostnameAndDomain(virtualGuest.getHostname(), virtualGuest.getDomain()); } });
@Override public HostnameAndDomain apply(VirtualGuest virtualGuest) { return new HostnameAndDomain(virtualGuest.getHostname(), virtualGuest.getDomain()); } });
private void checkVirtualGuest(VirtualGuest vg) { if (vg.getActiveTransactionCount() == 0) { assertNotNull(vg.getDomain(), "domain must be not null"); assertNotNull(vg.getFullyQualifiedDomainName(), "fullyQualifiedDomainName must be not null"); assertNotNull(vg.getHostname(), "hostname must be not null"); assertTrue(vg.getId() > 0, "id must be greater than 0"); assertTrue(vg.getMaxCpu() > 0, "maxCpu must be greater than 0"); assertTrue(vg.getMaxMemory() > 0, "maxMemory must be greater than 0"); assertTrue(vg.getStatusId() > 0, "statusId must be greater than 0"); } }
private void checkVirtualGuest(VirtualGuest vg) { if (vg.getActiveTransactionCount() == 0) { assertNotNull(vg.getDomain(), "domain must be not null"); assertNotNull(vg.getFullyQualifiedDomainName(), "fullyQualifiedDomainName must be not null"); assertNotNull(vg.getHostname(), "hostname must be not null"); assertTrue(vg.getId() > 0, "id must be greater than 0"); assertTrue(vg.getMaxCpu() > 0, "maxCpu must be greater than 0"); assertNotNull(vg.getMaxCpuUnits(), "maxCpuUnits must be not null"); assertTrue(vg.getMaxMemory() > 0, "maxMemory must be greater than 0"); assertTrue(vg.getStartCpus() > 0, "startCpus must be greater than 0"); assertTrue(vg.getStatusId() > 0, "statusId must be greater than 0"); assertNotNull(vg.getUuid(), "uuid must be not null"); } }
/** * Builds a Json string suitable for sending to the softlayer api * * @param virtualGuest * @return String */ String buildJson(VirtualGuest virtualGuest) { TemplateObject templateObject = null; String hostname = checkNotNull(virtualGuest.getHostname(), "hostname"); String domain = checkNotNull(virtualGuest.getDomain(), "domain"); int startCpus = checkNotNull(virtualGuest.getStartCpus(), "startCpus"); int maxMemory = checkNotNull(virtualGuest.getMaxMemory(), "maxMemory"); boolean localDiskFlag = checkNotNull(virtualGuest.isLocalDiskFlag(), "localDiskFlag"); String datacenterName = checkNotNull(virtualGuest.getDatacenter().getName(), "datacenterName"); Set<NetworkComponent> networkComponents = getNetworkComponents(virtualGuest); if(virtualGuest.getOperatingSystem() != null) { String operatingSystemReferenceCode = checkNotNull(virtualGuest.getOperatingSystem() .getOperatingSystemReferenceCode(), "operatingSystemReferenceCode"); templateObject = new TemplateObject(hostname, domain, startCpus, maxMemory, true, operatingSystemReferenceCode, null, localDiskFlag, new Datacenter(datacenterName), networkComponents, getBlockDevices(virtualGuest)); } else if(virtualGuest.getVirtualGuestBlockDeviceTemplateGroup() != null) { String globalIdentifier = checkNotNull(virtualGuest.getVirtualGuestBlockDeviceTemplateGroup() .getGlobalIdentifier(), "blockDeviceTemplateGroup.globalIdentifier"); templateObject = new TemplateObject(hostname, domain, startCpus, maxMemory, true, null, new BlockDeviceTemplateGroup(globalIdentifier), localDiskFlag, new Datacenter(datacenterName), networkComponents, null); } return json.toJson(ImmutableMap.of("parameters", ImmutableList.<TemplateObject> of(templateObject))); }
@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())); }
TemplateObject.Builder templateObjectBuilder = TemplateObject.builder(); String hostname = checkNotNull(virtualGuest.getHostname(), "hostname"); String domain = checkNotNull(virtualGuest.getDomain(), "domain"); int startCpus = virtualGuest.getStartCpus(); int maxMemory = virtualGuest.getMaxMemory();
@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())); }
TemplateObject.Builder templateObjectBuilder = TemplateObject.builder(); String hostname = checkNotNull(virtualGuest.getHostname(), "hostname"); String domain = checkNotNull(virtualGuest.getDomain(), "domain"); int startCpus = virtualGuest.getStartCpus(); int maxMemory = virtualGuest.getMaxMemory();
TemplateObject.Builder templateObjectBuilder = TemplateObject.builder(); String hostname = checkNotNull(virtualGuest.getHostname(), "hostname"); String domain = checkNotNull(virtualGuest.getDomain(), "domain"); int startCpus = virtualGuest.getStartCpus(); int maxMemory = virtualGuest.getMaxMemory();
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()); } }
.createDate(in.getCreateDate()) .dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly()) .domain(in.getDomain()) .fullyQualifiedDomainName(in.getFullyQualifiedDomainName()) .hostname(in.getHostname())
.createDate(in.getCreateDate()) .dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly()) .domain(in.getDomain()) .fullyQualifiedDomainName(in.getFullyQualifiedDomainName()) .hostname(in.getHostname())
.createDate(in.getCreateDate()) .dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly()) .domain(in.getDomain()) .fullyQualifiedDomainName(in.getFullyQualifiedDomainName()) .hostname(in.getHostname())
.createDate(in.getCreateDate()) .dedicatedAccountHostOnly(in.isDedicatedAccountHostOnly()) .domain(in.getDomain()) .fullyQualifiedDomainName(in.getFullyQualifiedDomainName()) .hostname(in.getHostname())