[
https://issues.apache.org/jira/browse/LIBCLOUD-311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13617485#comment-13617485
]
Rudolf J Streif commented on LIBCLOUD-311:
------------------------------------------
Changed scriptfile parameter name to script_file. Patch attached.
> 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
> Original Estimate: 10m
> Remaining Estimate: 10m
>
> 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