Merge lp:~xfactor973/charm-helpers/action-params into lp:charm-helpers

Proposed by Chris Holcombe
Status: Merged
Merged at revision: 552
Proposed branch: lp:~xfactor973/charm-helpers/action-params
Merge into: lp:charm-helpers
Diff against target: 25 lines (+6/-1)
1 file modified
charmhelpers/contrib/amulet/utils.py (+6/-1)
To merge this branch: bzr merge lp:~xfactor973/charm-helpers/action-params
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
Ryan Beisner (community) Approve
Review via email: mp+289537@code.launchpad.net

Description of the change

This patch adds dictionary of parameters to be passed to a juju run action. I made it a named argument with a default of None so that I don't break anyone currently tied to using this function.

To post a comment you must log in.
Revision history for this message
Ryan Beisner (1chb1n) :
review: Approve
Revision history for this message
Charles Butler (lazypower) wrote :

+1 LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/amulet/utils.py'
2--- charmhelpers/contrib/amulet/utils.py 2015-09-21 14:25:14 +0000
3+++ charmhelpers/contrib/amulet/utils.py 2016-03-18 19:11:35 +0000
4@@ -782,15 +782,20 @@
5
6 # amulet juju action helpers:
7 def run_action(self, unit_sentry, action,
8- _check_output=subprocess.check_output):
9+ _check_output=subprocess.check_output,
10+ params=None):
11 """Run the named action on a given unit sentry.
12
13+ params a dict of parameters to use
14 _check_output parameter is used for dependency injection.
15
16 @return action_id.
17 """
18 unit_id = unit_sentry.info["unit_name"]
19 command = ["juju", "action", "do", "--format=json", unit_id, action]
20+ if params is not None:
21+ for key, value in params.iteritems():
22+ command.append("{}={}".format(key, value))
23 self.log.info("Running command: %s\n" % " ".join(command))
24 output = _check_output(command, universal_newlines=True)
25 data = json.loads(output)

Subscribers

People subscribed via source and target branches