libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1462539 - in /libcloud/branches/0.12.x: ./ CHANGES libcloud/compute/deployment.py libcloud/test/compute/test_deployment.py
Date Fri, 29 Mar 2013 17:05:21 GMT
Author: tomaz
Date: Fri Mar 29 17:05:21 2013
New Revision: 1462539

URL: http://svn.apache.org/r1462539
Log:
Backport commit 1462534 from trunk.

Modified:
    libcloud/branches/0.12.x/   (props changed)
    libcloud/branches/0.12.x/CHANGES
    libcloud/branches/0.12.x/libcloud/compute/deployment.py
    libcloud/branches/0.12.x/libcloud/test/compute/test_deployment.py

Propchange: libcloud/branches/0.12.x/
------------------------------------------------------------------------------
  Merged /libcloud/trunk:r1462534

Modified: libcloud/branches/0.12.x/CHANGES
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/CHANGES?rev=1462539&r1=1462538&r2=1462539&view=diff
==============================================================================
--- libcloud/branches/0.12.x/CHANGES (original)
+++ libcloud/branches/0.12.x/CHANGES Fri Mar 29 17:05:21 2013
@@ -17,6 +17,10 @@ Changes with Apache Libcloud in developm
       the right value.
       [Tomaz Muraus]
 
+    - Add new ScriptFileDeployment deployment class which reads deploy script
+      from a file.
+      [Rudolf J Streif]
+
 Changes with Apache Libcloud 0.12.3:
 
   *) General

Modified: libcloud/branches/0.12.x/libcloud/compute/deployment.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/compute/deployment.py?rev=1462539&r1=1462538&r2=1462539&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/compute/deployment.py (original)
+++ libcloud/branches/0.12.x/libcloud/compute/deployment.py Fri Mar 29 17:05:21 2013
@@ -123,7 +123,8 @@ class ScriptDeployment(Deployment):
         @keyword script: Contents of 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.
+        @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.
@@ -167,6 +168,31 @@ class ScriptDeployment(Deployment):
         return node
 
 
+class ScriptFileDeployment(ScriptDeployment):
+    """
+    Runs an arbitrary Shell Script task from a file.
+    """
+
+    def __init__(self, script_file, name=None, delete=False):
+        """
+        @type script_file: C{str}
+        @keyword script_file: Path to a 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(script_file, '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.

Modified: libcloud/branches/0.12.x/libcloud/test/compute/test_deployment.py
URL: http://svn.apache.org/viewvc/libcloud/branches/0.12.x/libcloud/test/compute/test_deployment.py?rev=1462539&r1=1462538&r2=1462539&view=diff
==============================================================================
--- libcloud/branches/0.12.x/libcloud/test/compute/test_deployment.py (original)
+++ libcloud/branches/0.12.x/libcloud/test/compute/test_deployment.py Fri Mar 29 17:05:21
2013
@@ -24,7 +24,7 @@ from libcloud.utils.py3 import u
 
 from libcloud.compute.deployment import MultiStepDeployment, Deployment
 from libcloud.compute.deployment import SSHKeyDeployment, ScriptDeployment
-from libcloud.compute.deployment import FileDeployment
+from libcloud.compute.deployment import ScriptFileDeployment, FileDeployment
 from libcloud.compute.base import Node
 from libcloud.compute.types import NodeState, DeploymentError, LibcloudError
 from libcloud.compute.ssh import BaseSSHClient
@@ -111,6 +111,14 @@ class DeploymentTests(unittest.TestCase)
         self.assertEqual(self.node, sd2.run(node=self.node,
                         client=MockClient(hostname='localhost')))
 
+    def test_script_file_deployment(self):
+        file_path = os.path.abspath(__file__)
+        with open(file_path, 'rb') as fp:
+            content = fp.read()
+
+        sfd1 = ScriptFileDeployment(script_file=file_path)
+        self.assertEqual(sfd1.script, content)
+
     def test_script_deployment_relative_path(self):
         client = Mock()
         client.put.return_value = '/home/ubuntu/relative.sh'



Mime
View raw message