You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@libcloud.apache.org by "Rudolf J Streif (JIRA)" <ji...@apache.org> on 2013/03/27 21:03:17 UTC

[dev] [jira] [Created] (LIBCLOUD-311) Add ScriptFileDeployment Class

Rudolf J Streif created LIBCLOUD-311:
----------------------------------------

             Summary: Add ScriptFileDeployment Class
                 Key: LIBCLOUD-311
                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-311
             Project: Libcloud
          Issue Type: Improvement
          Components: Compute
    Affects Versions: 0.12.3
            Reporter: Rudolf J Streif
            Priority: Minor


The ScriptDeployment class easily lets you deploy and execute a series of commands provided as a string with the script parameter. That works fine if you only have a few commands.

Sometimes it would be useful to write a script file and then execute it on a node. For that reason I am proposing the following patch:

diff --git a/libcloud/compute/deployment.py b/libcloud/compute/deployment.py
index 6f24a06..f04ff49 100644
--- a/libcloud/compute/deployment.py
+++ b/libcloud/compute/deployment.py
@@ -167,6 +167,30 @@ class ScriptDeployment(Deployment):
         return node


+class ScriptFileDeployment(ScriptDeployment):
+    """
+    Runs an arbitrary Shell Script task from a file.
+    """
+
+    def __init__(self, scriptfile, name=None, delete=False):
+        """
+        @type scriptfile: C{str}
+        @keyword scriptfile: File containing the script to run
+
+        @type name: C{str}
+        @keyword name: Name of the script to upload it as, if not specified, a random name will be choosen.
+
+        @type delete: C{bool}
+        @keyword delete: Whether to delete the script on completion.
+        """
+        with open(scriptfile, 'rb') as fp:
+            content = fp.read()
+        
+        super(ScriptFileDeployment, self).__init__(script=content,
+                                               name=name,
+                                               delete=delete)
+
+
 class MultiStepDeployment(Deployment):
     """
     Runs a chain of Deployment steps.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira