You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/09/11 13:22:04 UTC
[2/6] git commit: Also allow user to pass "args" argument to the
ScriptFileDeployment class.
Also allow user to pass "args" argument to the ScriptFileDeployment class.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/44f45cef
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/44f45cef
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/44f45cef
Branch: refs/heads/trunk
Commit: 44f45cef1d0dc25c2b9972cb25169f6cbee34669
Parents: 799047e
Author: Tomaz Muraus <to...@apache.org>
Authored: Wed Sep 11 12:16:06 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Sep 11 12:16:06 2013 +0200
----------------------------------------------------------------------
CHANGES | 6 +++---
libcloud/compute/deployment.py | 18 +++++++++++++-----
libcloud/test/compute/test_deployment.py | 15 +++++++++++++++
3 files changed, 31 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/44f45cef/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 464477c..520a483 100644
--- a/CHANGES
+++ b/CHANGES
@@ -75,9 +75,9 @@ Changes with Apache Libcloud in development
extension arguments for handling security groups. (LIBCLOUD-388)
[sebastien goasguen]
- - Allow user to pass "args" argument to the ScriptDeployment class. This
- argument tells which command line arguments get passed to the
- ScriptDeployment script. (LIBCLOUD-394)
+ - Allow user to pass "args" argument to the ScriptDeployment and
+ ScriptFileDeployment class. This argument tells which command line
+ arguments get passed to the ScriptDeployment script. (LIBCLOUD-394)
[Tomaz Muraus]
*) Storage
http://git-wip-us.apache.org/repos/asf/libcloud/blob/44f45cef/libcloud/compute/deployment.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/deployment.py b/libcloud/compute/deployment.py
index b8224d5..653460f 100644
--- a/libcloud/compute/deployment.py
+++ b/libcloud/compute/deployment.py
@@ -189,11 +189,16 @@ class ScriptFileDeployment(ScriptDeployment):
Runs an arbitrary shell script from a local file on the server.
"""
- def __init__(self, script_file, name=None, delete=False):
+ def __init__(self, script_file, args=None, name=None, delete=False):
"""
@type script_file: C{str}
@keyword script_file: Path to a file containing the script to run.
+ @type args: C{list}
+ @keyword args: Optional command line arguments which get passed to the
+ deployment script file.
+
+
@type name: C{str}
@keyword name: Name of the script to upload it as, if not specified,
a random name will be choosen.
@@ -208,8 +213,9 @@ class ScriptFileDeployment(ScriptDeployment):
content = content.decode('utf-8')
super(ScriptFileDeployment, self).__init__(script=content,
- name=name,
- delete=delete)
+ args=args,
+ name=name,
+ delete=delete)
class MultiStepDeployment(Deployment):
@@ -225,10 +231,12 @@ class MultiStepDeployment(Deployment):
self.add(add)
def add(self, add):
- """Add a deployment to this chain.
+ """
+ Add a deployment to this chain.
@type add: Single L{Deployment} or a C{list} of L{Deployment}
- @keyword add: Adds this deployment to the others already in this object.
+ @keyword add: Adds this deployment to the others already in this
+ object.
"""
if add is not None:
add = add if isinstance(add, (list, tuple)) else [add]
http://git-wip-us.apache.org/repos/asf/libcloud/blob/44f45cef/libcloud/test/compute/test_deployment.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_deployment.py b/libcloud/test/compute/test_deployment.py
index bfe0c36..c714d6c 100644
--- a/libcloud/test/compute/test_deployment.py
+++ b/libcloud/test/compute/test_deployment.py
@@ -168,6 +168,21 @@ class DeploymentTests(unittest.TestCase):
expected = '/root/relative.sh'
client.run.assert_called_once_with(expected)
+ def test_script_file_deployment_with_arguments(self):
+ file_path = os.path.abspath(__file__)
+ client = Mock()
+ client.put.return_value = '/home/ubuntu/relative.sh'
+ client.run.return_value = ('', '', 0)
+
+ args = ['arg1', 'arg2', '--option1=test', 'option2']
+ sfd = ScriptFileDeployment(script_file=file_path, args=args,
+ name='/root/relative.sh')
+
+ sfd.run(self.node, client)
+
+ expected = '/root/relative.sh arg1 arg2 --option1=test option2'
+ client.run.assert_called_once_with(expected)
+
def test_script_deployment_and_sshkey_deployment_argument_types(self):
class FileObject(object):
def __init__(self, name):