~openstack-charmers-next/charms/xenial/nova-compute/trunk

« back to all changes in this revision

Viewing changes to tests/charmhelpers/contrib/amulet/utils.py

  • Committer: Edward Hope-Morley
  • Date: 2016-03-24 11:18:41 UTC
  • mto: This revision was merged to the branch mainline in revision 211.
  • Revision ID: edward.hope-morley@canonical.com-20160324111841-99ruo5hjzrpqktlx
Add hardening support

Add charmhelpers.contrib.hardening and calls to install,
config-changed, upgrade-charm and update-status hooks.
Also add new config option to allow one or more hardening
modules to be applied at runtime.

Change-Id: I525c15a14662175f2a68cdcd25a3ab2c92237850

Show diffs side-by-side

added added

removed removed

Lines of Context:
782
782
 
783
783
# amulet juju action helpers:
784
784
    def run_action(self, unit_sentry, action,
785
 
                   _check_output=subprocess.check_output):
 
785
                   _check_output=subprocess.check_output,
 
786
                   params=None):
786
787
        """Run the named action on a given unit sentry.
787
788
 
 
789
        params a dict of parameters to use
788
790
        _check_output parameter is used for dependency injection.
789
791
 
790
792
        @return action_id.
791
793
        """
792
794
        unit_id = unit_sentry.info["unit_name"]
793
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
799
        self.log.info("Running command: %s\n" % " ".join(command))
795
800
        output = _check_output(command, universal_newlines=True)
796
801
        data = json.loads(output)