From f134367c692c70b560c7ba1d6408277725185361 Mon Sep 17 00:00:00 2001 From: Andrea Turli Date: Tue, 14 Oct 2014 15:21:39 +0200 Subject: [PATCH] add support for primaryNetworkComponent.networkVlan.id, primaryBackendNetworkComponent.networkVlan.id, postInstallScriptUri, user-data, privateNetworkOnly and sshKeys options --- .../softlayer/SoftLayerProviderMetadata.java | 2 +- .../softlayer/binders/VirtualGuestToJson.java | 180 +++++----- .../SoftLayerComputeServiceContextModule.java | 4 +- .../functions/internal/OperatingSystems.java | 2 + .../options/SoftLayerTemplateOptions.java | 169 +++++++++ .../SoftLayerComputeServiceAdapter.java | 71 +++- .../jclouds/softlayer/domain/NetworkVlan.java | 181 ++++++++++ .../softlayer/domain/SecuritySshKey.java | 200 +++++++++++ .../softlayer/domain/VirtualGuest.java | 234 +++++++++---- .../domain/VirtualGuestAttribute.java | 86 +++++ .../domain/VirtualGuestNetworkComponent.java | 28 +- .../domain/internal/BlockDevice.java | 43 +++ .../internal/BlockDeviceTemplateGroup.java | 26 ++ .../softlayer/domain/internal/Datacenter.java | 26 ++ .../domain/internal/NetworkComponent.java | 25 ++ .../domain/internal/NetworkVlan.java | 25 ++ .../PrimaryBackendNetworkComponent.java | 25 ++ .../internal/PrimaryNetworkComponent.java | 25 ++ .../domain/internal/TemplateObject.java | 331 ++++++++++++++++++ .../softlayer/features/VirtualGuestApi.java | 2 +- .../binders/VirtualGuestToJsonTest.java | 43 +-- ...oftLayerComputeServiceAdapterLiveTest.java | 4 +- ...oftLayerComputeServiceContextLiveTest.java | 17 +- .../SoftLayerTemplateBuilderLiveTest.java | 3 +- .../features/VirtualGuestApiExpectTest.java | 4 +- .../parse/CreateVirtualGuestResponseTest.java | 3 +- .../parse/GetVirtualGuestResponseTest.java | 2 +- .../parse/ListVirtualGuestsResponseTest.java | 2 +- .../test/resources/virtual_guest_create.json | 2 +- 29 files changed, 1523 insertions(+), 242 deletions(-) create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/NetworkVlan.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SecuritySshKey.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestAttribute.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDevice.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDeviceTemplateGroup.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/Datacenter.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkComponent.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkVlan.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryBackendNetworkComponent.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryNetworkComponent.java create mode 100644 providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/TemplateObject.java diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java index d1f2c901aa..6e6014120a 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.java @@ -66,7 +66,7 @@ public class SoftLayerProviderMetadata extends BaseProviderMetadata { .apiMetadata(new SoftLayerApiMetadata()) .homepage(URI.create("http://www.softlayer.com")) .console(URI.create("https://manage.softlayer.com")) - .iso3166Codes("SG", "US-CA", "US-TX", "US-VA", "US-WA", "US-TX", "NL", "HK", "NSFTW-IL") // NSFTW-IL is a weird isoCode returned by Softlayer + .iso3166Codes("SG", "US-CA", "US-TX", "US-VA", "US-WA", "NL", "HK", "NSFTW-IL", "AU", "CA-ON", "GB") // NSFTW-IL is a weird isoCode returned by Softlayer .endpoint("https://api.softlayer.com/rest") .defaultProperties(SoftLayerProviderMetadata.defaultProperties()); } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/binders/VirtualGuestToJson.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/binders/VirtualGuestToJson.java index ddb9fdcd87..193183407e 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/binders/VirtualGuestToJson.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/binders/VirtualGuestToJson.java @@ -20,17 +20,29 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; + import org.jclouds.http.HttpRequest; import org.jclouds.json.Json; import org.jclouds.rest.Binder; +import org.jclouds.softlayer.compute.strategy.SoftLayerComputeServiceAdapter; +import org.jclouds.softlayer.domain.SecuritySshKey; import org.jclouds.softlayer.domain.VirtualGuest; import org.jclouds.softlayer.domain.VirtualGuestBlockDevice; -import org.jclouds.softlayer.domain.VirtualGuestNetworkComponent; +import org.jclouds.softlayer.domain.internal.BlockDevice; +import org.jclouds.softlayer.domain.internal.BlockDeviceTemplateGroup; +import org.jclouds.softlayer.domain.internal.Datacenter; +import org.jclouds.softlayer.domain.internal.NetworkComponent; +import org.jclouds.softlayer.domain.internal.NetworkVlan; +import org.jclouds.softlayer.domain.internal.PrimaryBackendNetworkComponent; +import org.jclouds.softlayer.domain.internal.PrimaryNetworkComponent; +import org.jclouds.softlayer.domain.internal.TemplateObject; import javax.inject.Inject; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Map; import java.util.Set; import static com.google.common.base.Preconditions.checkArgument; @@ -43,7 +55,9 @@ import static com.google.common.base.Preconditions.checkNotNull; */ public class VirtualGuestToJson implements Binder { - private final Json json; + public static final String USER_DATA_KEY = "value"; + private static final String SSH_KEY_ID = "id"; + protected Json json; @Inject public VirtualGuestToJson(Json json) { @@ -65,28 +79,67 @@ public class VirtualGuestToJson implements Binder { * @return String */ String buildJson(VirtualGuest virtualGuest) { - TemplateObject templateObject = null; + TemplateObject.Builder templateObjectBuilder = TemplateObject.builder(); 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"); + boolean hourlyBillingFlag = virtualGuest.isHourlyBillingFlag(); + boolean localDisk = virtualGuest.isLocalDiskFlag(); + String datacenterName = checkNotNull(virtualGuest.getDatacenter().getName(), "datacenterName"); - Set networkComponents = getNetworkComponents(virtualGuest); + Set networkComponents = createNetworkComponents(virtualGuest); + + templateObjectBuilder.hostname(hostname) + .domain(domain) + .startCpus(startCpus) + .maxMemory(maxMemory) + .hourlyBillingFlag(hourlyBillingFlag) + .localDiskFlag(localDisk) + .dedicatedAccountHostOnlyFlag(virtualGuest.isDedicatedAccountHostOnly()) + .privateNetworkOnlyFlag(virtualGuest.isPrivateNetworkOnly()) + .datacenter(new Datacenter(datacenterName)) + .networkComponents(networkComponents); + 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)); + templateObjectBuilder.operatingSystemReferenceCode(operatingSystemReferenceCode) + .blockDevices(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); + templateObjectBuilder.blockDeviceTemplateGroup(new BlockDeviceTemplateGroup(globalIdentifier)); } - return json.toJson(ImmutableMap.of("parameters", ImmutableList.of(templateObject))); + + if (virtualGuest.getPrimaryNetworkComponent() != null) { + templateObjectBuilder.primaryNetworkComponent(new PrimaryNetworkComponent(new NetworkVlan(virtualGuest + .getPrimaryNetworkComponent().getNetworkVlan().getId()))); + } + + if (virtualGuest.getPrimaryBackendNetworkComponent() != null) { + templateObjectBuilder.primaryBackendNetworkComponent(new PrimaryBackendNetworkComponent(new NetworkVlan(virtualGuest + .getPrimaryBackendNetworkComponent().getNetworkVlan().getId()))); + } + + if (virtualGuest.getPostInstallScriptUri() != null) { + templateObjectBuilder.postInstallScriptUri(virtualGuest.getPostInstallScriptUri()); + } + + if (virtualGuest.getVirtualGuestAttribute() != null) { + templateObjectBuilder.userData(ImmutableSet.>of(ImmutableMap.of(USER_DATA_KEY, + virtualGuest.getVirtualGuestAttribute().getValue()))); + } + + if (virtualGuest.getSshKeys() != null) { + Set> sshKeys = Sets.newHashSet(); + for (SecuritySshKey securitySshKey : virtualGuest.getSshKeys()) { + sshKeys.add(ImmutableMap.of(SSH_KEY_ID, securitySshKey.getId())); + } + templateObjectBuilder.sshKeys(sshKeys); + } + + return json.toJson(ImmutableMap.of("parameters", ImmutableList.of(templateObjectBuilder.build()))); } private List getBlockDevices(VirtualGuest virtualGuest) { @@ -101,104 +154,29 @@ public class VirtualGuestToJson implements Binder { return ImmutableList.copyOf(blockDevices); } - private Set getNetworkComponents(VirtualGuest virtualGuest) { - if (virtualGuest.getVirtualGuestNetworkComponents() == null) { + private Set createNetworkComponents(VirtualGuest virtualGuest) { + if (virtualGuest.getPrimaryNetworkComponent() == null && virtualGuest.getPrimaryBackendNetworkComponent() == null) { return null; } ImmutableSet.Builder networkComponents = ImmutableSet.builder(); - for (VirtualGuestNetworkComponent networkComponent : virtualGuest.getVirtualGuestNetworkComponents()) { - networkComponents.add(new NetworkComponent(networkComponent.getSpeed())); + int maxSpeed = SoftLayerComputeServiceAdapter.DEFAULT_MAX_PORT_SPEED; + + if (virtualGuest.getPrimaryNetworkComponent() != null && virtualGuest.getPrimaryNetworkComponent().getMaxSpeed() > maxSpeed) { + maxSpeed = virtualGuest.getPrimaryNetworkComponent().getMaxSpeed(); } + if (virtualGuest.getPrimaryBackendNetworkComponent() != null && virtualGuest.getPrimaryBackendNetworkComponent().getMaxSpeed() > maxSpeed) { + maxSpeed = virtualGuest.getPrimaryBackendNetworkComponent().getMaxSpeed(); + } + networkComponents.add(new NetworkComponent(maxSpeed)); return networkComponents.build(); } - private static class TemplateObject { - private final String hostname; - private final String domain; - private final int startCpus; - private final int maxMemory; - private final boolean hourlyBillingFlag; - private final BlockDeviceTemplateGroup blockDeviceTemplateGroup; - private final String operatingSystemReferenceCode; - private final boolean localDiskFlag; - private final Datacenter datacenter; - private final Set networkComponents; - private final List blockDevices; + public class BlockDevicesComparator implements Comparator { - private TemplateObject(String hostname, String domain, int startCpus, int maxMemory, boolean hourlyBillingFlag, - String operatingSystemReferenceCode, BlockDeviceTemplateGroup blockDeviceTemplateGroup, - boolean localDiskFlag, Datacenter datacenter, Set networkComponents, - List blockDevices) { - this.hostname = hostname; - this.domain = domain; - this.startCpus = startCpus; - this.maxMemory = maxMemory; - this.hourlyBillingFlag = hourlyBillingFlag; - this.operatingSystemReferenceCode = operatingSystemReferenceCode; - this.blockDeviceTemplateGroup = blockDeviceTemplateGroup; - this.localDiskFlag = localDiskFlag; - this.datacenter = datacenter; - this.networkComponents = networkComponents; - this.blockDevices = blockDevices; + @Override + public int compare(BlockDevice b1, BlockDevice b2) { + return Integer.valueOf(b1.getDevice()).compareTo(Integer.valueOf(b2.getDevice())); } } - private class Datacenter { - private String name; - - private Datacenter(String name) { - this.name = name; - } - } - - private class NetworkComponent { - private int maxSpeed; - - private NetworkComponent(int maxSpeed) { - this.maxSpeed = maxSpeed; - } - } - - private class BlockDevice { - private String device; - private DiskImage diskImage; - - public String getDevice() { - return device; - } - - public DiskImage getDiskImage() { - return diskImage; - } - - private BlockDevice(String device, float diskImageCapacity) { - this.device = device; - this.diskImage = new DiskImage(diskImageCapacity); - } - } - - private class DiskImage { - private float capacity; - - private DiskImage(float capacity) { - this.capacity = capacity; - } - } - - private class BlockDeviceTemplateGroup { - private String globalIdentifier; - - private BlockDeviceTemplateGroup(String globalIdentifier) { - this.globalIdentifier = globalIdentifier; - } - } - - private class BlockDevicesComparator implements Comparator { - - @Override - public int compare(BlockDevice b1, BlockDevice b2) { - return Integer.valueOf(b1.getDevice()).compareTo(Integer.valueOf(b2.getDevice())); - } - } - } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java index 825a733bfe..e2bf26a3ee 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/config/SoftLayerComputeServiceContextModule.java @@ -46,7 +46,7 @@ import org.jclouds.softlayer.domain.OperatingSystem; import org.jclouds.softlayer.domain.VirtualGuest; import com.google.common.base.Function; -import com.google.common.base.MoreObjects; +import com.google.common.base.Objects; import com.google.common.base.Supplier; import com.google.inject.Provides; import com.google.inject.TypeLiteral; @@ -90,7 +90,7 @@ public class SoftLayerComputeServiceContextModule extends @Override public String toString() { - return MoreObjects.toStringHelper(api) + return Objects.toStringHelper(api) .add("method", "virtualGuestApi.getCreateObjectOptions") .toString(); } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/internal/OperatingSystems.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/internal/OperatingSystems.java index 899a529a2c..577caeeba8 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/internal/OperatingSystems.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/internal/OperatingSystems.java @@ -84,6 +84,8 @@ public class OperatingSystems { } } else if (version.contains(" ")) { return version.substring(0, version.indexOf(" ")); + } else if (version.matches("^(\\d+\\.)?(\\d+\\.)?(\\*|\\d+)$")) { + return version; } return null; } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java index 6e0a85a6ae..1c04f40524 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java @@ -53,6 +53,14 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab protected Optional> blockDevices = Optional.absent(); protected Optional diskType = Optional.absent(); protected Optional portSpeed = Optional.absent(); + protected Optional userData = Optional.absent(); + protected Optional primaryNetworkComponentNetworkVlanId = Optional.absent(); + protected Optional primaryBackendNetworkComponentNetworkVlanId = Optional.absent(); + protected Optional hourlyBillingFlag = Optional.absent(); + protected Optional dedicatedAccountHostOnlyFlag = Optional.absent(); + protected Optional privateNetworkOnlyFlag = Optional.absent(); + protected Optional postInstallScriptUri = Optional.absent(); + protected Optional> sshKeys = Optional.absent(); @Override public SoftLayerTemplateOptions clone() { @@ -76,6 +84,27 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab if (portSpeed.isPresent()) { eTo.portSpeed(portSpeed.get()); } + if (userData.isPresent()) { + eTo.userData(userData.get()); + } + if (primaryNetworkComponentNetworkVlanId.isPresent()) { + eTo.primaryNetworkComponentNetworkVlanId(primaryNetworkComponentNetworkVlanId.get()); + } + if (primaryBackendNetworkComponentNetworkVlanId.isPresent()) { + eTo.primaryBackendNetworkComponentNetworkVlanId(primaryBackendNetworkComponentNetworkVlanId.get()); + } + if (hourlyBillingFlag.isPresent()) { + eTo.hourlyBillingFlag(hourlyBillingFlag.get()); + } + if (dedicatedAccountHostOnlyFlag.isPresent()) { + eTo.dedicatedAccountHostOnlyFlag(dedicatedAccountHostOnlyFlag.get()); + } + if (privateNetworkOnlyFlag.isPresent()) { + eTo.privateNetworkOnlyFlag(privateNetworkOnlyFlag.get()); + } + if (sshKeys.isPresent()) { + eTo.sshKeys(sshKeys.get()); + } } } @@ -117,6 +146,59 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab return this; } + public TemplateOptions userData(String userData) { + checkNotNull(userData, "userData was null"); + this.userData = Optional.of(userData); + return this; + } + + public TemplateOptions primaryNetworkComponentNetworkVlanId(Integer primaryNetworkComponentNetworkVlanId) { + checkNotNull(primaryNetworkComponentNetworkVlanId, "primaryNetworkComponentNetworkVlanId was null"); + this.primaryNetworkComponentNetworkVlanId = Optional.of(primaryNetworkComponentNetworkVlanId); + return this; + } + + public TemplateOptions primaryBackendNetworkComponentNetworkVlanId(Integer primaryBackendNetworkComponentNetworkVlanId) { + checkNotNull(primaryBackendNetworkComponentNetworkVlanId, "primaryBackendNetworkComponentNetworkVlanId was null"); + this.primaryBackendNetworkComponentNetworkVlanId = Optional.of(primaryBackendNetworkComponentNetworkVlanId); + return this; + } + + public TemplateOptions hourlyBillingFlag(boolean hourlyBillingFlag) { + checkNotNull(hourlyBillingFlag, "hourlyBillingFlag was null"); + this.hourlyBillingFlag = Optional.of(hourlyBillingFlag); + return this; + } + + public TemplateOptions dedicatedAccountHostOnlyFlag(boolean dedicatedAccountHostOnlyFlag) { + checkNotNull(dedicatedAccountHostOnlyFlag, "dedicatedAccountHostOnlyFlag was null"); + this.dedicatedAccountHostOnlyFlag = Optional.of(dedicatedAccountHostOnlyFlag); + return this; + } + + public TemplateOptions privateNetworkOnlyFlag(boolean privateNetworkOnlyFlag) { + checkNotNull(privateNetworkOnlyFlag, "privateNetworkOnlyFlag was null"); + this.privateNetworkOnlyFlag = Optional.of(privateNetworkOnlyFlag); + return this; + } + + public TemplateOptions postInstallScriptUri(String postInstallScriptUri) { + checkNotNull(postInstallScriptUri, "postInstallScriptUri was null"); + this.postInstallScriptUri = Optional.of(postInstallScriptUri); + return this; + } + + public TemplateOptions sshKeys(Iterable sshKeys) { + for (Integer sshKey : checkNotNull(sshKeys, "sshKeys")) + checkNotNull(sshKey, "sshKeys must be non-empty"); + this.sshKeys = Optional.> of(ImmutableList.copyOf(sshKeys)); + return this; + } + + public TemplateOptions sshKeys(Integer... sshKeys) { + return sshKeys(ImmutableList.copyOf(checkNotNull(sshKeys, "sshKeys"))); + } + public String getDomainName() { return domainName; } @@ -133,6 +215,24 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab return portSpeed; } + public Optional getUserData() { return userData; } + + public Optional getPrimaryNetworkComponentNetworkVlanId() { return primaryNetworkComponentNetworkVlanId; } + + public Optional getPrimaryBackendNetworkComponentNetworkVlanId() { return primaryBackendNetworkComponentNetworkVlanId; } + + public Optional isHourlyBillingFlag() { return hourlyBillingFlag; } + + public Optional isDedicatedAccountHostOnlyFlag() { return dedicatedAccountHostOnlyFlag; } + + public Optional isPrivateNetworkOnlyFlag() { return privateNetworkOnlyFlag; } + + public Optional getPostInstallScriptUri() { return postInstallScriptUri; } + + public Optional> getSshKeys() { + return sshKeys; + } + public static final SoftLayerTemplateOptions NONE = new SoftLayerTemplateOptions(); public static class Builder { @@ -174,6 +274,75 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab return SoftLayerTemplateOptions.class.cast(options.portSpeed(portSpeed)); } + /** + * @see #userData + */ + public static SoftLayerTemplateOptions userData(String userData) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.userData(userData)); + } + + /** + * @see #primaryNetworkComponentNetworkVlanId + */ + public static SoftLayerTemplateOptions primaryNetworkComponentNetworkVlanId(Integer primaryNetworkComponentNetworkVlanId) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.primaryNetworkComponentNetworkVlanId(primaryNetworkComponentNetworkVlanId)); + } + + /** + * @see #primaryBackendNetworkComponentNetworkVlanId + */ + public static SoftLayerTemplateOptions primaryBackendNetworkComponentNetworkVlanId(Integer primaryBackendNetworkComponentNetworkVlanId) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.primaryBackendNetworkComponentNetworkVlanId(primaryBackendNetworkComponentNetworkVlanId)); + } + + /** + * @see #hourlyBillingFlag + */ + public static SoftLayerTemplateOptions hourlyBillingFlag(boolean hourlyBillingFlag) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.hourlyBillingFlag(hourlyBillingFlag)); + } + + /** + * @see #dedicatedAccountHostOnlyFlag + */ + public static SoftLayerTemplateOptions dedicatedAccountHostOnlyFlag(boolean dedicatedAccountHostOnlyFlag) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.dedicatedAccountHostOnlyFlag(dedicatedAccountHostOnlyFlag)); + } + + /** + * @see #privateNetworkOnlyFlag + */ + public static SoftLayerTemplateOptions privateNetworkOnlyFlag(boolean privateNetworkOnlyFlag) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.privateNetworkOnlyFlag(privateNetworkOnlyFlag)); + } + + /** + * @see #postInstallScriptUri(String) + */ + public static SoftLayerTemplateOptions postInstallScriptUri(String postInstallScriptUri) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.postInstallScriptUri(postInstallScriptUri)); + } + + /** + * @see #sshKeys(Iterable) + */ + public static SoftLayerTemplateOptions sshKeys(Integer... sshKeys) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.sshKeys(sshKeys)); + } + + public static SoftLayerTemplateOptions sshKeys(Iterable sshKeys) { + SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); + return SoftLayerTemplateOptions.class.cast(options.blockDevices(sshKeys)); + } + // methods that only facilitate returning the correct object type /** diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java index 470c980ce1..2e5f574e0a 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java @@ -57,13 +57,16 @@ import org.jclouds.softlayer.SoftLayerApi; import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions; import org.jclouds.softlayer.domain.ContainerVirtualGuestConfiguration; import org.jclouds.softlayer.domain.Datacenter; +import org.jclouds.softlayer.domain.NetworkVlan; import org.jclouds.softlayer.domain.OperatingSystem; import org.jclouds.softlayer.domain.Password; +import org.jclouds.softlayer.domain.SecuritySshKey; import org.jclouds.softlayer.domain.SoftwareDescription; import org.jclouds.softlayer.domain.SoftwareLicense; import org.jclouds.softlayer.domain.VirtualDiskImage; import org.jclouds.softlayer.domain.VirtualDiskImageSoftware; import org.jclouds.softlayer.domain.VirtualGuest; +import org.jclouds.softlayer.domain.VirtualGuestAttribute; import org.jclouds.softlayer.domain.VirtualGuestBlockDevice; import org.jclouds.softlayer.domain.VirtualGuestBlockDeviceTemplate; import org.jclouds.softlayer.domain.VirtualGuestBlockDeviceTemplateGroup; @@ -91,7 +94,7 @@ public class SoftLayerComputeServiceAdapter implements private static final String BOOTABLE_DEVICE = "0"; public static final String DEFAULT_DISK_TYPE = "LOCAL"; - public static final int DEFAULT_PORT_SPEED = 100; + public static final int DEFAULT_MAX_PORT_SPEED = 100; @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) @@ -126,14 +129,14 @@ public class SoftLayerComputeServiceAdapter implements checkNotNull(template, "template was null"); checkNotNull(template.getOptions(), "template options was null"); checkArgument(template.getOptions().getClass().isAssignableFrom(SoftLayerTemplateOptions.class), - "options class %s should have been assignable from SoftLayerTemplateOptions", template.getOptions() - .getClass()); + "options class %s should have been assignable from SoftLayerTemplateOptions", + template.getOptions().getClass()); SoftLayerTemplateOptions templateOptions = template.getOptions().as(SoftLayerTemplateOptions.class); String domainName = templateOptions.getDomainName(); String diskType = templateOptions.getDiskType().or(DEFAULT_DISK_TYPE); - int portSpeed = templateOptions.getPortSpeed().or(DEFAULT_PORT_SPEED); - + boolean hourlyBillingFlag = templateOptions.isHourlyBillingFlag().or(true); + int maxPortSpeed = templateOptions.getPortSpeed().or(DEFAULT_MAX_PORT_SPEED); final Datacenter datacenter = Datacenter.builder().name(template.getLocation().getId()).build(); final String imageId = template.getImage().getId(); int cores = (int) template.getHardware().getProcessors().get(0).getCores(); @@ -141,11 +144,10 @@ public class SoftLayerComputeServiceAdapter implements VirtualGuest.Builder virtualGuestBuilder = VirtualGuest.builder() .domain(domainName) .hostname(name) + .hourlyBillingFlag(hourlyBillingFlag) .startCpus(cores) .maxMemory(template.getHardware().getRam()) - .datacenter(datacenter) - .networkComponents(VirtualGuestNetworkComponent.builder().speed(portSpeed).build()); - + .datacenter(datacenter); // set operating system or blockDeviceTemplateGroup Optional optionalOperatingSystem = tryExtractOperatingSystemFrom(imageId); if (optionalOperatingSystem.isPresent()) { @@ -162,6 +164,47 @@ public class SoftLayerComputeServiceAdapter implements virtualGuestBuilder.blockDevices(blockDevices); virtualGuestBuilder.localDiskFlag(isLocalDisk(diskType)); } + // set dedicatedAccountHostOnlyFlag + if (templateOptions.isDedicatedAccountHostOnlyFlag().isPresent()) { + virtualGuestBuilder.dedicatedAccountHostOnly(templateOptions.isDedicatedAccountHostOnlyFlag().get()); + } + // set privateNetworkOnlyFlag + if (templateOptions.isPrivateNetworkOnlyFlag().isPresent()) { + virtualGuestBuilder.privateNetworkOnlyFlag(templateOptions.isPrivateNetworkOnlyFlag().get()); + } + // set primaryNetworkComponent.networkVlan.id + if (templateOptions.getPrimaryNetworkComponentNetworkVlanId().isPresent()) { + int primaryNetworkComponentNetworkVlanId = templateOptions.getPrimaryNetworkComponentNetworkVlanId().get(); + virtualGuestBuilder.primaryNetworkComponent( + VirtualGuestNetworkComponent.builder() + .networkVlan(NetworkVlan.builder().id(primaryNetworkComponentNetworkVlanId).build()) + .speed(maxPortSpeed).build()); + } + // set primaryBackendNetworkComponent.networkVlan.id + if (templateOptions.getPrimaryBackendNetworkComponentNetworkVlanId().isPresent()) { + int primaryBackendNetworkComponentNetworkVlanId = templateOptions.getPrimaryBackendNetworkComponentNetworkVlanId().get(); + virtualGuestBuilder.primaryBackendNetworkComponent( + VirtualGuestNetworkComponent.builder() + .networkVlan(NetworkVlan.builder().id(primaryBackendNetworkComponentNetworkVlanId).build()) + .speed(maxPortSpeed).build()); + } + // set postInstallScriptUri + if (templateOptions.getPostInstallScriptUri().isPresent()) { + // Specifies the uri location of the script to be downloaded and run after installation is complete. + virtualGuestBuilder.postInstallScriptUri(templateOptions.getPostInstallScriptUri().get()); + } + // set userData + if (templateOptions.getUserData().isPresent()) { + virtualGuestBuilder.virtualGuestAttribute(VirtualGuestAttribute.builder().value(templateOptions.getUserData().get()).build()); + } + // set sshKeys + if (templateOptions.getSshKeys().isPresent()) { + Set sshKeys = Sets.newHashSet(); + for (int sshKeyId : templateOptions.getSshKeys().get()) { + sshKeys.add(SecuritySshKey.builder().id(sshKeyId).build()); + } + virtualGuestBuilder.sshKeys(sshKeys); + } VirtualGuest virtualGuest = virtualGuestBuilder.build(); logger.debug(">> creating new VirtualGuest(%s)", virtualGuest); @@ -429,13 +472,13 @@ public class SoftLayerComputeServiceAdapter implements public boolean apply(VirtualGuest guest) { checkNotNull(guest, "virtual guest was null"); - VirtualGuest newGuest = client.getVirtualGuestApi().getVirtualGuest(guest.getId()); - boolean hasBackendIp = newGuest.getPrimaryBackendIpAddress() != null; - boolean hasPrimaryIp = newGuest.getPrimaryIpAddress() != null; - boolean hasPasswords = newGuest.getOperatingSystem() != null - && !newGuest.getOperatingSystem().getPasswords().isEmpty(); + 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 hasBackendIp && hasPrimaryIp && hasPasswords; + return virtualGuest.isPrivateNetworkOnly() ? hasBackendIp && hasPasswords : hasBackendIp && hasPrimaryIp && hasPasswords; } } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/NetworkVlan.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/NetworkVlan.java new file mode 100644 index 0000000000..bf9018ec03 --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/NetworkVlan.java @@ -0,0 +1,181 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; + +public class NetworkVlan { + + private final int id; + private final int accountId; + private final String name; + private final int networkVrfId; + private final int primarySubnetId; + private final int vlanNumber; + private final String note; + + @ConstructorProperties({ + "id", "accountId", "name", "networkVrfId", "primarySubnetId", "vlanNumber", "note" + }) + public NetworkVlan(int id, int accountId, @Nullable String name, int networkVrfId, int primarySubnetId, + int vlanNumber, @Nullable String note) { + this.id = id; + this.accountId = accountId; + this.name = name; + this.networkVrfId = networkVrfId; + this.primarySubnetId = primarySubnetId; + this.vlanNumber = vlanNumber; + this.note = note; + } + + public int getId() { + return id; + } + + public int getAccountId() { + return accountId; + } + + public String getName() { + return name; + } + + public int getNetworkVrfId() { + return networkVrfId; + } + + public int getPrimarySubnetId() { + return primarySubnetId; + } + + public int getVlanNumber() { + return vlanNumber; + } + + public String getNote() { + return note; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + NetworkVlan that = (NetworkVlan) o; + + return Objects.equal(this.id, that.id) && + Objects.equal(this.accountId, that.accountId) && + Objects.equal(this.name, that.name) && + Objects.equal(this.networkVrfId, that.networkVrfId) && + Objects.equal(this.primarySubnetId, that.primarySubnetId) && + Objects.equal(this.vlanNumber, that.vlanNumber) && + Objects.equal(this.note, that.note); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, accountId, name, networkVrfId, primarySubnetId, vlanNumber, + note); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("accountId", accountId) + .add("name", name) + .add("networkVrfId", networkVrfId) + .add("primarySubnetId", primarySubnetId) + .add("vlanNumber", vlanNumber) + .add("note", note) + .toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromNetworkVlan(this); + } + + public static class Builder { + + protected int id; + protected int accountId; + protected String name; + protected int networkVrfId; + protected int primarySubnetId; + protected int vlanNumber; + protected String note; + + public Builder id(int id) { + this.id = id; + return this; + } + + public Builder accountId(int accountId) { + this.accountId = accountId; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder networkVrfId(int networkVrfId) { + this.networkVrfId = networkVrfId; + return this; + } + + public Builder primarySubnetId(int primarySubnetId) { + this.primarySubnetId = primarySubnetId; + return this; + } + + public Builder vlanNumber(int vlanNumber) { + this.vlanNumber = vlanNumber; + return this; + } + + public Builder note(String note) { + this.note = note; + return this; + } + + public NetworkVlan build() { + return new NetworkVlan(id, accountId, name, networkVrfId, primarySubnetId, + vlanNumber, note); + } + + public Builder fromNetworkVlan(NetworkVlan in) { + return this + .id(in.getId()) + .accountId(in.getAccountId()) + .name(in.getName()) + .networkVrfId(in.getNetworkVrfId()) + .primarySubnetId(in.getPrimarySubnetId()) + .vlanNumber(in.getVlanNumber()) + .note(in.getNote()); + } + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SecuritySshKey.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SecuritySshKey.java new file mode 100644 index 0000000000..0947975c3c --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SecuritySshKey.java @@ -0,0 +1,200 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain; + +import java.beans.ConstructorProperties; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; + +public class SecuritySshKey { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromSecuritySshKey(this); + } + + public static class Builder { + + protected int id; + protected String key; + protected String label; + protected String fingerprint; + protected String notes; + protected String createDate; + protected String modifyDate; + + /** + * @see SecuritySshKey#getId() + */ + public Builder id(int id) { + this.id = id; + return this; + } + + /** + * @see org.jclouds.softlayer.domain.SecuritySshKey#getKey() + */ + public Builder key(String key) { + this.key = key; + return this; + } + + /** + * @see org.jclouds.softlayer.domain.SecuritySshKey#getLabel() () + */ + public Builder label(String label) { + this.label = label; + return this; + } + + /** + * @see org.jclouds.softlayer.domain.SecuritySshKey#getFingerprint() + */ + public Builder fingerprint(String fingerprint) { + this.fingerprint = fingerprint; + return this; + } + + /** + * @see org.jclouds.softlayer.domain.SecuritySshKey#getNotes() + */ + public Builder notes(String notes) { + this.notes = notes; + return this; + } + + /** + * @see org.jclouds.softlayer.domain.SecuritySshKey#getCreateDate() + */ + public Builder createDate(String createDate) { + this.createDate = createDate; + return this; + } + + /** + * @see org.jclouds.softlayer.domain.SecuritySshKey#getModifyDate() + */ + public Builder modifyDate(String modifyDate) { + this.modifyDate = modifyDate; + return this; + } + + public SecuritySshKey build() { + return new SecuritySshKey(id, key, label, fingerprint, notes, createDate, modifyDate); + } + + public Builder fromSecuritySshKey(SecuritySshKey in) { + return this + .id(in.getId()) + .key(in.getKey()) + .label(in.getLabel()) + .fingerprint(in.getFingerprint()) + .notes(in.getNotes()) + .createDate(in.getCreateDate()) + .modifyDate(in.getModifyDate()); + } + } + + private final int id; + private final String key; + private final String label; + private final String fingerprint; + private final String notes; + private final String createDate; + private final String modifyDate; + + @ConstructorProperties({ + "id", "key", "label", "name", "notes", "createDate", "modifyDate" }) + protected SecuritySshKey(int id, @Nullable String key, @Nullable String label, + @Nullable String fingerprint, @Nullable String notes, @Nullable String createDate, + @Nullable String modifyDate) { + this.id = id; + this.key = key; + this.label = label; + this.fingerprint = fingerprint; + this.notes = notes; + this.createDate = createDate; + this.modifyDate = modifyDate; + } + + public int getId() { + return id; + } + + public String getKey() { + return key; + } + + public String getLabel() { + return label; + } + + public String getFingerprint() { + return fingerprint; + } + + public String getNotes() { + return notes; + } + + public String getCreateDate() { + return createDate; + } + + public String getModifyDate() { + return modifyDate; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SecuritySshKey that = (SecuritySshKey) o; + + return Objects.equal(this.id, that.id) && + Objects.equal(this.key, that.key) && + Objects.equal(this.label, that.label) && + Objects.equal(this.fingerprint, that.fingerprint) && + Objects.equal(this.notes, that.notes) && + Objects.equal(this.createDate, that.createDate) && + Objects.equal(this.modifyDate, that.modifyDate); + } + + @Override + public int hashCode() { + return Objects.hashCode(id, key, label, fingerprint, notes, createDate, modifyDate); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("id", id) + .add("key", key) + .add("label", label) + .add("name", fingerprint) + .add("notes", notes) + .add("createDate", createDate) + .add("modifyDate", modifyDate) + .toString(); + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java index e01b5a3dc5..9b2e59676f 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java @@ -25,7 +25,6 @@ import java.util.Set; import org.jclouds.javax.annotation.Nullable; import com.google.common.base.CaseFormat; -import com.google.common.base.MoreObjects; import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; @@ -103,7 +102,6 @@ public class VirtualGuest { protected int accountId; protected Date createDate; - protected boolean dedicatedAccountHostOnly; protected String domain; protected String fullyQualifiedDomainName; protected String hostname; @@ -115,7 +113,6 @@ public class VirtualGuest { protected Date metricPollDate; protected Date modifyDate; protected String notes; - protected boolean privateNetworkOnly; protected int startCpus; protected int statusId; protected String uuid; @@ -129,10 +126,18 @@ public class VirtualGuest { protected SoftwareLicense softwareLicense; protected int activeTransactionCount; protected List blockDevices; + protected boolean hourlyBillingFlag; protected boolean localDiskFlag; + protected boolean dedicatedAccountHostOnlyFlag; + protected boolean privateNetworkOnlyFlag; protected VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup; protected Set networkComponents; protected Set tagReferences; + protected VirtualGuestNetworkComponent primaryNetworkComponent; + protected VirtualGuestNetworkComponent primaryBackendNetworkComponent; + protected String postInstallScriptUri; + protected VirtualGuestAttribute virtualGuestAttribute; + protected Set sshKeys; /** * @see VirtualGuest#getAccountId() @@ -153,8 +158,8 @@ public class VirtualGuest { /** * @see VirtualGuest#isDedicatedAccountHostOnly() */ - public T dedicatedAccountHostOnly(boolean dedicatedAccountHostOnly) { - this.dedicatedAccountHostOnly = dedicatedAccountHostOnly; + public T dedicatedAccountHostOnly(boolean dedicatedAccountHostOnlyFlag) { + this.dedicatedAccountHostOnlyFlag = dedicatedAccountHostOnlyFlag; return self(); } @@ -246,14 +251,6 @@ public class VirtualGuest { return self(); } - /** - * @see VirtualGuest#isPrivateNetworkOnly() - */ - public T privateNetworkOnly(boolean privateNetworkOnly) { - this.privateNetworkOnly = privateNetworkOnly; - return self(); - } - /** * @see VirtualGuest#getStartCpus() */ @@ -362,21 +359,42 @@ public class VirtualGuest { return blockDevices(ImmutableList.copyOf(checkNotNull(in, "blockDevices"))); } + public T hourlyBillingFlag(boolean hourlyBillingFlag) { + this.hourlyBillingFlag = hourlyBillingFlag; + return self(); + } + public T localDiskFlag(boolean localDiskFlag) { this.localDiskFlag = localDiskFlag; return self(); } + public T dedicatedAccountHostOnlyFlag(boolean dedicatedAccountHostOnlyFlag) { + this.dedicatedAccountHostOnlyFlag = dedicatedAccountHostOnlyFlag; + return self(); + } + + public T privateNetworkOnlyFlag(boolean privateNetworkOnlyFlag) { + this.privateNetworkOnlyFlag = privateNetworkOnlyFlag; + return self(); + } + public T blockDeviceTemplateGroup(VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup) { this.blockDeviceTemplateGroup = blockDeviceTemplateGroup; return self(); } + /** + * @see org.jclouds.softlayer.domain.VirtualGuest#getPrimaryBackendNetworkComponent() () + */ public T networkComponents(Set networkComponents) { this.networkComponents = ImmutableSet.copyOf(checkNotNull(networkComponents, "networkComponents")); return self(); } + /** + * @see org.jclouds.softlayer.domain.VirtualGuest#getPrimaryBackendNetworkComponent() () + */ public T networkComponents(VirtualGuestNetworkComponent... in) { return networkComponents(ImmutableSet.copyOf(checkNotNull(in, "networkComponents"))); } @@ -390,13 +408,53 @@ public class VirtualGuest { return tagReferences(ImmutableSet.copyOf(checkNotNull(in, "tagReferences"))); } + public T primaryNetworkComponent(VirtualGuestNetworkComponent primaryNetworkComponent) { + this.primaryNetworkComponent = primaryNetworkComponent; + return self(); + } + + public T primaryBackendNetworkComponent(VirtualGuestNetworkComponent primaryBackendNetworkComponent) { + this.primaryBackendNetworkComponent = primaryBackendNetworkComponent; + return self(); + } + + /** + * @see org.jclouds.softlayer.domain.VirtualGuest#getPostInstallScriptUri() () + */ + public T postInstallScriptUri(String postInstallScriptUri) { + this.postInstallScriptUri = postInstallScriptUri; + return self(); + } + + /** + * @see org.jclouds.softlayer.domain.VirtualGuest#getVirtualGuestAttribute() () + */ + public T virtualGuestAttribute(VirtualGuestAttribute virtualGuestAttribute) { + this.virtualGuestAttribute = virtualGuestAttribute; + return self(); + } + + /** + * @see org.jclouds.softlayer.domain.VirtualGuest#getSshKeys() () + */ + public T sshKeys(Set sshKeys) { + this.sshKeys = ImmutableSet.copyOf(checkNotNull(sshKeys, "sshKeys")); + return self(); + } + + public T sshKeys(SecuritySshKey... in) { + return sshKeys(ImmutableSet.copyOf(checkNotNull(in, "sshKeys"))); + } + public VirtualGuest build() { - return new VirtualGuest(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, hostname, - id, lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes, privateNetworkOnly, + return new VirtualGuest(accountId, createDate, domain, fullyQualifiedDomainName, hostname, + id, lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes, startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress, new BillingItem(billingItemId), operatingSystem, operatingSystemReferenceCode, datacenter, powerState, softwareLicense, - activeTransactionCount, blockDevices, localDiskFlag, blockDeviceTemplateGroup, networkComponents, - tagReferences ); + activeTransactionCount, blockDevices, hourlyBillingFlag, localDiskFlag, dedicatedAccountHostOnlyFlag, + privateNetworkOnlyFlag, blockDeviceTemplateGroup, networkComponents, tagReferences, + primaryNetworkComponent, primaryBackendNetworkComponent, postInstallScriptUri, virtualGuestAttribute, + sshKeys); } public T fromVirtualGuest(VirtualGuest in) { @@ -415,7 +473,6 @@ public class VirtualGuest { .metricPollDate(in.getMetricPollDate()) .modifyDate(in.getModifyDate()) .notes(in.getNotes()) - .privateNetworkOnly(in.isPrivateNetworkOnly()) .startCpus(in.getStartCpus()) .statusId(in.getStatusId()) .uuid(in.getUuid()) @@ -427,10 +484,16 @@ public class VirtualGuest { .datacenter(in.getDatacenter()) .powerState(in.getPowerState()) .activeTransactionCount(in.getActiveTransactionCount()) + .hourlyBillingFlag(in.isHourlyBillingFlag()) .localDiskFlag(in.isLocalDiskFlag()) + .dedicatedAccountHostOnlyFlag(in.isDedicatedAccountHostOnly()) + .privateNetworkOnlyFlag(in.isPrivateNetworkOnly()) .blockDeviceTemplateGroup(in.getVirtualGuestBlockDeviceTemplateGroup()) .networkComponents(in.getVirtualGuestNetworkComponents()) - .tagReferences(in.getTagReferences()); + .tagReferences(in.getTagReferences()) + .postInstallScriptUri(in.getPostInstallScriptUri()) + .virtualGuestAttribute(in.getVirtualGuestAttribute()) + .sshKeys(in.getSshKeys()); } } @@ -443,7 +506,6 @@ public class VirtualGuest { private final int accountId; private final Date createDate; - private final boolean dedicatedAccountHostOnly; private final String domain; private final String fullyQualifiedDomainName; private final String hostname; @@ -455,7 +517,6 @@ public class VirtualGuest { private final Date metricPollDate; private final Date modifyDate; private final String notes; - private final boolean privateNetworkOnly; private final int startCpus; private final int statusId; private final String uuid; @@ -469,32 +530,45 @@ public class VirtualGuest { private final SoftwareLicense softwareLicense; private final int activeTransactionCount; private final List blockDevices; + private final boolean hourlyBillingFlag; private final boolean localDiskFlag; + private final boolean dedicatedAccountHostOnlyFlag; + private final boolean privateNetworkOnlyFlag; private final VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup; private final Set networkComponents; private final Set tagReferences; + private final VirtualGuestNetworkComponent primaryNetworkComponent; + private final VirtualGuestNetworkComponent primaryBackendNetworkComponent; + private final String postInstallScriptUri; + private final VirtualGuestAttribute virtualGuestAttribute; + private final Set sshKeys; - @ConstructorProperties({ "accountId", "createDate", "dedicatedAccountHostOnlyFlag", "domain", - "fullyQualifiedDomainName", "hostname", "id", "lastVerifiedDate", "maxCpu", "maxCpuUnits", "maxMemory", - "metricPollDate", "modifyDate", "notes", "privateNetworkOnlyFlag", "startCpus", "statusId", "uuid", - "primaryBackendIpAddress", "primaryIpAddress", "billingItem", "operatingSystem", - "operatingSystemReferenceCode", "datacenter", "powerState", "softwareLicense", "activeTransactionCount", - "blockDevices", "localDiskFlag", "blockDeviceTemplateGroup", "networkComponents", "tagReferences" -}) - protected VirtualGuest(int accountId, @Nullable Date createDate, boolean dedicatedAccountHostOnly, @Nullable String domain, + @ConstructorProperties({"accountId", "createDate", "domain", "fullyQualifiedDomainName", "hostname", "id", + "lastVerifiedDate", "maxCpu", "maxCpuUnits", "maxMemory", "metricPollDate", "modifyDate", "notes", + "startCpus", "statusId", "uuid", "primaryBackendIpAddress", "primaryIpAddress", "billingItem", + "operatingSystem", "operatingSystemReferenceCode", "datacenter", "powerState", "softwareLicense", + "activeTransactionCount", "blockDevices", "hourlyBillingFlag", "localDiskFlag", + "dedicatedAccountHostOnlyFlag", "privateNetworkOnlyFlag", "blockDeviceTemplateGroup", "networkComponents", + "tagReferences", "primaryNetworkComponent", "primaryBackendNetworkComponent", "postInstallScriptUri", + "virtualGuestAttribute", "sshKeys"}) + protected VirtualGuest(int accountId, @Nullable Date createDate, @Nullable String domain, @Nullable String fullyQualifiedDomainName, @Nullable String hostname, int id, @Nullable Date lastVerifiedDate, int maxCpu, @Nullable String maxCpuUnits, int maxMemory, @Nullable Date metricPollDate, @Nullable Date modifyDate, - @Nullable String notes, boolean privateNetworkOnly, int startCpus, int statusId, @Nullable String uuid, + @Nullable String notes, int startCpus, int statusId, @Nullable String uuid, @Nullable String primaryBackendIpAddress, @Nullable String primaryIpAddress, @Nullable BillingItem billingItem, @Nullable OperatingSystem operatingSystem, @Nullable String operatingSystemReferenceCode, @Nullable Datacenter datacenter, @Nullable PowerState powerState, @Nullable SoftwareLicense softwareLicense, int activeTransactionCount, @Nullable List blockDevices, - boolean localDiskFlag, @Nullable VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup, + boolean hourlyBillingFlag, boolean localDiskFlag, boolean dedicatedAccountHostOnlyFlag, + boolean privateNetworkOnlyFlag, @Nullable VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup, @Nullable Set networkComponents, - @Nullable Set tagReferences ) { + @Nullable Set tagReferences, + @Nullable VirtualGuestNetworkComponent primaryNetworkComponent, + @Nullable VirtualGuestNetworkComponent primaryBackendNetworkComponent, + @Nullable String postInstallScriptUri, @Nullable VirtualGuestAttribute virtualGuestAttribute, + @Nullable Set sshKeys) { this.accountId = accountId; this.createDate = createDate; - this.dedicatedAccountHostOnly = dedicatedAccountHostOnly; this.domain = domain; this.fullyQualifiedDomainName = fullyQualifiedDomainName; this.hostname = hostname; @@ -506,7 +580,6 @@ public class VirtualGuest { this.metricPollDate = metricPollDate; this.modifyDate = modifyDate; this.notes = notes; - this.privateNetworkOnly = privateNetworkOnly; this.startCpus = startCpus; this.statusId = statusId; this.uuid = uuid; @@ -520,10 +593,18 @@ public class VirtualGuest { this.powerState = powerState; this.softwareLicense = softwareLicense; this.activeTransactionCount = activeTransactionCount; + this.hourlyBillingFlag = hourlyBillingFlag; this.localDiskFlag = localDiskFlag; + this.dedicatedAccountHostOnlyFlag = dedicatedAccountHostOnlyFlag; + this.privateNetworkOnlyFlag = privateNetworkOnlyFlag; this.blockDeviceTemplateGroup = blockDeviceTemplateGroup; this.networkComponents = networkComponents; this.tagReferences = tagReferences; + this.primaryNetworkComponent = primaryNetworkComponent; + this.primaryBackendNetworkComponent = primaryBackendNetworkComponent; + this.postInstallScriptUri = postInstallScriptUri; + this.virtualGuestAttribute = virtualGuestAttribute; + this.sshKeys = sshKeys; } /** @@ -541,14 +622,6 @@ public class VirtualGuest { return this.createDate; } - /** - * @return When true this flag specifies that a compute instance is to run on hosts that only - have guests from the same account. - */ - public boolean isDedicatedAccountHostOnly() { - return this.dedicatedAccountHostOnly; - } - /** * @return A computing instance's domain name */ @@ -635,13 +708,6 @@ public class VirtualGuest { return this.notes; } - /** - * @return Whether the computing instance only has access to the private network. - */ - public boolean isPrivateNetworkOnly() { - return this.privateNetworkOnly; - } - /** * @return The number of CPUs available to a computing instance upon startup. */ @@ -733,10 +799,30 @@ public class VirtualGuest { return blockDevices; } + public boolean isHourlyBillingFlag() { + return this.hourlyBillingFlag; + } + public boolean isLocalDiskFlag() { return localDiskFlag; } + /** + * @return Whether the computing instance only has access to the private network. + */ + public boolean isPrivateNetworkOnly() { + return this.privateNetworkOnlyFlag; + } + + /** + * @return When true this flag specifies that a compute instance is to run on hosts that only + have guests from the same account. + */ + public boolean isDedicatedAccountHostOnly() { + return this.dedicatedAccountHostOnlyFlag; + } + + public VirtualGuestBlockDeviceTemplateGroup getVirtualGuestBlockDeviceTemplateGroup() { return blockDeviceTemplateGroup; } @@ -751,13 +837,35 @@ public class VirtualGuest { return tagReferences; } + public VirtualGuestNetworkComponent getPrimaryNetworkComponent() { + return primaryNetworkComponent; + } + + public VirtualGuestNetworkComponent getPrimaryBackendNetworkComponent() { + return primaryBackendNetworkComponent; + } + + public String getPostInstallScriptUri() { + return postInstallScriptUri; + } + + public VirtualGuestAttribute getVirtualGuestAttribute() { + return virtualGuestAttribute; + } + + public Set getSshKeys() { + return sshKeys; + } + @Override public int hashCode() { - return Objects.hashCode(accountId, createDate, dedicatedAccountHostOnly, domain, fullyQualifiedDomainName, + return Objects.hashCode(accountId, createDate, domain, fullyQualifiedDomainName, hostname, id, lastVerifiedDate, maxCpu, maxCpuUnits, maxMemory, metricPollDate, modifyDate, notes, - privateNetworkOnly, startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress, - billingItemId, operatingSystem, datacenter, powerState, softwareLicense, blockDevices, localDiskFlag, - blockDeviceTemplateGroup, tagReferences); + startCpus, statusId, uuid, primaryBackendIpAddress, primaryIpAddress, + billingItemId, operatingSystem, datacenter, powerState, softwareLicense, blockDevices, + hourlyBillingFlag, localDiskFlag, dedicatedAccountHostOnlyFlag, privateNetworkOnlyFlag, + blockDeviceTemplateGroup, tagReferences, primaryNetworkComponent, primaryBackendNetworkComponent, + postInstallScriptUri, virtualGuestAttribute, sshKeys); } @Override @@ -767,7 +875,6 @@ public class VirtualGuest { VirtualGuest that = VirtualGuest.class.cast(obj); return Objects.equal(this.accountId, that.accountId) && Objects.equal(this.createDate, that.createDate) - && Objects.equal(this.dedicatedAccountHostOnly, that.dedicatedAccountHostOnly) && Objects.equal(this.domain, that.domain) && Objects.equal(this.fullyQualifiedDomainName, that.fullyQualifiedDomainName) && Objects.equal(this.hostname, that.hostname) @@ -779,7 +886,6 @@ public class VirtualGuest { && Objects.equal(this.metricPollDate, that.metricPollDate) && Objects.equal(this.modifyDate, that.modifyDate) && Objects.equal(this.notes, that.notes) - && Objects.equal(this.privateNetworkOnly, that.privateNetworkOnly) && Objects.equal(this.startCpus, that.startCpus) && Objects.equal(this.statusId, that.statusId) && Objects.equal(this.uuid, that.uuid) @@ -792,18 +898,21 @@ public class VirtualGuest { && Objects.equal(this.powerState, that.powerState) && Objects.equal(this.softwareLicense, that.softwareLicense) && Objects.equal(this.blockDevices, that.blockDevices) + && Objects.equal(this.hourlyBillingFlag, that.hourlyBillingFlag) && Objects.equal(this.localDiskFlag, that.localDiskFlag) + && Objects.equal(this.dedicatedAccountHostOnlyFlag, that.dedicatedAccountHostOnlyFlag) + && Objects.equal(this.privateNetworkOnlyFlag, that.privateNetworkOnlyFlag) && Objects.equal(this.blockDeviceTemplateGroup, that.blockDeviceTemplateGroup) && Objects.equal(this.networkComponents, that.networkComponents) - && Objects.equal(this.tagReferences, that.tagReferences); + && Objects.equal(this.tagReferences, that.tagReferences) + && Objects.equal(this.sshKeys, that.sshKeys); } @Override public String toString() { - return MoreObjects.toStringHelper(this) + return Objects.toStringHelper(this) .add("accountId", accountId) .add("createDate", createDate) - .add("dedicatedAccountHostOnly", dedicatedAccountHostOnly) .add("domain", domain) .add("fullyQualifiedDomainName", fullyQualifiedDomainName) .add("hostname", hostname) @@ -815,7 +924,6 @@ public class VirtualGuest { .add("metricPollDate", metricPollDate) .add("modifyDate", modifyDate) .add("notes", notes) - .add("privateNetworkOnly", privateNetworkOnly) .add("startCpus", startCpus) .add("statusId", statusId) .add("uuid", uuid) @@ -829,10 +937,18 @@ public class VirtualGuest { .add("softwareLicense", softwareLicense) .add("activeTransactionCount", activeTransactionCount) .add("blockDevices", blockDevices) + .add("hourlyBillingFlag", hourlyBillingFlag) .add("localDiskFlag", localDiskFlag) + .add("dedicatedAccountHostOnlyFlag", dedicatedAccountHostOnlyFlag) + .add("privateNetworkOnlyFlag", privateNetworkOnlyFlag) .add("blockDeviceTemplateGroup", blockDeviceTemplateGroup) .add("networkComponents", networkComponents) .add("tagReferences", tagReferences) + .add("primaryNetworkComponent", primaryNetworkComponent) + .add("primaryBackendNetworkComponent", primaryBackendNetworkComponent) + .add("postInstallScriptUri", postInstallScriptUri) + .add("virtualGuestAttribute", virtualGuestAttribute) + .add("sshKeys", sshKeys) .toString(); } } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestAttribute.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestAttribute.java new file mode 100644 index 0000000000..374b5ef3ca --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestAttribute.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain; + +import static com.google.common.base.Preconditions.checkNotNull; +import java.beans.ConstructorProperties; + +import com.google.common.base.Objects; + +public class VirtualGuestAttribute { + private final String value; + + @ConstructorProperties({"value"} ) + public VirtualGuestAttribute(String value) { + this.value = checkNotNull(value, "value"); + } + + public String getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + VirtualGuestAttribute that = (VirtualGuestAttribute) o; + + return Objects.equal(this.value, that.value); + } + + @Override + public int hashCode() { + return Objects.hashCode(value); + } + + @Override + public String toString() { + return Objects.toStringHelper(this) + .add("value", value) + .toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromVirtualGuestAttribute(this); + } + + public static class Builder { + private String value; + + /** + * @see VirtualGuestAttribute#getValue() + */ + public Builder value(String value) { + this.value = value; + return this; + } + + public VirtualGuestAttribute build() { + return new VirtualGuestAttribute(value); + } + + public Builder fromVirtualGuestAttribute(VirtualGuestAttribute in) { + return this + .value(in.getValue()); + } + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestNetworkComponent.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestNetworkComponent.java index b36380f4e8..843b044988 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestNetworkComponent.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestNetworkComponent.java @@ -50,6 +50,7 @@ public class VirtualGuestNetworkComponent { protected int port; protected int speed; protected String status; + protected NetworkVlan networkVlan; /** * @see org.jclouds.softlayer.domain.VirtualGuestNetworkComponent#getId() @@ -120,9 +121,14 @@ public class VirtualGuestNetworkComponent { return this; } + public Builder networkVlan(NetworkVlan networkVlan) { + this.networkVlan = networkVlan; + return this; + } + public VirtualGuestNetworkComponent build() { return new VirtualGuestNetworkComponent(id, uuid, guestId, networkId, macAddress, maxSpeed, name, port, - speed, status); + speed, status, networkVlan); } public Builder fromVirtualGuestNetworkComponent(VirtualGuestNetworkComponent in) { @@ -135,7 +141,8 @@ public class VirtualGuestNetworkComponent { .maxSpeed(in.getMaxSpeed()) .port(in.getPort()) .speed(in.getSpeed()) - .status(in.getStatus()); + .status(in.getStatus()) + .networkVlan(in.getNetworkVlan()); } } @@ -149,11 +156,13 @@ public class VirtualGuestNetworkComponent { private final int port; private final int speed; private final String status; + private final NetworkVlan networkVlan; - @ConstructorProperties({ "id", "uuid", "guestId", "networkId", "macAddress", "maxSpeed", "name", "port", "speed", "status" }) + @ConstructorProperties({ "id", "uuid", "guestId", "networkId", "macAddress", "maxSpeed", "name", "port", "speed", + "status", "networkVlan" }) protected VirtualGuestNetworkComponent(int id, String uuid, int guestId, int networkId, @Nullable String macAddress, int maxSpeed, @Nullable String name, int port, int speed, - @Nullable String status) { + @Nullable String status, @Nullable NetworkVlan networkVlan) { this.id = id; this.uuid = uuid; this.guestId = guestId; @@ -164,6 +173,7 @@ public class VirtualGuestNetworkComponent { this.port = port; this.speed = speed; this.status = status; + this.networkVlan = networkVlan; } public int getId() { @@ -206,6 +216,10 @@ public class VirtualGuestNetworkComponent { return status; } + public NetworkVlan getNetworkVlan() { + return networkVlan; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -222,13 +236,14 @@ public class VirtualGuestNetworkComponent { Objects.equal(this.name, that.name) && Objects.equal(this.port, that.port) && Objects.equal(this.speed, that.speed) && - Objects.equal(this.status, that.status); + Objects.equal(this.status, that.status) && + Objects.equal(this.networkVlan, that.networkVlan); } @Override public int hashCode() { return Objects.hashCode(id, uuid, guestId, networkId, macAddress, maxSpeed, - name, port, speed, status); + name, port, speed, status, networkVlan); } @Override @@ -244,6 +259,7 @@ public class VirtualGuestNetworkComponent { .add("port", port) .add("speed", speed) .add("status", status) + .add("networkVlan", networkVlan) .toString(); } } diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDevice.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDevice.java new file mode 100644 index 0000000000..9d1868ff43 --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDevice.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain.internal; + +public class BlockDevice { + private final String device; + private final DiskImage diskImage; + + public String getDevice() { + return device; + } + + public DiskImage getDiskImage() { + return diskImage; + } + + public BlockDevice(String device, float diskImageCapacity) { + this.device = device; + this.diskImage = new DiskImage(diskImageCapacity); + } + + private class DiskImage { + private float capacity; + + public DiskImage(float capacity) { + this.capacity = capacity; + } + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDeviceTemplateGroup.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDeviceTemplateGroup.java new file mode 100644 index 0000000000..a2e428999e --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDeviceTemplateGroup.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain.internal; + +public class BlockDeviceTemplateGroup { + + private final String globalIdentifier; + + public BlockDeviceTemplateGroup(String globalIdentifier) { + this.globalIdentifier = globalIdentifier; + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/Datacenter.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/Datacenter.java new file mode 100644 index 0000000000..bb4b11c89d --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/Datacenter.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain.internal; + +public class Datacenter { + + private final String name; + + public Datacenter(String name) { + this.name = name; + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkComponent.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkComponent.java new file mode 100644 index 0000000000..8f6f122873 --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkComponent.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain.internal; + +public class NetworkComponent { + private final int maxSpeed; + + public NetworkComponent(int maxSpeed) { + this.maxSpeed = maxSpeed; + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkVlan.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkVlan.java new file mode 100644 index 0000000000..31fdd7895e --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkVlan.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain.internal; + +public class NetworkVlan { + private final int id; + + public NetworkVlan(int id) { + this.id = id; + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryBackendNetworkComponent.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryBackendNetworkComponent.java new file mode 100644 index 0000000000..7db997cf09 --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryBackendNetworkComponent.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain.internal; + +public class PrimaryBackendNetworkComponent { + private final NetworkVlan networkVlan; + + public PrimaryBackendNetworkComponent(NetworkVlan networkVlan) { + this.networkVlan = networkVlan; + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryNetworkComponent.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryNetworkComponent.java new file mode 100644 index 0000000000..722eea5adf --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryNetworkComponent.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain.internal; + +public class PrimaryNetworkComponent { + private final NetworkVlan networkVlan; + + public PrimaryNetworkComponent(NetworkVlan networkVlan) { + this.networkVlan = networkVlan; + } +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/TemplateObject.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/TemplateObject.java new file mode 100644 index 0000000000..6322d6083a --- /dev/null +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/TemplateObject.java @@ -0,0 +1,331 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.softlayer.domain.internal; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; + +public class TemplateObject { + private final String hostname; + private final String domain; + private final int startCpus; + private final int maxMemory; + private final boolean hourlyBillingFlag; + private final boolean localDiskFlag; + private final boolean dedicatedAccountHostOnlyFlag; + private final boolean privateNetworkOnlyFlag; + private final BlockDeviceTemplateGroup blockDeviceTemplateGroup; + private final String operatingSystemReferenceCode; + private final Datacenter datacenter; + private final Set networkComponents; + private final List blockDevices; + private final String postInstallScriptUri; + private final PrimaryNetworkComponent primaryNetworkComponent; + private final PrimaryBackendNetworkComponent primaryBackendNetworkComponent; + private final Set> userData; + private final Set> sshKeys; + + private TemplateObject(String hostname, String domain, int startCpus, int maxMemory, boolean hourlyBillingFlag, + boolean localDiskFlag, boolean dedicatedAccountHostOnlyFlag, + boolean privateNetworkOnlyFlag, String operatingSystemReferenceCode, + BlockDeviceTemplateGroup blockDeviceTemplateGroup, Datacenter datacenter, + Set networkComponents, List blockDevices, + String postInstallScriptUri, PrimaryNetworkComponent primaryNetworkComponent, + PrimaryBackendNetworkComponent primaryBackendNetworkComponent, Set> userData, Set> sshKeys) { + this.hostname = hostname; + this.domain = domain; + this.startCpus = startCpus; + this.maxMemory = maxMemory; + this.hourlyBillingFlag = hourlyBillingFlag; + this.localDiskFlag = localDiskFlag; + this.dedicatedAccountHostOnlyFlag = dedicatedAccountHostOnlyFlag; + this.privateNetworkOnlyFlag = privateNetworkOnlyFlag; + this.operatingSystemReferenceCode = operatingSystemReferenceCode; + this.blockDeviceTemplateGroup = blockDeviceTemplateGroup; + this.datacenter = datacenter; + this.networkComponents = networkComponents; + this.blockDevices = blockDevices; + this.postInstallScriptUri = postInstallScriptUri; + this.primaryNetworkComponent = primaryNetworkComponent; + this.primaryBackendNetworkComponent = primaryBackendNetworkComponent; + this.userData = userData; + this.sshKeys = sshKeys; + } + + public String getHostname() { + return hostname; + } + + public String getDomain() { + return domain; + } + + public int getStartCpus() { + return startCpus; + } + + public int getMaxMemory() { + return maxMemory; + } + + public boolean isHourlyBillingFlag() { + return hourlyBillingFlag; + } + + public boolean isLocalDiskFlag() { + return localDiskFlag; + } + + public boolean isDedicatedAccountHostOnlyFlag() { + return dedicatedAccountHostOnlyFlag; + } + + public boolean isPrivateNetworkOnlyFlag() { + return privateNetworkOnlyFlag; + } + + public BlockDeviceTemplateGroup getBlockDeviceTemplateGroup() { + return blockDeviceTemplateGroup; + } + + public String getOperatingSystemReferenceCode() { + return operatingSystemReferenceCode; + } + + public Datacenter getDatacenter() { + return datacenter; + } + + public Set getNetworkComponents() { + return networkComponents; + } + + public List getBlockDevices() { + return blockDevices; + } + + public String getPostInstallScriptUri() { + return postInstallScriptUri; + } + + public PrimaryNetworkComponent getPrimaryNetworkComponent() { + return primaryNetworkComponent; + } + + public Set> getUserData() { + return userData; + } + + public Set> getSshKeys() { + return sshKeys; + } + + public PrimaryBackendNetworkComponent getPrimaryBackendNetworkComponent() { + return primaryBackendNetworkComponent; + } + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromTemplateObject(this); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + TemplateObject that = (TemplateObject) o; + + return Objects.equal(this.hostname, that.hostname) && + Objects.equal(this.domain, that.domain) && + Objects.equal(this.startCpus, that.startCpus) && + Objects.equal(this.maxMemory, that.maxMemory) && + Objects.equal(this.hourlyBillingFlag, that.hourlyBillingFlag) && + Objects.equal(this.localDiskFlag, that.localDiskFlag) && + Objects.equal(this.dedicatedAccountHostOnlyFlag, that.dedicatedAccountHostOnlyFlag) && + Objects.equal(this.privateNetworkOnlyFlag, that.privateNetworkOnlyFlag) && + Objects.equal(this.blockDeviceTemplateGroup, that.blockDeviceTemplateGroup) && + Objects.equal(this.operatingSystemReferenceCode, that.operatingSystemReferenceCode) && + Objects.equal(this.datacenter, that.datacenter) && + Objects.equal(this.networkComponents, that.networkComponents) && + Objects.equal(this.blockDevices, that.blockDevices) && + Objects.equal(this.postInstallScriptUri, that.postInstallScriptUri) && + Objects.equal(this.primaryNetworkComponent, that.primaryNetworkComponent) && + Objects.equal(this.primaryBackendNetworkComponent, that.primaryBackendNetworkComponent) && + Objects.equal(this.userData, that.userData) && + Objects.equal(this.sshKeys, that.sshKeys); + } + + @Override + public int hashCode() { + return Objects.hashCode(hostname, domain, startCpus, maxMemory, hourlyBillingFlag, localDiskFlag, + dedicatedAccountHostOnlyFlag, privateNetworkOnlyFlag, blockDeviceTemplateGroup, operatingSystemReferenceCode, datacenter, + networkComponents, blockDevices, postInstallScriptUri, primaryNetworkComponent, + primaryBackendNetworkComponent, userData, sshKeys); + } + + + public static class Builder { + + protected String hostname; + protected String domain; + protected int startCpus; + protected int maxMemory; + protected boolean hourlyBillingFlag; + protected boolean localDiskFlag; + protected boolean dedicatedAccountHostOnlyFlag; + protected boolean privateNetworkOnlyFlag; + protected String operatingSystemReferenceCode; + protected BlockDeviceTemplateGroup blockDeviceTemplateGroup; + protected Datacenter datacenter; + protected Set networkComponents; + protected List blockDevices; + protected String postInstallScriptUri; + protected PrimaryNetworkComponent primaryNetworkComponent; + protected PrimaryBackendNetworkComponent primaryBackendNetworkComponent; + protected Set> userData; + protected Set> sshKeys; + + public Builder hostname(String hostname) { + this.hostname = hostname; + return this; + } + + public Builder domain(String domain) { + this.domain = domain; + return this; + } + + public Builder startCpus(int startCpus) { + this.startCpus = startCpus; + return this; + } + + public Builder maxMemory(int maxMemory) { + this.maxMemory = maxMemory; + return this; + } + + public Builder hourlyBillingFlag(boolean hourlyBillingFlag) { + this.hourlyBillingFlag = hourlyBillingFlag; + return this; + } + + public Builder localDiskFlag(boolean localDiskFlag) { + this.localDiskFlag = localDiskFlag; + return this; + } + + public Builder dedicatedAccountHostOnlyFlag(boolean dedicatedAccountHostOnlyFlag) { + this.dedicatedAccountHostOnlyFlag = dedicatedAccountHostOnlyFlag; + return this; + } + + public Builder privateNetworkOnlyFlag(boolean privateNetworkOnlyFlag) { + this.privateNetworkOnlyFlag = privateNetworkOnlyFlag; + return this; + } + + public Builder operatingSystemReferenceCode(String operatingSystemReferenceCode) { + this.operatingSystemReferenceCode = operatingSystemReferenceCode; + return this; + } + + public Builder blockDeviceTemplateGroup(BlockDeviceTemplateGroup blockDeviceTemplateGroup) { + this.blockDeviceTemplateGroup = blockDeviceTemplateGroup; + return this; + } + + public Builder datacenter(Datacenter datacenter) { + this.datacenter = datacenter; + return this; + } + + public Builder networkComponents(Set networkComponents) { + this.networkComponents = networkComponents; + return this; + } + + public Builder blockDevices(List blockDevices) { + this.blockDevices = blockDevices; + return this; + } + + public Builder postInstallScriptUri(String postInstallScriptUri) { + this.postInstallScriptUri = postInstallScriptUri; + return this; + } + + public Builder primaryNetworkComponent(PrimaryNetworkComponent primaryNetworkComponent) { + this.primaryNetworkComponent = primaryNetworkComponent; + return this; + } + + public Builder primaryBackendNetworkComponent(PrimaryBackendNetworkComponent primaryBackendNetworkComponent) { + this.primaryBackendNetworkComponent = primaryBackendNetworkComponent; + return this; + } + + public Builder userData(Set> userData) { + this.userData = ImmutableSet.copyOf(userData); + return this; + } + + public Builder sshKeys(Set> sshKeys) { + this.sshKeys = ImmutableSet.copyOf(sshKeys); + return this; + } + + public TemplateObject build() { + return new TemplateObject(hostname, domain, startCpus, maxMemory, hourlyBillingFlag, localDiskFlag, + dedicatedAccountHostOnlyFlag, privateNetworkOnlyFlag, operatingSystemReferenceCode, + blockDeviceTemplateGroup, datacenter, networkComponents, blockDevices, postInstallScriptUri, + primaryNetworkComponent, primaryBackendNetworkComponent, userData, sshKeys); + } + + public Builder fromTemplateObject(TemplateObject in) { + return this + .hostname(in.getHostname()) + .domain(in.getDomain()) + .startCpus(in.getStartCpus()) + .maxMemory(in.getMaxMemory()) + .hourlyBillingFlag(in.isHourlyBillingFlag()) + .localDiskFlag(in.isLocalDiskFlag()) + .dedicatedAccountHostOnlyFlag(in.isDedicatedAccountHostOnlyFlag()) + .privateNetworkOnlyFlag(in.isPrivateNetworkOnlyFlag()) + .operatingSystemReferenceCode(in.getOperatingSystemReferenceCode()) + .blockDeviceTemplateGroup(in.getBlockDeviceTemplateGroup()) + .datacenter(in.getDatacenter()) + .networkComponents(in.getNetworkComponents()) + .blockDevices(in.getBlockDevices()) + .postInstallScriptUri(in.getPostInstallScriptUri()) + .primaryNetworkComponent(in.getPrimaryNetworkComponent()) + .primaryBackendNetworkComponent(in.getPrimaryBackendNetworkComponent()) + .userData(in.getUserData()) + .sshKeys(in.getSshKeys()); + } + + } + +} diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java index 31fefd047d..abc581e942 100644 --- a/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java +++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java @@ -51,7 +51,7 @@ public interface VirtualGuestApi { String GUEST_MASK = "id;hostname;domain;fullyQualifiedDomainName;powerState;maxCpu;maxMemory;" + "statusId;operatingSystem.passwords;primaryBackendIpAddress;primaryIpAddress;activeTransactionCount;" + - "blockDevices.diskImage;datacenter;tagReferences"; + "blockDevices.diskImage;datacenter;tagReferences;privateNetworkOnlyFlag;sshKeys"; /** * Enables the creation of computing instances on an account. diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java index 3adf0dcd79..8a9d8b36dc 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java @@ -60,30 +60,15 @@ public class VirtualGuestToJsonTest { request = binder.bindToRequest(request, virtualGuestWithOS); - assertEquals(request.getPayload().getRawContent(), - "{" + - "\"parameters\":[" + - "{" + - "\"hostname\":\"hostname\"," + - "\"domain\":\"domain\"," + - "\"startCpus\":1," + - "\"maxMemory\":1024," + - "\"hourlyBillingFlag\":true," + - "\"operatingSystemReferenceCode\":\"UBUNTU_12_64\"," + - "\"localDiskFlag\":true," + - "\"datacenter\":{" + - "\"name\":\"datacenterName\"" + - "}" + - "}" + - "]" + - "}"); + assertEquals(request.getPayload().getRawContent(), "{" + + "\"parameters\":[{\"hostname\":\"hostname\",\"domain\":\"domain\",\"startCpus\":1,\"maxMemory\":1024,\"hourlyBillingFlag\":false,\"localDiskFlag\":true,\"dedicatedAccountHostOnlyFlag\":false,\"privateNetworkOnlyFlag\":false,\"operatingSystemReferenceCode\":\"UBUNTU_12_64\",\"datacenter\":{\"name\":\"datacenterName\"}}]}"); } @Test public void testVirtualGuestWithVirtualGuestBlockDeviceTemplateGroup() { HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest").build(); VirtualGuestToJson binder = new VirtualGuestToJson(json); - VirtualGuest virtualGuestWithOS = VirtualGuest.builder() + VirtualGuest virtualGuestWithVirtualGuestBlockDeviceTemplateGroup = VirtualGuest.builder() .hostname("hostname") .domain("domain") .startCpus(1) @@ -97,26 +82,20 @@ public class VirtualGuestToJsonTest { .localDiskFlag(true) .build(); - request = binder.bindToRequest(request, virtualGuestWithOS); + request = binder.bindToRequest(request, virtualGuestWithVirtualGuestBlockDeviceTemplateGroup); - assertEquals(request.getPayload().getRawContent(), - "{" + + assertEquals(request.getPayload().getRawContent(), "{" + "\"parameters\":[{" + "\"hostname\":\"hostname\"," + "\"domain\":\"domain\"," + "\"startCpus\":1," + "\"maxMemory\":1024," + - "\"hourlyBillingFlag\":true," + - "\"blockDeviceTemplateGroup\":{" + - "\"globalIdentifier\":\"ffaafa98-4b4a-4fa7-b9f7-b1bad5ec50f0\"" + - "}," + - "\"localDiskFlag\":true," + - "\"datacenter\":{" + - "\"name\":\"datacenterName\"" + - "}" + - "}" + - "]" + - "}"); + "\"hourlyBillingFlag\":false," + + "\"localDiskFlag\":true," + + "\"dedicatedAccountHostOnlyFlag\":false," + + "\"privateNetworkOnlyFlag\":false," + + "\"blockDeviceTemplateGroup\":{\"globalIdentifier\":\"ffaafa98-4b4a-4fa7-b9f7-b1bad5ec50f0\"}," + + "\"datacenter\":{\"name\":\"datacenterName\"}}]}"); } } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java index 327150c6a8..b758a030ac 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java @@ -33,6 +33,7 @@ import org.jclouds.domain.LoginCredentials; import org.jclouds.softlayer.SoftLayerApi; import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions; import org.jclouds.softlayer.compute.strategy.SoftLayerComputeServiceAdapter; +import org.jclouds.softlayer.domain.Datacenter; import org.jclouds.softlayer.domain.VirtualGuest; import org.jclouds.softlayer.features.BaseSoftLayerApiLiveTest; import org.jclouds.ssh.SshClient; @@ -67,7 +68,8 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerApiLive @Test public void testListLocations() { - assertFalse(Iterables.isEmpty(adapter.listLocations()), "locations must not be empty"); + Iterable locations = adapter.listLocations(); + assertFalse(Iterables.isEmpty(locations), "locations must not be empty"); } @Test diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java index fe36d46f6b..3dd2ad170e 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java @@ -33,10 +33,7 @@ import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.logging.Logger; import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.jclouds.softlayer.SoftLayerApi; import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions; -import org.jclouds.softlayer.domain.VirtualGuest; -import org.jclouds.softlayer.domain.VirtualGuestBlockDevice; import org.jclouds.ssh.SshClient; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.Test; @@ -59,7 +56,6 @@ public class SoftLayerComputeServiceContextLiveTest extends BaseComputeServiceCo public void testLaunchClusterWithMinDisk() throws RunNodesException { int numNodes = 1; final String name = "node"; - ComputeServiceContext context = ContextBuilder.newBuilder("softlayer").credentials(identity, credential) .modules(ImmutableSet.of(new SLF4JLoggingModule(), new SshjSshClientModule())) @@ -67,10 +63,7 @@ public class SoftLayerComputeServiceContextLiveTest extends BaseComputeServiceCo TemplateBuilder templateBuilder = context.getComputeService().templateBuilder(); templateBuilder.imageId("CENTOS_6_64"); - //templateBuilder.imageVersionMatches("6.5"); - templateBuilder.locationId("ams01"); - // private image id should be a globalIdentifier of a VirtualGuestBlockDeviceTemplateGroup - //templateBuilder.imageId("3d7697d8-beef-437a-8921-5a2a18bc116f"); + templateBuilder.locationId("dal01"); Template template = templateBuilder.build(); // test passing custom options @@ -81,7 +74,6 @@ public class SoftLayerComputeServiceContextLiveTest extends BaseComputeServiceCo //options.diskType("SAN"); //tags options.tags(ImmutableList.of("jclouds")); - Set nodes = context.getComputeService().createNodesInGroup(name, numNodes, template); assertEquals(numNodes, nodes.size(), "wrong number of nodes"); for (NodeMetadata node : nodes) { @@ -90,13 +82,6 @@ public class SoftLayerComputeServiceContextLiveTest extends BaseComputeServiceCo client.connect(); ExecResponse hello = client.exec("mount"); logger.debug(hello.getOutput().trim()); - - VirtualGuest virtualGuest = context.unwrapApi(SoftLayerApi.class).getVirtualGuestApi() - .getVirtualGuest(Long.parseLong(node.getId())); - for (VirtualGuestBlockDevice blockDevice : virtualGuest.getVirtualGuestBlockDevices()) { - logger.debug(blockDevice.toString()); - } - context.getComputeService().destroyNode(node.getId()); } } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java index 299da8e270..678bae4cfe 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java @@ -18,7 +18,6 @@ package org.jclouds.softlayer.compute; import com.google.common.base.Predicate; import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableSet; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; @@ -163,7 +162,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Override protected Set getIso3166Codes() { - return ImmutableSet. of("SG", "US-CA", "US-TX", "US-VA", "US-WA", "NL", "HK", "NSFTW-IL"); + return createProviderMetadata().getIso3166Codes(); } @BeforeClass(groups = "live") diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java index cfba677d7f..6627acfe37 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java @@ -42,7 +42,7 @@ public class VirtualGuestApiExpectTest extends BaseSoftLayerApiExpectTest { public void testGetVirtualGuestWhenResponseIs2xx() { HttpRequest getVirtualGuest = HttpRequest.builder().method("GET") - .endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/3001812/getObject?objectMask=id%3Bhostname%3Bdomain%3BfullyQualifiedDomainName%3BpowerState%3BmaxCpu%3BmaxMemory%3BstatusId%3BoperatingSystem.passwords%3BprimaryBackendIpAddress%3BprimaryIpAddress%3BactiveTransactionCount%3BblockDevices.diskImage%3Bdatacenter%3BtagReferences") + .endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/3001812/getObject?objectMask=id%3Bhostname%3Bdomain%3BfullyQualifiedDomainName%3BpowerState%3BmaxCpu%3BmaxMemory%3BstatusId%3BoperatingSystem.passwords%3BprimaryBackendIpAddress%3BprimaryIpAddress%3BactiveTransactionCount%3BblockDevices.diskImage%3Bdatacenter%3BtagReferences%3BprivateNetworkOnlyFlag%3BsshKeys") .addHeader("Accept", "application/json") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); @@ -58,7 +58,7 @@ public class VirtualGuestApiExpectTest extends BaseSoftLayerApiExpectTest { public void testGetVirtualGuestWhenResponseIs4xx() { HttpRequest getObjectRequest = HttpRequest.builder().method("GET") - .endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/3001812/getObject?objectMask=id%3Bhostname%3Bdomain%3BfullyQualifiedDomainName%3BpowerState%3BmaxCpu%3BmaxMemory%3BstatusId%3BoperatingSystem.passwords%3BprimaryBackendIpAddress%3BprimaryIpAddress%3BactiveTransactionCount%3BblockDevices.diskImage%3Bdatacenter%3BtagReferences") + .endpoint("https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/3001812/getObject?objectMask=id%3Bhostname%3Bdomain%3BfullyQualifiedDomainName%3BpowerState%3BmaxCpu%3BmaxMemory%3BstatusId%3BoperatingSystem.passwords%3BprimaryBackendIpAddress%3BprimaryIpAddress%3BactiveTransactionCount%3BblockDevices.diskImage%3Bdatacenter%3BtagReferences%3BprivateNetworkOnlyFlag%3BsshKeys") .addHeader("Accept", "application/json") .addHeader("Authorization", "Basic aWRlbnRpdHk6Y3JlZGVudGlhbA==").build(); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/CreateVirtualGuestResponseTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/CreateVirtualGuestResponseTest.java index 8fca9eae5f..90601dc1dd 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/CreateVirtualGuestResponseTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/CreateVirtualGuestResponseTest.java @@ -45,9 +45,8 @@ public class CreateVirtualGuestResponseTest extends BaseSoftLayerParseTest