[SoftLayer] fix SoftLayerTemplateOptions

This commit is contained in:
Andrea Turli 2015-07-24 16:27:20 +02:00
parent 2c578d7bcb
commit f5e1c47644
5 changed files with 298 additions and 179 deletions

View File

@ -16,19 +16,23 @@
*/ */
package org.jclouds.softlayer.binders; package org.jclouds.softlayer.binders;
import com.google.common.collect.ImmutableList; import static com.google.common.base.Preconditions.checkArgument;
import com.google.common.collect.ImmutableMap; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.collect.ImmutableSet; import java.util.Collections;
import com.google.common.collect.Lists; import java.util.Comparator;
import com.google.common.collect.Sets; import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.json.Json; import org.jclouds.json.Json;
import org.jclouds.rest.Binder; import org.jclouds.rest.Binder;
import org.jclouds.softlayer.compute.strategy.SoftLayerComputeServiceAdapter;
import org.jclouds.softlayer.domain.SecuritySshKey; import org.jclouds.softlayer.domain.SecuritySshKey;
import org.jclouds.softlayer.domain.VirtualGuest; import org.jclouds.softlayer.domain.VirtualGuest;
import org.jclouds.softlayer.domain.VirtualGuestBlockDevice; 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.BlockDevice;
import org.jclouds.softlayer.domain.internal.BlockDeviceTemplateGroup; import org.jclouds.softlayer.domain.internal.BlockDeviceTemplateGroup;
import org.jclouds.softlayer.domain.internal.Datacenter; import org.jclouds.softlayer.domain.internal.Datacenter;
@ -38,15 +42,13 @@ import org.jclouds.softlayer.domain.internal.PrimaryBackendNetworkComponent;
import org.jclouds.softlayer.domain.internal.PrimaryNetworkComponent; import org.jclouds.softlayer.domain.internal.PrimaryNetworkComponent;
import org.jclouds.softlayer.domain.internal.TemplateObject; import org.jclouds.softlayer.domain.internal.TemplateObject;
import javax.inject.Inject; import com.google.common.base.Function;
import java.util.Collections; import com.google.common.collect.FluentIterable;
import java.util.Comparator; import com.google.common.collect.ImmutableList;
import java.util.List; import com.google.common.collect.ImmutableMap;
import java.util.Map; import com.google.common.collect.ImmutableSet;
import java.util.Set; import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Converts a VirtualGuest into a json string valid for creating a CCI via softlayer api * Converts a VirtualGuest into a json string valid for creating a CCI via softlayer api
@ -88,7 +90,17 @@ public class VirtualGuestToJson implements Binder {
boolean localDisk = virtualGuest.isLocalDiskFlag(); boolean localDisk = virtualGuest.isLocalDiskFlag();
String datacenterName = checkNotNull(virtualGuest.getDatacenter().getName(), "datacenterName"); String datacenterName = checkNotNull(virtualGuest.getDatacenter().getName(), "datacenterName");
Set<NetworkComponent> networkComponents = createNetworkComponents(virtualGuest); Set<VirtualGuestNetworkComponent> virtualGuestNetworkComponents = virtualGuest.getVirtualGuestNetworkComponents();
Set<NetworkComponent> networkComponents = Sets.newHashSet();
if (virtualGuestNetworkComponents != null) {
networkComponents = FluentIterable.from(virtualGuestNetworkComponents)
.transform(new Function<VirtualGuestNetworkComponent, NetworkComponent>() {
@Override
public NetworkComponent apply(VirtualGuestNetworkComponent virtualGuestNetworkComponent) {
return new NetworkComponent(virtualGuestNetworkComponent.getSpeed());
}
}).toSet();
}
templateObjectBuilder.hostname(hostname) templateObjectBuilder.hostname(hostname)
.domain(domain) .domain(domain)
@ -98,9 +110,11 @@ public class VirtualGuestToJson implements Binder {
.localDiskFlag(localDisk) .localDiskFlag(localDisk)
.dedicatedAccountHostOnlyFlag(virtualGuest.isDedicatedAccountHostOnly()) .dedicatedAccountHostOnlyFlag(virtualGuest.isDedicatedAccountHostOnly())
.privateNetworkOnlyFlag(virtualGuest.isPrivateNetworkOnly()) .privateNetworkOnlyFlag(virtualGuest.isPrivateNetworkOnly())
.datacenter(new Datacenter(datacenterName)) .datacenter(new Datacenter(datacenterName));
.networkComponents(networkComponents);
if (!networkComponents.isEmpty()) {
templateObjectBuilder.networkComponents(networkComponents);
}
if (virtualGuest.getOperatingSystem() != null) { if (virtualGuest.getOperatingSystem() != null) {
String operatingSystemReferenceCode = checkNotNull(virtualGuest.getOperatingSystem() String operatingSystemReferenceCode = checkNotNull(virtualGuest.getOperatingSystem()
.getOperatingSystemReferenceCode(), "operatingSystemReferenceCode"); .getOperatingSystemReferenceCode(), "operatingSystemReferenceCode");
@ -154,23 +168,6 @@ public class VirtualGuestToJson implements Binder {
return ImmutableList.copyOf(blockDevices); return ImmutableList.copyOf(blockDevices);
} }
private Set<NetworkComponent> createNetworkComponents(VirtualGuest virtualGuest) {
if (virtualGuest.getPrimaryNetworkComponent() == null && virtualGuest.getPrimaryBackendNetworkComponent() == null) {
return null;
}
ImmutableSet.Builder networkComponents = ImmutableSet.builder();
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();
}
public class BlockDevicesComparator implements Comparator<BlockDevice> { public class BlockDevicesComparator implements Comparator<BlockDevice> {
@Override @Override

View File

@ -22,8 +22,10 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.jclouds.compute.options.TemplateOptions; import org.jclouds.compute.options.TemplateOptions;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.scriptbuilder.domain.Statement;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.net.InternetDomainName; import com.google.common.net.InternetDomainName;
@ -50,17 +52,17 @@ import com.google.common.net.InternetDomainName;
public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneable { public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneable {
protected String domainName = "jclouds.org"; protected String domainName = "jclouds.org";
protected Optional<List<Integer>> blockDevices = Optional.absent(); protected List<Integer> blockDevices = ImmutableList.of();
protected Optional<String> diskType = Optional.absent(); protected String diskType;
protected Optional<Integer> portSpeed = Optional.absent(); protected Integer portSpeed;
protected Optional<String> userData = Optional.absent(); protected String userData;
protected Optional<Integer> primaryNetworkComponentNetworkVlanId = Optional.absent(); protected Integer primaryNetworkComponentNetworkVlanId;
protected Optional<Integer> primaryBackendNetworkComponentNetworkVlanId = Optional.absent(); protected Integer primaryBackendNetworkComponentNetworkVlanId;
protected Optional<Boolean> hourlyBillingFlag = Optional.absent(); protected Boolean hourlyBillingFlag;
protected Optional<Boolean> dedicatedAccountHostOnlyFlag = Optional.absent(); protected Boolean dedicatedAccountHostOnlyFlag;
protected Optional<Boolean> privateNetworkOnlyFlag = Optional.absent(); protected Boolean privateNetworkOnlyFlag;
protected Optional<String> postInstallScriptUri = Optional.absent(); protected String postInstallScriptUri;
protected Optional<List<Integer>> sshKeys = Optional.absent(); protected List<Integer> sshKeys = ImmutableList.of();
@Override @Override
public SoftLayerTemplateOptions clone() { public SoftLayerTemplateOptions clone() {
@ -75,35 +77,19 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
if (to instanceof SoftLayerTemplateOptions) { if (to instanceof SoftLayerTemplateOptions) {
SoftLayerTemplateOptions eTo = SoftLayerTemplateOptions.class.cast(to); SoftLayerTemplateOptions eTo = SoftLayerTemplateOptions.class.cast(to);
eTo.domainName(domainName); eTo.domainName(domainName);
if (blockDevices.isPresent()) { if (!blockDevices.isEmpty()) {
eTo.blockDevices(blockDevices.get()); eTo.blockDevices(blockDevices);
} }
if (diskType.isPresent()) { eTo.diskType(diskType);
eTo.diskType(diskType.get()); eTo.portSpeed(portSpeed);
} eTo.userData(userData);
if (portSpeed.isPresent()) { eTo.primaryNetworkComponentNetworkVlanId(primaryNetworkComponentNetworkVlanId);
eTo.portSpeed(portSpeed.get()); eTo.primaryBackendNetworkComponentNetworkVlanId(primaryBackendNetworkComponentNetworkVlanId);
} eTo.hourlyBillingFlag(hourlyBillingFlag);
if (userData.isPresent()) { eTo.dedicatedAccountHostOnlyFlag(dedicatedAccountHostOnlyFlag);
eTo.userData(userData.get()); eTo.privateNetworkOnlyFlag(privateNetworkOnlyFlag);
} if (!sshKeys.isEmpty()) {
if (primaryNetworkComponentNetworkVlanId.isPresent()) { eTo.sshKeys(sshKeys);
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());
} }
} }
} }
@ -126,7 +112,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
public SoftLayerTemplateOptions blockDevices(Iterable<Integer> capacities) { public SoftLayerTemplateOptions blockDevices(Iterable<Integer> capacities) {
for (Integer capacity : checkNotNull(capacities, "capacities")) for (Integer capacity : checkNotNull(capacities, "capacities"))
checkNotNull(capacity, "all block devices must be non-empty"); checkNotNull(capacity, "all block devices must be non-empty");
this.blockDevices = Optional.<List<Integer>> of(ImmutableList.copyOf(capacities)); this.blockDevices = ImmutableList.copyOf(capacities);
return this; return this;
} }
@ -134,61 +120,55 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
return blockDevices(ImmutableList.copyOf(checkNotNull(capacities, "capacities"))); return blockDevices(ImmutableList.copyOf(checkNotNull(capacities, "capacities")));
} }
public SoftLayerTemplateOptions diskType(String diskType) { public SoftLayerTemplateOptions diskType(@Nullable String diskType) {
checkNotNull(diskType, "diskType was null"); this.diskType = diskType;
this.diskType = Optional.of(diskType);
return this; return this;
} }
public SoftLayerTemplateOptions portSpeed(Integer portSpeed) { public SoftLayerTemplateOptions portSpeed(@Nullable Integer portSpeed) {
checkNotNull(portSpeed, "portSpeed was null"); this.portSpeed = portSpeed;
this.portSpeed = Optional.of(portSpeed);
return this; return this;
} }
public SoftLayerTemplateOptions userData(String userData) { public SoftLayerTemplateOptions userData(@Nullable String userData) {
checkNotNull(userData, "userData was null"); this.userData = userData;
this.userData = Optional.of(userData);
return this; return this;
} }
public SoftLayerTemplateOptions primaryNetworkComponentNetworkVlanId(Integer primaryNetworkComponentNetworkVlanId) { public SoftLayerTemplateOptions primaryNetworkComponentNetworkVlanId(@Nullable Integer primaryNetworkComponentNetworkVlanId) {
checkNotNull(primaryNetworkComponentNetworkVlanId, "primaryNetworkComponentNetworkVlanId was null"); this.primaryNetworkComponentNetworkVlanId = primaryNetworkComponentNetworkVlanId;
this.primaryNetworkComponentNetworkVlanId = Optional.of(primaryNetworkComponentNetworkVlanId);
return this; return this;
} }
public SoftLayerTemplateOptions primaryBackendNetworkComponentNetworkVlanId(Integer primaryBackendNetworkComponentNetworkVlanId) { public SoftLayerTemplateOptions primaryBackendNetworkComponentNetworkVlanId(@Nullable Integer primaryBackendNetworkComponentNetworkVlanId) {
checkNotNull(primaryBackendNetworkComponentNetworkVlanId, "primaryBackendNetworkComponentNetworkVlanId was null"); this.primaryBackendNetworkComponentNetworkVlanId = primaryBackendNetworkComponentNetworkVlanId;
this.primaryBackendNetworkComponentNetworkVlanId = Optional.of(primaryBackendNetworkComponentNetworkVlanId);
return this; return this;
} }
public SoftLayerTemplateOptions hourlyBillingFlag(boolean hourlyBillingFlag) { public SoftLayerTemplateOptions hourlyBillingFlag(@Nullable Boolean hourlyBillingFlag) {
this.hourlyBillingFlag = Optional.of(hourlyBillingFlag); this.hourlyBillingFlag = hourlyBillingFlag;
return this; return this;
} }
public SoftLayerTemplateOptions dedicatedAccountHostOnlyFlag(boolean dedicatedAccountHostOnlyFlag) { public SoftLayerTemplateOptions dedicatedAccountHostOnlyFlag(@Nullable Boolean dedicatedAccountHostOnlyFlag) {
this.dedicatedAccountHostOnlyFlag = Optional.of(dedicatedAccountHostOnlyFlag); this.dedicatedAccountHostOnlyFlag = dedicatedAccountHostOnlyFlag;
return this; return this;
} }
public SoftLayerTemplateOptions privateNetworkOnlyFlag(boolean privateNetworkOnlyFlag) { public SoftLayerTemplateOptions privateNetworkOnlyFlag(@Nullable Boolean privateNetworkOnlyFlag) {
this.privateNetworkOnlyFlag = Optional.of(privateNetworkOnlyFlag); this.privateNetworkOnlyFlag = privateNetworkOnlyFlag;
return this; return this;
} }
public SoftLayerTemplateOptions postInstallScriptUri(String postInstallScriptUri) { public SoftLayerTemplateOptions postInstallScriptUri(@Nullable String postInstallScriptUri) {
checkNotNull(postInstallScriptUri, "postInstallScriptUri was null"); this.postInstallScriptUri = postInstallScriptUri;
this.postInstallScriptUri = Optional.of(postInstallScriptUri);
return this; return this;
} }
public SoftLayerTemplateOptions sshKeys(Iterable<Integer> sshKeys) { public SoftLayerTemplateOptions sshKeys(Iterable<Integer> sshKeys) {
for (Integer sshKey : checkNotNull(sshKeys, "sshKeys")) for (Integer sshKey : checkNotNull(sshKeys, "sshKeys"))
checkNotNull(sshKey, "sshKeys must be non-empty"); checkNotNull(sshKey, "sshKeys must be non-empty");
this.sshKeys = Optional.<List<Integer>> of(ImmutableList.copyOf(sshKeys)); this.sshKeys = ImmutableList.copyOf(sshKeys);
return this; return this;
} }
@ -200,38 +180,36 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
return domainName; return domainName;
} }
public Optional<List<Integer>> getBlockDevices() { public List<Integer> getBlockDevices() {
return blockDevices; return blockDevices;
} }
public Optional<String> getDiskType() { public String getDiskType() {
return diskType; return diskType;
} }
public Optional<Integer> getPortSpeed() { public Integer getPortSpeed() {
return portSpeed; return portSpeed;
} }
public Optional<String> getUserData() { return userData; } public String getUserData() { return userData; }
public Optional<Integer> getPrimaryNetworkComponentNetworkVlanId() { return primaryNetworkComponentNetworkVlanId; } public Integer getPrimaryNetworkComponentNetworkVlanId() { return primaryNetworkComponentNetworkVlanId; }
public Optional<Integer> getPrimaryBackendNetworkComponentNetworkVlanId() { return primaryBackendNetworkComponentNetworkVlanId; } public Integer getPrimaryBackendNetworkComponentNetworkVlanId() { return primaryBackendNetworkComponentNetworkVlanId; }
public Optional<Boolean> isHourlyBillingFlag() { return hourlyBillingFlag; } public Boolean isHourlyBillingFlag() { return hourlyBillingFlag; }
public Optional<Boolean> isDedicatedAccountHostOnlyFlag() { return dedicatedAccountHostOnlyFlag; } public Boolean isDedicatedAccountHostOnlyFlag() { return dedicatedAccountHostOnlyFlag; }
public Optional<Boolean> isPrivateNetworkOnlyFlag() { return privateNetworkOnlyFlag; } public Boolean isPrivateNetworkOnlyFlag() { return privateNetworkOnlyFlag; }
public Optional<String> getPostInstallScriptUri() { return postInstallScriptUri; } public String getPostInstallScriptUri() { return postInstallScriptUri; }
public Optional<List<Integer>> getSshKeys() { public List<Integer> getSshKeys() {
return sshKeys; return sshKeys;
} }
public static final SoftLayerTemplateOptions NONE = new SoftLayerTemplateOptions();
public static class Builder { public static class Builder {
/** /**
@ -239,7 +217,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions domainName(String domainName) { public static SoftLayerTemplateOptions domainName(String domainName) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.domainName(domainName)); return options.domainName(domainName);
} }
/** /**
@ -247,12 +225,12 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions blockDevices(Integer... capacities) { public static SoftLayerTemplateOptions blockDevices(Integer... capacities) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.blockDevices(capacities)); return options.blockDevices(capacities);
} }
public static SoftLayerTemplateOptions blockDevices(Iterable<Integer> capacities) { public static SoftLayerTemplateOptions blockDevices(Iterable<Integer> capacities) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.blockDevices(capacities)); return options.blockDevices(capacities);
} }
/** /**
@ -260,7 +238,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions diskType(String diskType) { public static SoftLayerTemplateOptions diskType(String diskType) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.diskType(diskType)); return options.diskType(diskType);
} }
/** /**
@ -268,7 +246,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions portSpeed(Integer portSpeed) { public static SoftLayerTemplateOptions portSpeed(Integer portSpeed) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.portSpeed(portSpeed)); return options.portSpeed(portSpeed);
} }
/** /**
@ -276,7 +254,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions userData(String userData) { public static SoftLayerTemplateOptions userData(String userData) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.userData(userData)); return options.userData(userData);
} }
/** /**
@ -284,7 +262,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions primaryNetworkComponentNetworkVlanId(Integer primaryNetworkComponentNetworkVlanId) { public static SoftLayerTemplateOptions primaryNetworkComponentNetworkVlanId(Integer primaryNetworkComponentNetworkVlanId) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.primaryNetworkComponentNetworkVlanId(primaryNetworkComponentNetworkVlanId)); return options.primaryNetworkComponentNetworkVlanId(primaryNetworkComponentNetworkVlanId);
} }
/** /**
@ -292,7 +270,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions primaryBackendNetworkComponentNetworkVlanId(Integer primaryBackendNetworkComponentNetworkVlanId) { public static SoftLayerTemplateOptions primaryBackendNetworkComponentNetworkVlanId(Integer primaryBackendNetworkComponentNetworkVlanId) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.primaryBackendNetworkComponentNetworkVlanId(primaryBackendNetworkComponentNetworkVlanId)); return options.primaryBackendNetworkComponentNetworkVlanId(primaryBackendNetworkComponentNetworkVlanId);
} }
/** /**
@ -300,7 +278,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions hourlyBillingFlag(boolean hourlyBillingFlag) { public static SoftLayerTemplateOptions hourlyBillingFlag(boolean hourlyBillingFlag) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.hourlyBillingFlag(hourlyBillingFlag)); return options.hourlyBillingFlag(hourlyBillingFlag);
} }
/** /**
@ -308,7 +286,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions dedicatedAccountHostOnlyFlag(boolean dedicatedAccountHostOnlyFlag) { public static SoftLayerTemplateOptions dedicatedAccountHostOnlyFlag(boolean dedicatedAccountHostOnlyFlag) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.dedicatedAccountHostOnlyFlag(dedicatedAccountHostOnlyFlag)); return options.dedicatedAccountHostOnlyFlag(dedicatedAccountHostOnlyFlag);
} }
/** /**
@ -316,7 +294,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions privateNetworkOnlyFlag(boolean privateNetworkOnlyFlag) { public static SoftLayerTemplateOptions privateNetworkOnlyFlag(boolean privateNetworkOnlyFlag) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.privateNetworkOnlyFlag(privateNetworkOnlyFlag)); return options.privateNetworkOnlyFlag(privateNetworkOnlyFlag);
} }
/** /**
@ -324,7 +302,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions postInstallScriptUri(String postInstallScriptUri) { public static SoftLayerTemplateOptions postInstallScriptUri(String postInstallScriptUri) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.postInstallScriptUri(postInstallScriptUri)); return options.postInstallScriptUri(postInstallScriptUri);
} }
/** /**
@ -332,22 +310,20 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions sshKeys(Integer... sshKeys) { public static SoftLayerTemplateOptions sshKeys(Integer... sshKeys) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.sshKeys(sshKeys)); return options.sshKeys(sshKeys);
} }
public static SoftLayerTemplateOptions sshKeys(Iterable<Integer> sshKeys) { public static SoftLayerTemplateOptions sshKeys(Iterable<Integer> sshKeys) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.blockDevices(sshKeys)); return options.blockDevices(sshKeys);
} }
// methods that only facilitate returning the correct object type
/** /**
* @see TemplateOptions#inboundPorts(int...) * @see TemplateOptions#inboundPorts(int...)
*/ */
public static SoftLayerTemplateOptions inboundPorts(int... ports) { public static SoftLayerTemplateOptions inboundPorts(int... ports) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.inboundPorts(ports)); return options.inboundPorts(ports);
} }
/** /**
@ -355,7 +331,23 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions blockOnPort(int port, int seconds) { public static SoftLayerTemplateOptions blockOnPort(int port, int seconds) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.blockOnPort(port, seconds)); return options.blockOnPort(port, seconds);
}
/**
* @see TemplateOptions#installPrivateKey(String)
*/
public static SoftLayerTemplateOptions installPrivateKey(String rsaKey) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return options.installPrivateKey(rsaKey);
}
/**
* @see TemplateOptions#authorizePublicKey(String)
*/
public static SoftLayerTemplateOptions authorizePublicKey(String rsaKey) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return options.authorizePublicKey(rsaKey);
} }
/** /**
@ -363,15 +355,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions userMetadata(Map<String, String> userMetadata) { public static SoftLayerTemplateOptions userMetadata(Map<String, String> userMetadata) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.userMetadata(userMetadata)); return options.userMetadata(userMetadata);
}
/**
* @see TemplateOptions#userMetadata(String, String)
*/
public static SoftLayerTemplateOptions userMetadata(String key, String value) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.userMetadata(key, value));
} }
/** /**
@ -379,7 +363,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions nodeNames(Iterable<String> nodeNames) { public static SoftLayerTemplateOptions nodeNames(Iterable<String> nodeNames) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.nodeNames(nodeNames)); return options.nodeNames(nodeNames);
} }
/** /**
@ -387,14 +371,62 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
*/ */
public static SoftLayerTemplateOptions networks(Iterable<String> networks) { public static SoftLayerTemplateOptions networks(Iterable<String> networks) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions(); SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return SoftLayerTemplateOptions.class.cast(options.networks(networks)); return options.networks(networks);
}
} }
/**
* @see TemplateOptions#overrideLoginUser(String)
*/
public static SoftLayerTemplateOptions overrideLoginUser(String user) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return options.overrideLoginUser(user);
}
/**
* @see TemplateOptions#overrideLoginPassword(String)
*/
public static SoftLayerTemplateOptions overrideLoginPassword(String password) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return options.overrideLoginPassword(password);
}
/**
* @see TemplateOptions#overrideLoginPrivateKey(String)
*/
public static SoftLayerTemplateOptions overrideLoginPrivateKey(String privateKey) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return options.overrideLoginPrivateKey(privateKey);
}
/**
* @see TemplateOptions#overrideAuthenticateSudo(boolean)
*/
public static SoftLayerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return options.overrideAuthenticateSudo(authenticateSudo);
}
/**
* @see TemplateOptions#overrideLoginCredentials(LoginCredentials)
*/
public static SoftLayerTemplateOptions overrideLoginCredentials(LoginCredentials credentials) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return options.overrideLoginCredentials(credentials);
}
/**
* @see TemplateOptions#blockUntilRunning(boolean)
*/
public static SoftLayerTemplateOptions blockUntilRunning(boolean blockUntilRunning) {
SoftLayerTemplateOptions options = new SoftLayerTemplateOptions();
return options.blockUntilRunning(blockUntilRunning);
}
}
// methods that only facilitate returning the correct object type // methods that only facilitate returning the correct object type
/** /**
* @see TemplateOptions#blockOnPort(int, int) * {@inheritDoc}
*/ */
@Override @Override
public SoftLayerTemplateOptions blockOnPort(int port, int seconds) { public SoftLayerTemplateOptions blockOnPort(int port, int seconds) {
@ -402,7 +434,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
} }
/** /**
* @see TemplateOptions#inboundPorts(int...) * {@inheritDoc}
*/ */
@Override @Override
public SoftLayerTemplateOptions inboundPorts(int... ports) { public SoftLayerTemplateOptions inboundPorts(int... ports) {
@ -410,7 +442,7 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
} }
/** /**
* @see TemplateOptions#authorizePublicKey(String) * {@inheritDoc}
*/ */
@Override @Override
public SoftLayerTemplateOptions authorizePublicKey(String publicKey) { public SoftLayerTemplateOptions authorizePublicKey(String publicKey) {
@ -418,13 +450,93 @@ public class SoftLayerTemplateOptions extends TemplateOptions implements Cloneab
} }
/** /**
* @see TemplateOptions#installPrivateKey(String) * {@inheritDoc}
*/ */
@Override @Override
public SoftLayerTemplateOptions installPrivateKey(String privateKey) { public SoftLayerTemplateOptions installPrivateKey(String privateKey) {
return SoftLayerTemplateOptions.class.cast(super.installPrivateKey(privateKey)); return SoftLayerTemplateOptions.class.cast(super.installPrivateKey(privateKey));
} }
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions blockUntilRunning(boolean blockUntilRunning) {
return SoftLayerTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning));
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions dontAuthorizePublicKey() {
return SoftLayerTemplateOptions.class.cast(super.dontAuthorizePublicKey());
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions nameTask(String name) {
return SoftLayerTemplateOptions.class.cast(super.nameTask(name));
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions runAsRoot(boolean runAsRoot) {
return SoftLayerTemplateOptions.class.cast(super.runAsRoot(runAsRoot));
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions runScript(Statement script) {
return SoftLayerTemplateOptions.class.cast(super.runScript(script));
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) {
return SoftLayerTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials));
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions overrideLoginPassword(String password) {
return SoftLayerTemplateOptions.class.cast(super.overrideLoginPassword(password));
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions overrideLoginPrivateKey(String privateKey) {
return SoftLayerTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey));
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions overrideLoginUser(String loginUser) {
return SoftLayerTemplateOptions.class.cast(super.overrideLoginUser(loginUser));
}
/**
* {@inheritDoc}
*/
@Override
public SoftLayerTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
return SoftLayerTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo));
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */

