@Override public Datacenter apply(ContainerVirtualGuestConfigurationOption input) { return input.getTemplate().getDatacenter(); } }));
@Override public Datacenter apply(ContainerVirtualGuestConfigurationOption input) { return input.getTemplate().getDatacenter(); } }));
@Override public Datacenter apply(ContainerVirtualGuestConfigurationOption input) { return input.getTemplate().getDatacenter(); } }));
@Override public Datacenter apply(ContainerVirtualGuestConfigurationOption input) { return input.getTemplate().getDatacenter(); } }));
/** * 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))); }
@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(); }
builder.name(from.getHostname()); builder.hostname(from.getFullyQualifiedDomainName()); if (from.getDatacenter() != null) { builder.location(from(locations.get()).firstMatch( LocationPredicates.idEquals(from.getDatacenter().getName())).orNull());
builder.name(from.getHostname()); builder.hostname(from.getFullyQualifiedDomainName()); if (from.getDatacenter() != null) { builder.location(from(locations.get()).firstMatch( LocationPredicates.idEquals(from.getDatacenter().getName())).orNull());
@Test public void testApplyWhereVirtualGuestWithNoPassword() { // notice if we've already parsed this properly here, we can rely on it. VirtualGuest guest = new ParseVirtualGuestWithNoPasswordTest().expected(); // setup so that we have an expected Location to be parsed from the guest. Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter()); Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet .<Location> of(expectedLocation)); VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata( locationSupplier, new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention); NodeMetadata node = parser.apply(guest); assertEquals( node, new NodeMetadataBuilder().ids("416788").name("node1000360500").hostname("node1000360500") .location(expectedLocation).status(Status.PENDING) .publicAddresses(ImmutableSet.of("173.192.29.186")) .privateAddresses(ImmutableSet.of("10.37.102.194")) .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest)) .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId()) .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build()); }
@Test public void testApplyWhereVirtualGuestIsPaused() { // notice if we've already parsed this properly here, we can rely on it. VirtualGuest guest = new ParseVirtualGuestPausedTest().expected(); // setup so that we have an expected Location to be parsed from the guest. Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter()); Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet .<Location> of(expectedLocation)); VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(locationSupplier, new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention); NodeMetadata node = parser.apply(guest); assertEquals( node, new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489") .location(expectedLocation).status(Status.SUSPENDED) .publicAddresses(ImmutableSet.of("173.192.29.187")) .privateAddresses(ImmutableSet.of("10.37.102.195")) .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest)) .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId()) .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build()); }
@Test public void testApplyWhereVirtualGuestIsHalted() { // notice if we've already parsed this properly here, we can rely on it. VirtualGuest guest = new ParseVirtualGuestHaltedTest().expected(); // setup so that we have an expected Location to be parsed from the guest. Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter()); Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet .<Location> of(expectedLocation)); VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(locationSupplier, new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention); NodeMetadata node = parser.apply(guest); assertEquals( node, new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489") .location(expectedLocation).status(Status.PENDING) .publicAddresses(ImmutableSet.of("173.192.29.187")) .privateAddresses(ImmutableSet.of("10.37.102.195")) .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest)) .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId()) .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build()); }
@Test public void testApplyWhereVirtualGuestIsRunning() { // notice if we've already parsed this properly here, we can rely on it. VirtualGuest guest = new ParseVirtualGuestRunningTest().expected(); // setup so that we have an expected Location to be parsed from the guest. Location expectedLocation = DatacenterToLocationTest.function.apply(guest.getDatacenter()); Supplier<Set<? extends Location>> locationSupplier = Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet .<Location> of(expectedLocation)); VirtualGuestToNodeMetadata parser = new VirtualGuestToNodeMetadata(locationSupplier, new GetHardwareForVirtualGuestMock(), new GetImageForVirtualGuestMock(), namingConvention); NodeMetadata node = parser.apply(guest); assertEquals( node, new NodeMetadataBuilder().ids("416700").name("node1703810489").hostname("node1703810489") .location(expectedLocation).status(Status.RUNNING) .publicAddresses(ImmutableSet.of("173.192.29.187")) .privateAddresses(ImmutableSet.of("10.37.102.195")) .hardware(new GetHardwareForVirtualGuestMock().getHardware(guest)) .imageId(new GetImageForVirtualGuestMock().getImage(guest).getId()) .operatingSystem(new GetImageForVirtualGuestMock().getImage(guest).getOperatingSystem()).build()); }
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()); } }
.operatingSystem(in.getOperatingSystem()) .operatingSystemReferenceCode(in.getOperatingSystemReferenceCode()) .datacenter(in.getDatacenter()) .powerState(in.getPowerState()) .activeTransactionCount(in.getActiveTransactionCount())
.operatingSystem(in.getOperatingSystem()) .operatingSystemReferenceCode(in.getOperatingSystemReferenceCode()) .datacenter(in.getDatacenter()) .powerState(in.getPowerState()) .activeTransactionCount(in.getActiveTransactionCount())
.operatingSystem(in.getOperatingSystem()) .operatingSystemReferenceCode(in.getOperatingSystemReferenceCode()) .datacenter(in.getDatacenter()) .powerState(in.getPowerState()) .activeTransactionCount(in.getActiveTransactionCount())
.operatingSystem(in.getOperatingSystem()) .operatingSystemReferenceCode(in.getOperatingSystemReferenceCode()) .datacenter(in.getDatacenter()) .powerState(in.getPowerState()) .activeTransactionCount(in.getActiveTransactionCount())