JCLOUDS-995 - Add `userData` property to `CloudStackTemplateOptions` and map it in the underlying adapter.

This commit is contained in:
Irmo Manie 2015-09-01 11:21:36 +02:00 committed by Ignasi Barrera
parent cc1217b5c8
commit 1ef5c70106
2 changed files with 31 additions and 5 deletions

View File

@ -32,13 +32,13 @@ import com.google.common.collect.Sets;
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)} and
* {@link ComputeService#createNodesInGroup(String, int, TemplateOptions)}
* operations on the <em>gogrid</em> provider.
*
*
* <h2>Usage</h2> The recommended way to instantiate a
* {@link CloudStackTemplateOptions} object is to statically import
* {@code CloudStackTemplateOptions.*} and invoke a static creation method
* followed by an instance mutator (if needed):
* <p>
*
*
* <pre>
* import static org.jclouds.compute.options.CloudStackTemplateOptions.Builder.*;
* ComputeService client = // get connection
@ -59,7 +59,8 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
protected boolean generateSecurityGroup = false;
protected String diskOfferingId;
protected int dataDiskSize;
protected byte[] unencodedData;
@Override
public CloudStackTemplateOptions clone() {
CloudStackTemplateOptions options = new CloudStackTemplateOptions();
@ -83,6 +84,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
eTo.setupStaticNat(setupStaticNat);
eTo.diskOfferingId(diskOfferingId);
eTo.dataDiskSize(dataDiskSize);
eTo.userData(unencodedData);
}
}
@ -110,6 +112,18 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
return dataDiskSize;
}
/**
* @see DeployVirtualMachineOptions#userData
*/
public CloudStackTemplateOptions userData(byte[] unencodedData) {
this.unencodedData = unencodedData;
return this;
}
public byte[] getUserData() {
return unencodedData;
}
/**
* @see DeployVirtualMachineOptions#securityGroupId
*/
@ -278,6 +292,14 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
return options.dataDiskSize(dataDiskSize);
}
/**
* @see CloudStackTemplateOptions#userData
*/
public static CloudStackTemplateOptions userData(byte[] unencodedData) {
CloudStackTemplateOptions options = new CloudStackTemplateOptions();
return options.userData(unencodedData);
}
/**
* @see CloudStackTemplateOptions#securityGroupId
*/
@ -295,7 +317,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
}
/**
* @see CloudStackTemplateOptions#shouldGenerateSecurityGroup()
* @see CloudStackTemplateOptions#shouldGenerateSecurityGroup()
*/
public static CloudStackTemplateOptions generateSecurityGroup(boolean enable) {
return new CloudStackTemplateOptions().generateSecurityGroup(enable);
@ -352,7 +374,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
}
/**
* @see CloudStackTemplateOptions#shouldGenerateKeyPair()
* @see CloudStackTemplateOptions#shouldGenerateKeyPair()
*/
public static CloudStackTemplateOptions generateKeyPair(boolean enable) {
return new CloudStackTemplateOptions().generateKeyPair(enable);

View File

@ -183,6 +183,10 @@ public class CloudStackComputeServiceAdapter implements
options.ipsToNetworks(templateOptions.getIpsToNetworks());
}
if (templateOptions.getUserData() != null) {
options.userData(templateOptions.getUserData());
}
if (templateOptions.getKeyPair() != null) {
SshKeyPair keyPair = null;
if (templateOptions.getLoginPrivateKey() != null) {