551
553
return 'Dicts within list are not identical'
557
def run_action(self, unit_sentry, action,
558
_check_output=subprocess.check_output):
559
"""Run the named action on a given unit sentry.
561
_check_output parameter is used for dependency injection.
565
unit_id = unit_sentry.info["unit_name"]
566
command = ["juju", "action", "do", "--format=json", unit_id, action]
567
self.log.info("Running command: %s\n" % " ".join(command))
568
output = _check_output(command, universal_newlines=True)
569
data = json.loads(output)
570
action_id = data[u'Action queued with id']
573
def wait_on_action(self, action_id, _check_output=subprocess.check_output):
574
"""Wait for a given action, returning if it completed or not.
576
_check_output parameter is used for dependency injection.
578
command = ["juju", "action", "fetch", "--format=json", "--wait=0",
580
output = _check_output(command, universal_newlines=True)
581
data = json.loads(output)
582
return data.get(u"status") == "completed"