mirror of
https://github.com/apache/jclouds.git
synced 2025-02-16 15:08:28 +00:00
add support for primaryNetworkComponent.networkVlan.id, primaryBackendNetworkComponent.networkVlan.id, postInstallScriptUri, user-data, privateNetworkOnly and sshKeys options
This commit is contained in:
parent
3d7362a0c1
commit
4c765b1884
@ -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());
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
return json.toJson(ImmutableMap.of("parameters", ImmutableList.of(templateObject)));
|
||||
|
||||
if (virtualGuest.getPrimaryNetworkComponent() != null) {
|
||||
templateObjectBuilder.primaryNetworkComponent(new PrimaryNetworkComponent(new NetworkVlan(virtualGuest
|
||||
.getPrimaryNetworkComponent().getNetworkVlan().getId())));
|
||||
}
|
||||
|
||||
if (virtualGuest.getPrimaryBackendNetworkComponent() != null) {
|
||||
templateObjectBuilder.primaryBackendNetworkComponent(new PrimaryBackendNetworkComponent(new NetworkVlan(virtualGuest
|
||||
.getPrimaryBackendNetworkComponent().getNetworkVlan().getId())));
|
||||
}
|
||||
|
||||
if (virtualGuest.getPostInstallScriptUri() != null) {
|
||||
templateObjectBuilder.postInstallScriptUri(virtualGuest.getPostInstallScriptUri());
|
||||
}
|
||||
|
||||
if (virtualGuest.getVirtualGuestAttribute() != null) {
|
||||
templateObjectBuilder.userData(ImmutableSet.<Map<String, String>>of(ImmutableMap.of(USER_DATA_KEY,
|
||||
virtualGuest.getVirtualGuestAttribute().getValue())));
|
||||
}
|
||||
|
||||
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()));
|
||||
int maxSpeed = SoftLayerComputeServiceAdapter.DEFAULT_MAX_PORT_SPEED;
|
||||
|
||||
if (virtualGuest.getPrimaryNetworkComponent() != null && virtualGuest.getPrimaryNetworkComponent().getMaxSpeed() > maxSpeed) {
|
||||
maxSpeed = virtualGuest.getPrimaryNetworkComponent().getMaxSpeed();
|
||||
}
|
||||
if (virtualGuest.getPrimaryBackendNetworkComponent() != null && virtualGuest.getPrimaryBackendNetworkComponent().getMaxSpeed() > maxSpeed) {
|
||||
maxSpeed = virtualGuest.getPrimaryBackendNetworkComponent().getMaxSpeed();
|
||||
}
|
||||
networkComponents.add(new NetworkComponent(maxSpeed));
|
||||
return networkComponents.build();
|
||||
}
|
||||
|
||||
private static class TemplateObject {
|
||||
private final String hostname;
|
||||
private final String domain;
|
||||
private final int startCpus;
|
||||
private final int maxMemory;
|
||||
private final boolean hourlyBillingFlag;
|
||||
private final BlockDeviceTemplateGroup blockDeviceTemplateGroup;
|
||||
private final String operatingSystemReferenceCode;
|
||||
private final boolean localDiskFlag;
|
||||
private final Datacenter datacenter;
|
||||
private final Set<NetworkComponent> networkComponents;
|
||||
private final List<BlockDevice> blockDevices;
|
||||
public class BlockDevicesComparator implements Comparator<BlockDevice> {
|
||||
|
||||
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;
|
||||
@Override
|
||||
public int compare(BlockDevice b1, BlockDevice b2) {
|
||||
return Integer.valueOf(b1.getDevice()).compareTo(Integer.valueOf(b2.getDevice()));
|
||||
}
|
||||
}
|
||||
|
||||
private class Datacenter {
|
||||
private String name;
|
||||
|
||||
private Datacenter(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
private class NetworkComponent {
|
||||
private int maxSpeed;
|
||||
|
||||
private NetworkComponent(int maxSpeed) {
|
||||
this.maxSpeed = maxSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
private class BlockDevice {
|
||||
private String device;
|
||||
private DiskImage diskImage;
|
||||
|
||||
public String getDevice() {
|
||||
return device;
|
||||
}
|
||||
|
||||
public DiskImage getDiskImage() {
|
||||
return diskImage;
|
||||
}
|
||||
|
||||
private BlockDevice(String device, float diskImageCapacity) {
|
||||
this.device = device;
|
||||
this.diskImage = new DiskImage(diskImageCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
private class DiskImage {
|
||||
private float capacity;
|
||||
|
||||
private DiskImage(float capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
}
|
||||
|
||||
private class BlockDeviceTemplateGroup {
|
||||
private String globalIdentifier;
|
||||
|
||||
private BlockDeviceTemplateGroup(String globalIdentifier) {
|
||||
this.globalIdentifier = globalIdentifier;
|
||||
}
|
||||
}
|
||||
|
||||
private class BlockDevicesComparator implements Comparator<BlockDevice> {
|
||||
|
||||
@Override
|
||||
public int compare(BlockDevice b1, BlockDevice b2) {
|
||||
return Integer.valueOf(b1.getDevice()).compareTo(Integer.valueOf(b2.getDevice()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
@ -245,14 +251,6 @@ public class VirtualGuest {
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#isPrivateNetworkOnly()
|
||||
*/
|
||||
public T privateNetworkOnly(boolean privateNetworkOnly) {
|
||||
this.privateNetworkOnly = privateNetworkOnly;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualGuest#getStartCpus()
|
||||
*/
|
||||
@ -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;
|
||||
private final VirtualGuestNetworkComponent primaryNetworkComponent;
|
||||
private final VirtualGuestNetworkComponent primaryBackendNetworkComponent;
|
||||
private final String postInstallScriptUri;
|
||||
private final VirtualGuestAttribute virtualGuestAttribute;
|
||||
private final Set<SecuritySshKey> sshKeys;
|
||||
|
||||
@ConstructorProperties({ "accountId", "createDate", "dedicatedAccountHostOnlyFlag", "domain",
|
||||
"fullyQualifiedDomainName", "hostname", "id", "lastVerifiedDate", "maxCpu", "maxCpuUnits", "maxMemory",
|
||||
"metricPollDate", "modifyDate", "notes", "privateNetworkOnlyFlag", "startCpus", "statusId", "uuid",
|
||||
"primaryBackendIpAddress", "primaryIpAddress", "billingItem", "operatingSystem",
|
||||
"operatingSystemReferenceCode", "datacenter", "powerState", "softwareLicense", "activeTransactionCount",
|
||||
"blockDevices", "localDiskFlag", "blockDeviceTemplateGroup", "networkComponents", "tagReferences"
|
||||
})
|
||||
protected VirtualGuest(int accountId, @Nullable Date createDate, boolean dedicatedAccountHostOnly, @Nullable String domain,
|
||||
@ConstructorProperties({"accountId", "createDate", "domain", "fullyQualifiedDomainName", "hostname", "id",
|
||||
"lastVerifiedDate", "maxCpu", "maxCpuUnits", "maxMemory", "metricPollDate", "modifyDate", "notes",
|
||||
"startCpus", "statusId", "uuid", "primaryBackendIpAddress", "primaryIpAddress", "billingItem",
|
||||
"operatingSystem", "operatingSystemReferenceCode", "datacenter", "powerState", "softwareLicense",
|
||||
"activeTransactionCount", "blockDevices", "hourlyBillingFlag", "localDiskFlag",
|
||||
"dedicatedAccountHostOnlyFlag", "privateNetworkOnlyFlag", "blockDeviceTemplateGroup", "networkComponents",
|
||||
"tagReferences", "primaryNetworkComponent", "primaryBackendNetworkComponent", "postInstallScriptUri",
|
||||
"virtualGuestAttribute", "sshKeys"})
|
||||
protected VirtualGuest(int accountId, @Nullable Date createDate, @Nullable String domain,
|
||||
@Nullable String fullyQualifiedDomainName, @Nullable String hostname, int id, @Nullable Date lastVerifiedDate,
|
||||
int maxCpu, @Nullable String maxCpuUnits, int maxMemory, @Nullable Date metricPollDate, @Nullable Date modifyDate,
|
||||
@Nullable String notes, boolean privateNetworkOnly, int startCpus, int statusId, @Nullable String uuid,
|
||||
@Nullable String notes, int startCpus, int statusId, @Nullable String uuid,
|
||||
@Nullable String primaryBackendIpAddress, @Nullable String primaryIpAddress, @Nullable BillingItem billingItem,
|
||||
@Nullable OperatingSystem operatingSystem, @Nullable String operatingSystemReferenceCode,
|
||||
@Nullable Datacenter datacenter, @Nullable PowerState powerState, @Nullable SoftwareLicense softwareLicense,
|
||||
int activeTransactionCount, @Nullable List<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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -540,14 +622,6 @@ public class VirtualGuest {
|
||||
return this.createDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return When true this flag specifies that a compute instance is to run on hosts that only
|
||||
have guests from the same account.
|
||||
*/
|
||||
public boolean isDedicatedAccountHostOnly() {
|
||||
return this.dedicatedAccountHostOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A computing instance's domain name
|
||||
*/
|
||||
@ -634,13 +708,6 @@ public class VirtualGuest {
|
||||
return this.notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the computing instance only has access to the private network.
|
||||
*/
|
||||
public boolean isPrivateNetworkOnly() {
|
||||
return this.privateNetworkOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of CPUs available to a computing instance upon startup.
|
||||
*/
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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.
|
||||
|
@ -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\"}}]}");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
@ -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")
|
||||
|
@ -1 +1 @@
|
||||
{"parameters":[{"hostname":"host1","domain":"example.com","startCpus":1,"maxMemory":1024,"hourlyBillingFlag":true,"operatingSystemReferenceCode":"UBUNTU_LATEST","localDiskFlag":true,"datacenter":{"name":"test"}}]}
|
||||
{"parameters":[{"hostname":"host1","domain":"example.com","startCpus":1,"maxMemory":1024,"hourlyBillingFlag":false,"localDiskFlag":true,"dedicatedAccountHostOnlyFlag":false,"privateNetworkOnlyFlag":false,"operatingSystemReferenceCode":"UBUNTU_LATEST","datacenter":{"name":"test"}}]}
|
Loading…
x
Reference in New Issue
Block a user