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

@ -59,6 +59,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
protected boolean generateSecurityGroup = false; protected boolean generateSecurityGroup = false;
protected String diskOfferingId; protected String diskOfferingId;
protected int dataDiskSize; protected int dataDiskSize;
protected byte[] unencodedData;
@Override @Override
public CloudStackTemplateOptions clone() { public CloudStackTemplateOptions clone() {
@ -83,6 +84,7 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
eTo.setupStaticNat(setupStaticNat); eTo.setupStaticNat(setupStaticNat);
eTo.diskOfferingId(diskOfferingId); eTo.diskOfferingId(diskOfferingId);
eTo.dataDiskSize(dataDiskSize); eTo.dataDiskSize(dataDiskSize);
eTo.userData(unencodedData);
} }
} }
@ -110,6 +112,18 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
return dataDiskSize; return dataDiskSize;
} }
/**
* @see DeployVirtualMachineOptions#userData
*/
public CloudStackTemplateOptions userData(byte[] unencodedData) {
this.unencodedData = unencodedData;
return this;
}
public byte[] getUserData() {
return unencodedData;
}
/** /**
* @see DeployVirtualMachineOptions#securityGroupId * @see DeployVirtualMachineOptions#securityGroupId
*/ */
@ -278,6 +292,14 @@ public class CloudStackTemplateOptions extends TemplateOptions implements Clonea
return options.dataDiskSize(dataDiskSize); return options.dataDiskSize(dataDiskSize);
} }
/**
* @see CloudStackTemplateOptions#userData
*/
public static CloudStackTemplateOptions userData(byte[] unencodedData) {
CloudStackTemplateOptions options = new CloudStackTemplateOptions();
return options.userData(unencodedData);
}
/** /**
* @see CloudStackTemplateOptions#securityGroupId * @see CloudStackTemplateOptions#securityGroupId
*/ */

View File

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