View File

@ -30,7 +30,6 @@ import static org.jclouds.compute.util.ComputeServiceUtils.getSpace;
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_ACTIVE_TRANSACTIONS_DELAY; import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_ACTIVE_TRANSACTIONS_DELAY;
import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY; import static org.jclouds.softlayer.reference.SoftLayerConstants.PROPERTY_SOFTLAYER_VIRTUALGUEST_LOGIN_DETAILS_DELAY;
import static org.jclouds.util.Predicates2.retry; import static org.jclouds.util.Predicates2.retry;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -82,6 +81,7 @@ import com.google.common.base.Supplier;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
import com.google.common.collect.FluentIterable; import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -99,7 +99,6 @@ public class SoftLayerComputeServiceAdapter implements
private static final int USER_META_NOTES_MAX_LENGTH = 1000; private static final int USER_META_NOTES_MAX_LENGTH = 1000;
private static final String BOOTABLE_DEVICE = "0"; private static final String BOOTABLE_DEVICE = "0";
public static final String DEFAULT_DISK_TYPE = "LOCAL"; public static final String DEFAULT_DISK_TYPE = "LOCAL";
public static final int DEFAULT_MAX_PORT_SPEED = 100;
@Resource @Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER) @Named(ComputeServiceConstants.COMPUTE_LOGGER)
@ -136,9 +135,12 @@ public class SoftLayerComputeServiceAdapter implements
SoftLayerTemplateOptions templateOptions = template.getOptions().as(SoftLayerTemplateOptions.class); SoftLayerTemplateOptions templateOptions = template.getOptions().as(SoftLayerTemplateOptions.class);
String domainName = templateOptions.getDomainName(); String domainName = templateOptions.getDomainName();
String diskType = templateOptions.getDiskType().or(DEFAULT_DISK_TYPE); String diskType = templateOptions.getDiskType() == null ? DEFAULT_DISK_TYPE : templateOptions.getDiskType();
boolean hourlyBillingFlag = templateOptions.isHourlyBillingFlag().or(true); boolean hourlyBillingFlag = templateOptions.isHourlyBillingFlag() == null ? true : templateOptions.isHourlyBillingFlag();
int maxPortSpeed = templateOptions.getPortSpeed().or(DEFAULT_MAX_PORT_SPEED); Integer portSpeed = templateOptions.getPortSpeed();
Set<VirtualGuestNetworkComponent> networkComponents = portSpeed != null ?
ImmutableSet.of(VirtualGuestNetworkComponent.builder().speed(portSpeed).build()) :
ImmutableSet.<VirtualGuestNetworkComponent>of();
final Datacenter datacenter = Datacenter.builder().name(template.getLocation().getId()).build(); final Datacenter datacenter = Datacenter.builder().name(template.getLocation().getId()).build();
final String imageId = template.getImage().getId(); final String imageId = template.getImage().getId();
int cores = (int) template.getHardware().getProcessors().get(0).getCores(); int cores = (int) template.getHardware().getProcessors().get(0).getCores();
@ -151,10 +153,12 @@ public class SoftLayerComputeServiceAdapter implements
.startCpus(cores) .startCpus(cores)
.maxMemory(template.getHardware().getRam()) .maxMemory(template.getHardware().getRam())
.datacenter(datacenter) .datacenter(datacenter)
.localDiskFlag(isLocalDisk(diskType)); .localDiskFlag(isLocalDisk(diskType))
.networkComponents(networkComponents);
// set operating system or blockDeviceTemplateGroup // set operating system or blockDeviceTemplateGroup
Optional<OperatingSystem> optionalOperatingSystem = tryExtractOperatingSystemFrom(imageId); Optional<OperatingSystem> optionalOperatingSystem = tryExtractOperatingSystemFrom(imageId);
if (optionalOperatingSystem.isPresent()) { if (optionalOperatingSystem != null) {
virtualGuestBuilder.operatingSystem(optionalOperatingSystem.get()); virtualGuestBuilder.operatingSystem(optionalOperatingSystem.get());
// the imageId specified is an id of a public/private/flex image // the imageId specified is an id of a public/private/flex image
} else { } else {
@ -163,47 +167,47 @@ public class SoftLayerComputeServiceAdapter implements
virtualGuestBuilder.blockDeviceTemplateGroup(blockDeviceTemplateGroup).build(); virtualGuestBuilder.blockDeviceTemplateGroup(blockDeviceTemplateGroup).build();
} }
// set multi-disks // set multi-disks
if (templateOptions.getBlockDevices().isPresent()) { if (!templateOptions.getBlockDevices().isEmpty()) {
List<VirtualGuestBlockDevice> blockDevices = getBlockDevices(templateOptions.getBlockDevices().get(), diskType); List<VirtualGuestBlockDevice> blockDevices = getBlockDevices(templateOptions.getBlockDevices(), diskType);
virtualGuestBuilder.blockDevices(blockDevices); virtualGuestBuilder.blockDevices(blockDevices);
} }
// set dedicatedAccountHostOnlyFlag // set dedicatedAccountHostOnlyFlag
if (templateOptions.isDedicatedAccountHostOnlyFlag().isPresent()) { if (templateOptions.isDedicatedAccountHostOnlyFlag() != null) {
virtualGuestBuilder.dedicatedAccountHostOnly(templateOptions.isDedicatedAccountHostOnlyFlag().get()); virtualGuestBuilder.dedicatedAccountHostOnly(templateOptions.isDedicatedAccountHostOnlyFlag());
} }
// set privateNetworkOnlyFlag // set privateNetworkOnlyFlag
if (templateOptions.isPrivateNetworkOnlyFlag().isPresent()) { if (templateOptions.isPrivateNetworkOnlyFlag() != null) {
virtualGuestBuilder.privateNetworkOnlyFlag(templateOptions.isPrivateNetworkOnlyFlag().get()); virtualGuestBuilder.privateNetworkOnlyFlag(templateOptions.isPrivateNetworkOnlyFlag());
} }
// set primaryNetworkComponent.networkVlan.id // set primaryNetworkComponent.networkVlan.id
if (templateOptions.getPrimaryNetworkComponentNetworkVlanId().isPresent()) { if (templateOptions.getPrimaryNetworkComponentNetworkVlanId() != null) {
int primaryNetworkComponentNetworkVlanId = templateOptions.getPrimaryNetworkComponentNetworkVlanId().get(); int primaryNetworkComponentNetworkVlanId = templateOptions.getPrimaryNetworkComponentNetworkVlanId();
virtualGuestBuilder.primaryNetworkComponent( virtualGuestBuilder.primaryNetworkComponent(
VirtualGuestNetworkComponent.builder() VirtualGuestNetworkComponent.builder()
.networkVlan(NetworkVlan.builder().id(primaryNetworkComponentNetworkVlanId).build()) .networkVlan(NetworkVlan.builder().id(primaryNetworkComponentNetworkVlanId).build())
.speed(maxPortSpeed).build()); .build());
} }
// set primaryBackendNetworkComponent.networkVlan.id // set primaryBackendNetworkComponent.networkVlan.id
if (templateOptions.getPrimaryBackendNetworkComponentNetworkVlanId().isPresent()) { if (templateOptions.getPrimaryBackendNetworkComponentNetworkVlanId() != null) {
int primaryBackendNetworkComponentNetworkVlanId = templateOptions.getPrimaryBackendNetworkComponentNetworkVlanId().get(); int primaryBackendNetworkComponentNetworkVlanId = templateOptions.getPrimaryBackendNetworkComponentNetworkVlanId();
virtualGuestBuilder.primaryBackendNetworkComponent( virtualGuestBuilder.primaryBackendNetworkComponent(
VirtualGuestNetworkComponent.builder() VirtualGuestNetworkComponent.builder()
.networkVlan(NetworkVlan.builder().id(primaryBackendNetworkComponentNetworkVlanId).build()) .networkVlan(NetworkVlan.builder().id(primaryBackendNetworkComponentNetworkVlanId).build())
.speed(maxPortSpeed).build()); .build());
} }
// set postInstallScriptUri // set postInstallScriptUri
if (templateOptions.getPostInstallScriptUri().isPresent()) { if (templateOptions.getPostInstallScriptUri() != null) {
// Specifies the uri location of the script to be downloaded and run after installation is complete. // Specifies the uri location of the script to be downloaded and run after installation is complete.
virtualGuestBuilder.postInstallScriptUri(templateOptions.getPostInstallScriptUri().get()); virtualGuestBuilder.postInstallScriptUri(templateOptions.getPostInstallScriptUri());
} }
// set userData // set userData
if (templateOptions.getUserData().isPresent()) { if (templateOptions.getUserData() != null) {
virtualGuestBuilder.virtualGuestAttribute(VirtualGuestAttribute.builder().value(templateOptions.getUserData().get()).build()); virtualGuestBuilder.virtualGuestAttribute(VirtualGuestAttribute.builder().value(templateOptions.getUserData()).build());
} }
// set sshKeys // set sshKeys
if (templateOptions.getSshKeys().isPresent()) { if (!templateOptions.getSshKeys().isEmpty()) {
Set<SecuritySshKey> sshKeys = Sets.newHashSet(); Set<SecuritySshKey> sshKeys = Sets.newHashSet();
for (int sshKeyId : templateOptions.getSshKeys().get()) { for (int sshKeyId : templateOptions.getSshKeys()) {
sshKeys.add(SecuritySshKey.builder().id(sshKeyId).build()); sshKeys.add(SecuritySshKey.builder().id(sshKeyId).build());
} }
virtualGuestBuilder.sshKeys(sshKeys); virtualGuestBuilder.sshKeys(sshKeys);
@ -215,7 +219,7 @@ public class SoftLayerComputeServiceAdapter implements
logger.trace("<< VirtualGuest(%s)", result.getId()); logger.trace("<< VirtualGuest(%s)", result.getId());
// tags // tags
if (templateOptions.getTags() != null) { if (!templateOptions.getTags().isEmpty()) {
api.getVirtualGuestApi().setTags(result.getId(), templateOptions.getTags()); api.getVirtualGuestApi().setTags(result.getId(), templateOptions.getTags());
} }

View File

@ -25,9 +25,11 @@ import org.jclouds.softlayer.domain.Datacenter;
import org.jclouds.softlayer.domain.OperatingSystem; import org.jclouds.softlayer.domain.OperatingSystem;
import org.jclouds.softlayer.domain.VirtualGuest; import org.jclouds.softlayer.domain.VirtualGuest;
import org.jclouds.softlayer.domain.VirtualGuestBlockDeviceTemplateGroup; import org.jclouds.softlayer.domain.VirtualGuestBlockDeviceTemplateGroup;
import org.jclouds.softlayer.domain.VirtualGuestNetworkComponent;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson; import com.google.gson.Gson;
@Test(groups = "unit", testName = "VirtualGuestToJsonTest") @Test(groups = "unit", testName = "VirtualGuestToJsonTest")
@ -56,6 +58,7 @@ public class VirtualGuestToJsonTest {
.operatingSystemReferenceCode("UBUNTU_12_64") .operatingSystemReferenceCode("UBUNTU_12_64")
.build()) .build())
.localDiskFlag(true) .localDiskFlag(true)
.networkComponents(ImmutableSet.<VirtualGuestNetworkComponent>of())
.build(); .build();
request = binder.bindToRequest(request, virtualGuestWithOS); request = binder.bindToRequest(request, virtualGuestWithOS);
@ -80,6 +83,7 @@ public class VirtualGuestToJsonTest {
.globalIdentifier("ffaafa98-4b4a-4fa7-b9f7-b1bad5ec50f0") .globalIdentifier("ffaafa98-4b4a-4fa7-b9f7-b1bad5ec50f0")
.build()) .build())
.localDiskFlag(true) .localDiskFlag(true)
.networkComponents(ImmutableSet.<VirtualGuestNetworkComponent>of())
.build(); .build();
request = binder.bindToRequest(request, virtualGuestWithVirtualGuestBlockDeviceTemplateGroup); request = binder.bindToRequest(request, virtualGuestWithVirtualGuestBlockDeviceTemplateGroup);

View File

@ -67,9 +67,11 @@ public class SoftLayerComputeServiceContextLiveTest extends BaseComputeServiceCo
// test passing custom options // test passing custom options
SoftLayerTemplateOptions options = template.getOptions().as(SoftLayerTemplateOptions.class); SoftLayerTemplateOptions options = template.getOptions().as(SoftLayerTemplateOptions.class);
options.domainName("live.org"); options.domainName("live.org");
options.portSpeed(100);
//tags //tags
options.tags(ImmutableList.of("jclouds")); options.tags(ImmutableList.of("jclouds"));
Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup(name, numNodes, template); Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup(name, numNodes, template);
assertEquals(numNodes, nodes.size(), "wrong number of nodes"); assertEquals(numNodes, nodes.size(), "wrong number of nodes");
for (NodeMetadata node : nodes) { for (NodeMetadata node : nodes) {