You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by an...@apache.org on 2014/10/24 19:29:18 UTC
[1/3] git commit: fix support for private images in SoftLayer
Repository: jclouds
Updated Branches:
refs/heads/1.8.x dcfda5217 -> 4c765b188
fix support for private images in SoftLayer
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/3d7362a0
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/3d7362a0
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/3d7362a0
Branch: refs/heads/1.8.x
Commit: 3d7362a0c1427b147932c38d4f8b5d6b6327b4b8
Parents: dcfda52
Author: Andrea Turli <an...@gmail.com>
Authored: Fri Oct 10 10:49:56 2014 +0200
Committer: Andrea Turli <an...@gmail.com>
Committed: Fri Oct 24 19:16:39 2014 +0200
----------------------------------------------------------------------
.../SoftLayerComputeServiceAdapter.java | 258 ++++++++++---------
.../softlayer/domain/SoftwareDescription.java | 2 +-
.../SoftLayerComputeServiceContextLiveTest.java | 7 +-
3 files changed, 143 insertions(+), 124 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/3d7362a0/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java
----------------------------------------------------------------------
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 7ef331b..cc11210 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
@@ -35,7 +35,6 @@ import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLA
import static org.jclouds.util.Predicates2.retry;
import java.util.Comparator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
@@ -73,15 +72,12 @@ import org.jclouds.softlayer.domain.VirtualGuestNetworkComponent;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
import com.google.common.base.Supplier;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.ImmutableSortedSet;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
@@ -151,7 +147,7 @@ public class SoftLayerComputeServiceAdapter implements
.networkComponents(VirtualGuestNetworkComponent.builder().speed(portSpeed).build());
// set operating system or blockDeviceTemplateGroup
- Optional<OperatingSystem> optionalOperatingSystem = tryGetOperatingSystemFrom(imageId);
+ Optional<OperatingSystem> optionalOperatingSystem = tryExtractOperatingSystemFrom(imageId);
if (optionalOperatingSystem.isPresent()) {
virtualGuestBuilder.operatingSystem(optionalOperatingSystem.get());
// the imageId specified is a the id of a public/private/flex image
@@ -191,47 +187,10 @@ public class SoftLayerComputeServiceAdapter implements
}
result = api.getVirtualGuestApi().getVirtualGuest(result.getId());
Password pwd = get(result.getOperatingSystem().getPasswords(), 0);
- return new NodeAndInitialCredentials<VirtualGuest>(result, result.getId() + "",
+ return new NodeAndInitialCredentials(result, result.getId() + "",
LoginCredentials.builder().user(pwd.getUsername()).password(pwd.getPassword()).build());
}
- /**
- * This method will deliberately skip device position 1 as it is reserved to SWAP
- * @param blockDeviceCapacities list of blockDevices to be attached
- * @param diskType disks can be LOCAL or SAN
- * @return
- */
- private List<VirtualGuestBlockDevice> getBlockDevices(List<Integer> blockDeviceCapacities, String diskType) {
- List<VirtualGuestBlockDevice> blockDevices = Lists.newArrayList();
- int devicePosition = 0;
- for (int i = 0; i < blockDeviceCapacities.size(); i++) {
- if (i > 0) { devicePosition = i + 1; }
- blockDevices.add(VirtualGuestBlockDevice.builder()
- .device(devicePosition + "")
- .diskImage(VirtualDiskImage.builder()
- .capacity(blockDeviceCapacities.get(i))
- .typeId(Type.valueOf(diskType).ordinal())
- .build())
- .build());
- }
- return blockDevices;
- }
-
- private Optional<OperatingSystem> tryGetOperatingSystemFrom(final String imageId) {
- Set<OperatingSystem> operatingSystemsAvailable = createObjectOptionsSupplier.get().getVirtualGuestOperatingSystems();
- return tryFind(FluentIterable.from(operatingSystemsAvailable)
- .filter(new Predicate<OperatingSystem>() {
- @Override
- public boolean apply(OperatingSystem input) {
- return input.getId().contains(imageId);
- }
- }), Predicates.notNull());
- }
-
- private boolean isLocalDisk(String diskType) {
- return diskType.equalsIgnoreCase(Type.LOCAL.name());
- }
-
@Override
public Iterable<Hardware> listHardwareProfiles() {
ContainerVirtualGuestConfiguration virtualGuestConfiguration = createObjectOptionsSupplier.get();
@@ -279,90 +238,39 @@ public class SoftLayerComputeServiceAdapter implements
return hardware.build();
}
- private int getBootableDeviceType(Hardware hardware) {
- List<? extends Volume> volumes = hardware.getVolumes();
- Optional<? extends Volume> optionalBootableVolume = tryFind(volumes, new Predicate<Volume>() {
- @Override
- public boolean apply(Volume volume) {
- return volume.getDevice().equals(BOOTABLE_DEVICE);
- }
- });
- if (!optionalBootableVolume.isPresent()) {
- return Type.LOCAL.ordinal();
- }
- return optionalBootableVolume.get().getType().ordinal();
- }
-
@Override
public Set<OperatingSystem> listImages() {
Set<OperatingSystem> result = Sets.newHashSet();
- Set<SoftwareDescription> unfiltered = api.getSoftwareDescriptionApi().getAllObjects();
- Set<OperatingSystem> operatingSystemsAvailable = createObjectOptionsSupplier.get()
- .getVirtualGuestOperatingSystems();
- for (OperatingSystem os : operatingSystemsAvailable) {
- final String osReferenceCode = os.getOperatingSystemReferenceCode();
- final String osId = os.getId();
- result.addAll(FluentIterable.from(unfiltered)
- .filter(new Predicate<SoftwareDescription>() {
- @Override
- public boolean apply(SoftwareDescription input) {
- return isOperatingSystem(input) && input.getReferenceCode().equals(osReferenceCode);
- }
- })
- .transform(new SoftwareDescriptionToOperatingSystem(osId, osReferenceCode))
- .toSet()
- );
- }
+ Set<SoftwareDescription> allObjects = api.getSoftwareDescriptionApi().getAllObjects();
- // list private images and transform them to OperatingSystem
+ // add private images
Set<VirtualGuestBlockDeviceTemplateGroup> privateImages = api.getAccountApi().getBlockDeviceTemplateGroups();
- Map<String, SoftwareDescription> privateImagesSoftwareDescriptions = extractSoftwareDescriptions(privateImages);
- for (Map.Entry<String, SoftwareDescription> entry : privateImagesSoftwareDescriptions.entrySet()) {
- OperatingSystem os = getOperatingSystem(entry);
- if (os != null) {
- result.add(os);
+ for (VirtualGuestBlockDeviceTemplateGroup privateImage : privateImages) {
+ Optional<OperatingSystem> operatingSystemOptional = tryExtractOperatingSystemFrom(privateImage);
+ if (operatingSystemOptional.isPresent()) {
+ result.add(operatingSystemOptional.get());
}
}
- // list public images and transform them to OperatingSystem
+
if (includePublicImages) {
Set<VirtualGuestBlockDeviceTemplateGroup> publicImages = api.getVirtualGuestBlockDeviceTemplateGroupApi().getPublicImages();
- Map<String, SoftwareDescription> publicImagesSoftwareDescriptions = extractSoftwareDescriptions(publicImages);
- for (Map.Entry<String, SoftwareDescription> entry : publicImagesSoftwareDescriptions.entrySet()) {
- OperatingSystem os = getOperatingSystem(entry);
- if (os != null) {
- result.add(os);
+ for (VirtualGuestBlockDeviceTemplateGroup publicImage : publicImages) {
+ Optional<OperatingSystem> operatingSystemOptional = tryExtractOperatingSystemFrom(publicImage);
+ if (operatingSystemOptional.isPresent()) {
+ result.add(operatingSystemOptional.get());
}
}
}
- return result;
- }
- private OperatingSystem getOperatingSystem(Map.Entry<String, SoftwareDescription> entry) {
- SoftwareDescription softwareDescription = entry.getValue();
- if (isOperatingSystem(softwareDescription)) {
- String uuid = entry.getKey();
- return OperatingSystem.builder()
- .id(uuid)
- .softwareLicense(SoftwareLicense.builder().softwareDescription(softwareDescription).build())
- .operatingSystemReferenceCode(softwareDescription.getReferenceCode())
- .build();
+ // add allObjects filtered by the available OS
+ for (OperatingSystem os : createObjectOptionsSupplier.get().getVirtualGuestOperatingSystems()) {
+ result.addAll(FluentIterable.from(allObjects)
+ .filter(new IsOperatingSystem())
+ .filter(new HasSameOsReferenceCode(os.getOperatingSystemReferenceCode()))
+ .transform(new SoftwareDescriptionToOperatingSystem(os.getId()))
+ .toSet());
}
- return null;
- }
-
- private Map<String, SoftwareDescription> extractSoftwareDescriptions(Set<VirtualGuestBlockDeviceTemplateGroup> images) {
- Map<String, SoftwareDescription> softwareDescriptions = Maps.newHashMap();
- for (VirtualGuestBlockDeviceTemplateGroup image : images) {
- final String globalIdentifier = image.getGlobalIdentifier();
- for (VirtualGuestBlockDeviceTemplateGroup child : image.getChildren()) {
- for (VirtualGuestBlockDeviceTemplate blockDeviceTemplate : child.getBlockDevices()) {
- for (VirtualDiskImageSoftware softwareReference : blockDeviceTemplate.getDiskImage().getSoftwareReferences()) {
- softwareDescriptions.put(globalIdentifier, softwareReference.getSoftwareDescription());
- }
- }
- }
- }
- return softwareDescriptions;
+ return result;
}
@Override
@@ -445,8 +353,68 @@ public class SoftLayerComputeServiceAdapter implements
api.getVirtualGuestApi().pauseVirtualGuest(Long.parseLong(id));
}
- private boolean isOperatingSystem(SoftwareDescription input) {
- return input.getOperatingSystem() == 1;
+ /**
+ * This method will deliberately skip device position 1 as it is reserved to SWAP
+ * @param blockDeviceCapacities list of blockDevices to be attached
+ * @param diskType disks can be LOCAL or SAN
+ * @return
+ */
+ private static List<VirtualGuestBlockDevice> getBlockDevices(List<Integer> blockDeviceCapacities, String diskType) {
+ ImmutableList.Builder<VirtualGuestBlockDevice> blockDevicesBuilder = ImmutableList.builder();
+ int devicePosition = 0;
+ for (int i = 0; i < blockDeviceCapacities.size(); i++) {
+ if (i > 0) { devicePosition = i + 1; }
+ blockDevicesBuilder.add(VirtualGuestBlockDevice.builder()
+ .device(devicePosition + "")
+ .diskImage(VirtualDiskImage.builder()
+ .capacity(blockDeviceCapacities.get(i))
+ .typeId(Type.valueOf(diskType).ordinal())
+ .build())
+ .build());
+ }
+ return blockDevicesBuilder.build();
+ }
+
+ private static boolean isLocalDisk(String diskType) {
+ return diskType.equalsIgnoreCase(Type.LOCAL.name());
+ }
+
+ private static int getBootableDeviceType(Hardware hardware) {
+ List<? extends Volume> volumes = hardware.getVolumes();
+ Optional<? extends Volume> optionalBootableVolume = tryFind(volumes, new Predicate<Volume>() {
+ @Override
+ public boolean apply(Volume volume) {
+ return volume.getDevice().equals(BOOTABLE_DEVICE);
+ }
+ });
+ if (!optionalBootableVolume.isPresent()) {
+ return Type.LOCAL.ordinal();
+ }
+ return optionalBootableVolume.get().getType().ordinal();
+ }
+
+ private Optional<OperatingSystem> tryExtractOperatingSystemFrom(final String imageId) {
+ Set<OperatingSystem> operatingSystemsAvailable = createObjectOptionsSupplier.get().getVirtualGuestOperatingSystems();
+ return FluentIterable.from(operatingSystemsAvailable)
+ .filter(new Predicate<OperatingSystem>() {
+ @Override
+ public boolean apply(OperatingSystem input) {
+ if (input == null) return false;
+ return input.getId().contains(imageId);
+ }
+ })
+ .first();
+ }
+
+ private Optional<OperatingSystem> tryExtractOperatingSystemFrom(VirtualGuestBlockDeviceTemplateGroup image) {
+ return FluentIterable.from(image.getChildren())
+ .transformAndConcat(new BlockDeviceTemplateGroupToBlockDeviceTemplateIterable())
+ .filter(new IsBootableDevice())
+ .transformAndConcat(new BlockDeviceTemplateToDiskImageSoftware())
+ .transform(new DiskImageSoftwareToSoftwareDescription())
+ .filter(new IsOperatingSystem())
+ .transform(new SoftwareDescriptionToOperatingSystem(image.getGlobalIdentifier()))
+ .first();
}
public static class VirtualGuestHasLoginDetailsPresent implements Predicate<VirtualGuest> {
@@ -473,19 +441,67 @@ public class SoftLayerComputeServiceAdapter implements
private static class SoftwareDescriptionToOperatingSystem implements Function<SoftwareDescription, OperatingSystem> {
private final String osId;
- private final String operatingSystemReferenceCode;
- public SoftwareDescriptionToOperatingSystem(String osId, String operatingSystemReferenceCode) {
+ public SoftwareDescriptionToOperatingSystem(String osId) {
this.osId = osId;
- this.operatingSystemReferenceCode = operatingSystemReferenceCode;
}
@Override
public OperatingSystem apply(SoftwareDescription input) {
return OperatingSystem.builder().id(osId)
- .softwareLicense(SoftwareLicense.builder().softwareDescription(input).build())
- .operatingSystemReferenceCode(operatingSystemReferenceCode)
- .build();
+ .softwareLicense(SoftwareLicense.builder().softwareDescription(input).build())
+ .operatingSystemReferenceCode(input.getReferenceCode())
+ .build();
+ }
+ }
+
+ private static class IsBootableDevice implements Predicate<VirtualGuestBlockDeviceTemplate> {
+ @Override
+ public boolean apply(VirtualGuestBlockDeviceTemplate blockDeviceTemplate) {
+ return blockDeviceTemplate.getDevice().equals(BOOTABLE_DEVICE);
+ }
+ }
+
+ private static class BlockDeviceTemplateGroupToBlockDeviceTemplateIterable implements Function<VirtualGuestBlockDeviceTemplateGroup,
+ Iterable<VirtualGuestBlockDeviceTemplate>> {
+ @Override
+ public Iterable<VirtualGuestBlockDeviceTemplate> apply(VirtualGuestBlockDeviceTemplateGroup input) {
+ return input.getBlockDevices();
+ }
+ }
+
+ private static class BlockDeviceTemplateToDiskImageSoftware implements Function<VirtualGuestBlockDeviceTemplate, Iterable<VirtualDiskImageSoftware>> {
+ @Override
+ public Iterable<VirtualDiskImageSoftware> apply(VirtualGuestBlockDeviceTemplate bootableDevice) {
+ return bootableDevice.getDiskImage().getSoftwareReferences();
+ }
+ }
+
+ private static class DiskImageSoftwareToSoftwareDescription implements Function<VirtualDiskImageSoftware, SoftwareDescription> {
+ @Override
+ public SoftwareDescription apply(VirtualDiskImageSoftware software) {
+ return software.getSoftwareDescription();
+ }
+ }
+
+ private static class HasSameOsReferenceCode implements Predicate<SoftwareDescription> {
+ private final String osReferenceCode;
+
+ public HasSameOsReferenceCode(String osReferenceCode) {
+ this.osReferenceCode = osReferenceCode;
+ }
+
+ @Override
+ public boolean apply(SoftwareDescription input) {
+ return input.getReferenceCode().equals(osReferenceCode);
+ }
+ }
+
+ private class IsOperatingSystem implements Predicate<SoftwareDescription> {
+ @Override
+ public boolean apply(SoftwareDescription softwareDescription) {
+ // operatingSystem is set to '1' if this Software Description describes an Operating System.
+ return softwareDescription.getOperatingSystem() == 1;
}
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/3d7362a0/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SoftwareDescription.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SoftwareDescription.java b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SoftwareDescription.java
index 28827fc..11adef6 100644
--- a/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SoftwareDescription.java
+++ b/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SoftwareDescription.java
@@ -80,7 +80,7 @@ public class SoftwareDescription {
}
/**
- * @see SoftwareDescription#getOperatingSystem()
+ * @see SoftwareDescription#isOperatingSystem()
*/
public Builder operatingSystem(int operatingSystem) {
this.operatingSystem = operatingSystem;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/3d7362a0/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java
----------------------------------------------------------------------
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 854d01a..fe36d46 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
@@ -67,15 +67,18 @@ 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");
Template template = templateBuilder.build();
// test passing custom options
SoftLayerTemplateOptions options = template.getOptions().as(SoftLayerTemplateOptions.class);
options.domainName("live.org");
// multi-disk option
- options.blockDevices(ImmutableList.of(25, 400, 400));
- options.diskType("SAN");
+ //options.blockDevices(ImmutableList.of(25, 400, 400));
+ //options.diskType("SAN");
//tags
options.tags(ImmutableList.of("jclouds"));
[3/3] git commit: add support for
primaryNetworkComponent.networkVlan.id,
primaryBackendNetworkComponent.networkVlan.id, postInstallScriptUri, user-data,
privateNetworkOnly and sshKeys options
Posted by an...@apache.org.
add support for primaryNetworkComponent.networkVlan.id, primaryBackendNetworkComponent.networkVlan.id, postInstallScriptUri, user-data, privateNetworkOnly and sshKeys options
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/4c765b18
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/4c765b18
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/4c765b18
Branch: refs/heads/1.8.x
Commit: 4c765b1884014b1abb65befdd16c780f6032e116
Parents: 3d7362a
Author: Andrea Turli <an...@gmail.com>
Authored: Tue Oct 14 15:21:39 2014 +0200
Committer: Andrea Turli <an...@gmail.com>
Committed: Fri Oct 24 19:17:29 2014 +0200
----------------------------------------------------------------------
.../softlayer/SoftLayerProviderMetadata.java | 2 +-
.../softlayer/binders/VirtualGuestToJson.java | 178 +++++-----
.../functions/internal/OperatingSystems.java | 2 +
.../options/SoftLayerTemplateOptions.java | 169 ++++++++++
.../SoftLayerComputeServiceAdapter.java | 71 +++-
.../jclouds/softlayer/domain/NetworkVlan.java | 181 ++++++++++
.../softlayer/domain/SecuritySshKey.java | 200 +++++++++++
.../jclouds/softlayer/domain/VirtualGuest.java | 233 +++++++++----
.../softlayer/domain/VirtualGuestAttribute.java | 86 +++++
.../domain/VirtualGuestNetworkComponent.java | 28 +-
.../softlayer/domain/internal/BlockDevice.java | 43 +++
.../internal/BlockDeviceTemplateGroup.java | 26 ++
.../softlayer/domain/internal/Datacenter.java | 26 ++
.../domain/internal/NetworkComponent.java | 25 ++
.../softlayer/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 +--
.../SoftLayerComputeServiceAdapterLiveTest.java | 4 +-
.../SoftLayerComputeServiceContextLiveTest.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 +-
28 files changed, 1520 insertions(+), 238 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/SoftLayerProviderMetadata.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 d1f2c90..6e60141 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());
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/binders/VirtualGuestToJson.java
----------------------------------------------------------------------
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 ddb9fdc..1931834 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<NetworkComponent> networkComponents = getNetworkComponents(virtualGuest);
+ Set<NetworkComponent> 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));
+ }
+
+ 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.<Map<String, String>>of(ImmutableMap.of(USER_DATA_KEY,
+ virtualGuest.getVirtualGuestAttribute().getValue())));
}
- return json.toJson(ImmutableMap.of("parameters", ImmutableList.of(templateObject)));
+
+ if (virtualGuest.getSshKeys() != null) {
+ Set<Map<String, Integer>> 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<BlockDevice> getBlockDevices(VirtualGuest virtualGuest) {
@@ -101,104 +154,29 @@ public class VirtualGuestToJson implements Binder {
return ImmutableList.copyOf(blockDevices);
}
- private Set<NetworkComponent> getNetworkComponents(VirtualGuest virtualGuest) {
- if (virtualGuest.getVirtualGuestNetworkComponents() == null) {
+ private Set<NetworkComponent> 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()));
- }
- 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<NetworkComponent> networkComponents;
- private final List<BlockDevice> blockDevices;
-
- private TemplateObject(String hostname, String domain, int startCpus, int maxMemory, boolean hourlyBillingFlag,
- String operatingSystemReferenceCode, BlockDeviceTemplateGroup blockDeviceTemplateGroup,
- boolean localDiskFlag, Datacenter datacenter, Set<NetworkComponent> networkComponents,
- List<BlockDevice> 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;
- }
- }
+ int maxSpeed = SoftLayerComputeServiceAdapter.DEFAULT_MAX_PORT_SPEED;
- private class Datacenter {
- private String name;
-
- private Datacenter(String name) {
- this.name = name;
+ if (virtualGuest.getPrimaryNetworkComponent() != null && virtualGuest.getPrimaryNetworkComponent().getMaxSpeed() > maxSpeed) {
+ maxSpeed = virtualGuest.getPrimaryNetworkComponent().getMaxSpeed();
}
- }
-
- 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;
+ if (virtualGuest.getPrimaryBackendNetworkComponent() != null && virtualGuest.getPrimaryBackendNetworkComponent().getMaxSpeed() > maxSpeed) {
+ maxSpeed = virtualGuest.getPrimaryBackendNetworkComponent().getMaxSpeed();
}
+ networkComponents.add(new NetworkComponent(maxSpeed));
+ return networkComponents.build();
}
- private class BlockDeviceTemplateGroup {
- private String globalIdentifier;
+ public class BlockDevicesComparator implements Comparator<BlockDevice> {
- private BlockDeviceTemplateGroup(String globalIdentifier) {
- this.globalIdentifier = globalIdentifier;
+ @Override
+ public int compare(BlockDevice b1, BlockDevice b2) {
+ return Integer.valueOf(b1.getDevice()).compareTo(Integer.valueOf(b2.getDevice()));
}
}
- private class BlockDevicesComparator implements Comparator<BlockDevice> {
-
- @Override
- public int compare(BlockDevice b1, BlockDevice b2) {
- return Integer.valueOf(b1.getDevice()).compareTo(Integer.valueOf(b2.getDevice()));
- }
- }
-
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/functions/internal/OperatingSystems.java
----------------------------------------------------------------------
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 899a529..577caee 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;
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/options/SoftLayerTemplateOptions.java
----------------------------------------------------------------------
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 6e0a85a..1c04f40 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<List<Integer>> blockDevices = Optional.absent();
protected Optional<String> diskType = Optional.absent();
protected Optional<Integer> portSpeed = Optional.absent();
+ protected Optional<String> userData = Optional.absent();
+ protected Optional<Integer> primaryNetworkComponentNetworkVlanId = Optional.absent();
+ protected Optional<Integer> primaryBackendNetworkComponentNetworkVlanId = Optional.absent();
+ protected Optional<Boolean> hourlyBillingFlag = Optional.absent();
+ protected Optional<Boolean> dedicatedAccountHostOnlyFlag = Optional.absent();
+ protected Optional<Boolean> privateNetworkOnlyFlag = Optional.absent();
+ protected Optional<String> postInstallScriptUri = Optional.absent();
+ protected Optional<List<Integer>> 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<Integer> sshKeys) {
+ for (Integer sshKey : checkNotNull(sshKeys, "sshKeys"))
+ checkNotNull(sshKey, "sshKeys must be non-empty");
+ this.sshKeys = Optional.<List<Integer>> 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<String> getUserData() { return userData; }
+
+ public Optional<Integer> getPrimaryNetworkComponentNetworkVlanId() { return primaryNetworkComponentNetworkVlanId; }
+
+ public Optional<Integer> getPrimaryBackendNetworkComponentNetworkVlanId() { return primaryBackendNetworkComponentNetworkVlanId; }
+
+ public Optional<Boolean> isHourlyBillingFlag() { return hourlyBillingFlag; }
+
+ public Optional<Boolean> isDedicatedAccountHostOnlyFlag() { return dedicatedAccountHostOnlyFlag; }
+
+ public Optional<Boolean> isPrivateNetworkOnlyFlag() { return privateNetworkOnlyFlag; }
+
+ public Optional<String> getPostInstallScriptUri() { return postInstallScriptUri; }
+
+ public Optional<List<Integer>> 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<Integer> sshKeys) {
+ SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
+ return SoftLayerTemplateOptions.class.cast(options.blockDevices(sshKeys));
+ }
+
// methods that only facilitate returning the correct object type
/**
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/compute/strategy/SoftLayerComputeServiceAdapter.java
----------------------------------------------------------------------
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 cc11210..2e5f574 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<OperatingSystem> 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<SecuritySshKey> 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().size() > 0;
+ 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;
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/NetworkVlan.java
----------------------------------------------------------------------
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 0000000..bf9018e
--- /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());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/SecuritySshKey.java
----------------------------------------------------------------------
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 0000000..0947975
--- /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();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuest.java
----------------------------------------------------------------------
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 9d1f248..9b2e596 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
@@ -102,7 +102,6 @@ public class VirtualGuest {
protected int accountId;
protected Date createDate;
- protected boolean dedicatedAccountHostOnly;
protected String domain;
protected String fullyQualifiedDomainName;
protected String hostname;
@@ -114,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;
@@ -128,10 +126,18 @@ public class VirtualGuest {
protected SoftwareLicense softwareLicense;
protected int activeTransactionCount;
protected List<VirtualGuestBlockDevice> blockDevices;
+ protected boolean hourlyBillingFlag;
protected boolean localDiskFlag;
+ protected boolean dedicatedAccountHostOnlyFlag;
+ protected boolean privateNetworkOnlyFlag;
protected VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup;
protected Set<VirtualGuestNetworkComponent> networkComponents;
protected Set<TagReference> tagReferences;
+ protected VirtualGuestNetworkComponent primaryNetworkComponent;
+ protected VirtualGuestNetworkComponent primaryBackendNetworkComponent;
+ protected String postInstallScriptUri;
+ protected VirtualGuestAttribute virtualGuestAttribute;
+ protected Set<SecuritySshKey> sshKeys;
/**
* @see VirtualGuest#getAccountId()
@@ -152,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 +252,6 @@ public class VirtualGuest {
}
/**
- * @see VirtualGuest#isPrivateNetworkOnly()
- */
- public T privateNetworkOnly(boolean privateNetworkOnly) {
- this.privateNetworkOnly = privateNetworkOnly;
- return self();
- }
-
- /**
* @see VirtualGuest#getStartCpus()
*/
public T startCpus(int startCpus) {
@@ -361,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<VirtualGuestNetworkComponent> 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")));
}
@@ -389,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<SecuritySshKey> 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) {
@@ -414,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())
@@ -426,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());
}
}
@@ -442,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;
@@ -454,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;
@@ -468,32 +530,45 @@ public class VirtualGuest {
private final SoftwareLicense softwareLicense;
private final int activeTransactionCount;
private final List<VirtualGuestBlockDevice> blockDevices;
+ private final boolean hourlyBillingFlag;
private final boolean localDiskFlag;
+ private final boolean dedicatedAccountHostOnlyFlag;
+ private final boolean privateNetworkOnlyFlag;
private final VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup;
private final Set<VirtualGuestNetworkComponent> networkComponents;
private final Set<TagReference> tagReferences;
-
- @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,
+ private final VirtualGuestNetworkComponent primaryNetworkComponent;
+ private final VirtualGuestNetworkComponent primaryBackendNetworkComponent;
+ private final String postInstallScriptUri;
+ private final VirtualGuestAttribute virtualGuestAttribute;
+ private final Set<SecuritySshKey> sshKeys;
+
+ @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<VirtualGuestBlockDevice> blockDevices,
- boolean localDiskFlag, @Nullable VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup,
+ boolean hourlyBillingFlag, boolean localDiskFlag, boolean dedicatedAccountHostOnlyFlag,
+ boolean privateNetworkOnlyFlag, @Nullable VirtualGuestBlockDeviceTemplateGroup blockDeviceTemplateGroup,
@Nullable Set<VirtualGuestNetworkComponent> networkComponents,
- @Nullable Set<TagReference> tagReferences ) {
+ @Nullable Set<TagReference> tagReferences,
+ @Nullable VirtualGuestNetworkComponent primaryNetworkComponent,
+ @Nullable VirtualGuestNetworkComponent primaryBackendNetworkComponent,
+ @Nullable String postInstallScriptUri, @Nullable VirtualGuestAttribute virtualGuestAttribute,
+ @Nullable Set<SecuritySshKey> sshKeys) {
this.accountId = accountId;
this.createDate = createDate;
- this.dedicatedAccountHostOnly = dedicatedAccountHostOnly;
this.domain = domain;
this.fullyQualifiedDomainName = fullyQualifiedDomainName;
this.hostname = hostname;
@@ -505,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;
@@ -519,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 +623,6 @@ public class VirtualGuest {
}
/**
- * @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
*/
@Nullable
@@ -635,13 +709,6 @@ public class VirtualGuest {
}
/**
- * @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.
*/
public int getStartCpus() {
@@ -732,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;
}
@@ -750,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<SecuritySshKey> 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
@@ -766,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)
@@ -778,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)
@@ -791,10 +898,14 @@ 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
@@ -802,7 +913,6 @@ public class VirtualGuest {
return Objects.toStringHelper(this)
.add("accountId", accountId)
.add("createDate", createDate)
- .add("dedicatedAccountHostOnly", dedicatedAccountHostOnly)
.add("domain", domain)
.add("fullyQualifiedDomainName", fullyQualifiedDomainName)
.add("hostname", hostname)
@@ -814,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)
@@ -828,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();
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestAttribute.java
----------------------------------------------------------------------
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 0000000..374b5ef
--- /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());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/VirtualGuestNetworkComponent.java
----------------------------------------------------------------------
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 760c70e..82a28e5 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
@@ -49,6 +49,7 @@ public class VirtualGuestNetworkComponent {
protected int port;
protected int speed;
protected String status;
+ protected NetworkVlan networkVlan;
/**
* @see org.jclouds.softlayer.domain.VirtualGuestNetworkComponent#getId()
@@ -119,9 +120,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) {
@@ -134,7 +140,8 @@ public class VirtualGuestNetworkComponent {
.maxSpeed(in.getMaxSpeed())
.port(in.getPort())
.speed(in.getSpeed())
- .status(in.getStatus());
+ .status(in.getStatus())
+ .networkVlan(in.getNetworkVlan());
}
}
@@ -148,11 +155,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;
@@ -163,6 +172,7 @@ public class VirtualGuestNetworkComponent {
this.port = port;
this.speed = speed;
this.status = status;
+ this.networkVlan = networkVlan;
}
public int getId() {
@@ -205,6 +215,10 @@ public class VirtualGuestNetworkComponent {
return status;
}
+ public NetworkVlan getNetworkVlan() {
+ return networkVlan;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -221,13 +235,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
@@ -243,6 +258,7 @@ public class VirtualGuestNetworkComponent {
.add("port", port)
.add("speed", speed)
.add("status", status)
+ .add("networkVlan", networkVlan)
.toString();
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDevice.java
----------------------------------------------------------------------
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 0000000..9d1868f
--- /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;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/BlockDeviceTemplateGroup.java
----------------------------------------------------------------------
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 0000000..a2e4289
--- /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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/Datacenter.java
----------------------------------------------------------------------
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 0000000..bb4b11c
--- /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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkComponent.java
----------------------------------------------------------------------
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 0000000..8f6f122
--- /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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/NetworkVlan.java
----------------------------------------------------------------------
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 0000000..31fdd78
--- /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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryBackendNetworkComponent.java
----------------------------------------------------------------------
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 0000000..7db997c
--- /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;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/PrimaryNetworkComponent.java
----------------------------------------------------------------------
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 0000000..722eea5
--- /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;
+ }
+}
[2/3] add support for primaryNetworkComponent.networkVlan.id,
primaryBackendNetworkComponent.networkVlan.id, postInstallScriptUri, user-data,
privateNetworkOnly and sshKeys options
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/domain/internal/TemplateObject.java
----------------------------------------------------------------------
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 0000000..6322d60
--- /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<NetworkComponent> networkComponents;
+ private final List<BlockDevice> blockDevices;
+ private final String postInstallScriptUri;
+ private final PrimaryNetworkComponent primaryNetworkComponent;
+ private final PrimaryBackendNetworkComponent primaryBackendNetworkComponent;
+ private final Set<Map<String, String>> userData;
+ private final Set<Map<String, Integer>> 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<NetworkComponent> networkComponents, List<BlockDevice> blockDevices,
+ String postInstallScriptUri, PrimaryNetworkComponent primaryNetworkComponent,
+ PrimaryBackendNetworkComponent primaryBackendNetworkComponent, Set<Map<String,
+ String>> userData, Set<Map<String, Integer>> 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<NetworkComponent> getNetworkComponents() {
+ return networkComponents;
+ }
+
+ public List<BlockDevice> getBlockDevices() {
+ return blockDevices;
+ }
+
+ public String getPostInstallScriptUri() {
+ return postInstallScriptUri;
+ }
+
+ public PrimaryNetworkComponent getPrimaryNetworkComponent() {
+ return primaryNetworkComponent;
+ }
+
+ public Set<Map<String, String>> getUserData() {
+ return userData;
+ }
+
+ public Set<Map<String, Integer>> 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<NetworkComponent> networkComponents;
+ protected List<BlockDevice> blockDevices;
+ protected String postInstallScriptUri;
+ protected PrimaryNetworkComponent primaryNetworkComponent;
+ protected PrimaryBackendNetworkComponent primaryBackendNetworkComponent;
+ protected Set<Map<String, String>> userData;
+ protected Set<Map<String, Integer>> 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<NetworkComponent> networkComponents) {
+ this.networkComponents = networkComponents;
+ return this;
+ }
+
+ public Builder blockDevices(List<BlockDevice> 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<Map<String, String>> userData) {
+ this.userData = ImmutableSet.copyOf(userData);
+ return this;
+ }
+
+ public Builder sshKeys(Set<Map<String, Integer>> 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());
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/main/java/org/jclouds/softlayer/features/VirtualGuestApi.java
----------------------------------------------------------------------
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 a4bb5fb..879738a 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 {
public static 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.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/java/org/jclouds/softlayer/binders/VirtualGuestToJsonTest.java
----------------------------------------------------------------------
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 3adf0dc..8a9d8b3 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\"}}]}");
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java
----------------------------------------------------------------------
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 327150c..b758a03 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<Datacenter> locations = adapter.listLocations();
+ assertFalse(Iterables.isEmpty(locations), "locations must not be empty");
}
@Test
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceContextLiveTest.java
----------------------------------------------------------------------
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 fe36d46..3dd2ad1 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<? extends NodeMetadata> 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());
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java
----------------------------------------------------------------------
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 299da8e..678bae4 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<String> getIso3166Codes() {
- return ImmutableSet.<String> of("SG", "US-CA", "US-TX", "US-VA", "US-WA", "NL", "HK", "NSFTW-IL");
+ return createProviderMetadata().getIso3166Codes();
}
@BeforeClass(groups = "live")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestApiExpectTest.java
----------------------------------------------------------------------
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 cfba677..6627acf 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();
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/CreateVirtualGuestResponseTest.java
----------------------------------------------------------------------
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 8fca9ea..90601dc 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<Virtu
.maxCpu(1)
.maxCpuUnits("CORE")
.maxMemory(1024)
- .privateNetworkOnly(false)
+ .privateNetworkOnlyFlag(false)
.startCpus(1)
- .privateNetworkOnly(false)
.statusId(1001)
.billingItemId(0)
.operatingSystem(null)
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/GetVirtualGuestResponseTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/GetVirtualGuestResponseTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/GetVirtualGuestResponseTest.java
index a5ceb4d..97e2e0d 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/GetVirtualGuestResponseTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/GetVirtualGuestResponseTest.java
@@ -49,7 +49,7 @@ public class GetVirtualGuestResponseTest extends BaseSoftLayerParseTest<VirtualG
.maxMemory(1024)
.metricPollDate(null)
.modifyDate(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T14:10:21.552-07:00"))
- .privateNetworkOnly(false)
+ .privateNetworkOnlyFlag(false)
.startCpus(1)
.statusId(1001)
.uuid("92102aff-93c9-05f1-b3f2-50787e865344")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ListVirtualGuestsResponseTest.java
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ListVirtualGuestsResponseTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ListVirtualGuestsResponseTest.java
index 3cea255..74508dc 100644
--- a/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ListVirtualGuestsResponseTest.java
+++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/parse/ListVirtualGuestsResponseTest.java
@@ -54,7 +54,7 @@ public class ListVirtualGuestsResponseTest extends BaseSoftLayerParseTest<Set<Vi
.maxMemory(1024)
.metricPollDate(null)
.modifyDate(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T14:10:21.552-07:00"))
- .privateNetworkOnly(false)
+ .privateNetworkOnlyFlag(false)
.startCpus(1)
.statusId(1001)
.uuid("92102aff-93c9-05f1-b3f2-50787e865344")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4c765b18/providers/softlayer/src/test/resources/virtual_guest_create.json
----------------------------------------------------------------------
diff --git a/providers/softlayer/src/test/resources/virtual_guest_create.json b/providers/softlayer/src/test/resources/virtual_guest_create.json
index 24625db..e406f6d 100644
--- a/providers/softlayer/src/test/resources/virtual_guest_create.json
+++ b/providers/softlayer/src/test/resources/virtual_guest_create.json
@@ -1 +1 @@
-{"parameters":[{"hostname":"host1","domain":"example.com","startCpus":1,"maxMemory":1024,"hourlyBillingFlag":true,"operatingSystemReferenceCode":"UBUNTU_LATEST","localDiskFlag":true,"datacenter":{"name":"test"}}]}
\ No newline at end of file
+{"parameters":[{"hostname":"host1","domain":"example.com","startCpus":1,"maxMemory":1024,"hourlyBillingFlag":false,"localDiskFlag":true,"dedicatedAccountHostOnlyFlag":false,"privateNetworkOnlyFlag":false,"operatingSystemReferenceCode":"UBUNTU_LATEST","datacenter":{"name":"test"}}]}
\ No newline at end of file