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
=== modified file 'charmhelpers/contrib/amulet/utils.py'
--- charmhelpers/contrib/amulet/utils.py 2015-09-21 14:25:14 +0000
+++ charmhelpers/contrib/amulet/utils.py 2016-03-18 19:11:35 +0000
@@ -782,15 +782,20 @@
782782
783# amulet juju action helpers:783# amulet juju action helpers:
784 def run_action(self, unit_sentry, action,784 def run_action(self, unit_sentry, action,
785 _check_output=subprocess.check_output):785 _check_output=subprocess.check_output,
786 params=None):
786 """Run the named action on a given unit sentry.787 """Run the named action on a given unit sentry.
787788
789 params a dict of parameters to use
788 _check_output parameter is used for dependency injection.790 _check_output parameter is used for dependency injection.
789791
790 @return action_id.792 @return action_id.
791 """793 """
792 unit_id = unit_sentry.info["unit_name"]794 unit_id = unit_sentry.info["unit_name"]
793 command = ["juju", "action", "do", "--format=json", unit_id, action]795 command = ["juju", "action", "do", "--format=json", unit_id, action]
796 if params is not None:
797 for key, value in params.iteritems():
798 command.append("{}={}".format(key, value))
794 self.log.info("Running command: %s\n" % " ".join(command))799 self.log.info("Running command: %s\n" % " ".join(command))
795 output = _check_output(command, universal_newlines=True)800 output = _check_output(command, universal_newlines=True)
796 data = json.loads(output)801 data = json.loads(output)

Subscribers

People subscribed via source and target branches