diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java index 1bcad0cd26..59ceff9d7e 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/options/CloudStackTemplateOptions.java @@ -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 gogrid provider. - * + * *

Usage

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): *

- * + * *

  * 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);
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java
index e723f7f363..3806a83989 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/compute/strategy/CloudStackComputeServiceAdapter.java
@@ -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) {