~openstack-charmers-archive/charms/precise/ceph-radosgw/old-1410

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/core/hookenv.py

  • Committer: james.page at ubuntu
  • Date: 2014-10-06 22:16:05 UTC
  • mfrom: (26.1.5 ceph-radosgw)
  • Revision ID: james.page@ubuntu.com-20141006221605-z9wo0l6kj02s4onu
[coreycb,r=james-page] Add amulet tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
486
486
            hooks.execute(sys.argv)
487
487
    """
488
488
 
489
 
    def __init__(self):
 
489
    def __init__(self, config_save=True):
490
490
        super(Hooks, self).__init__()
491
491
        self._hooks = {}
 
492
        self._config_save = config_save
492
493
 
493
494
    def register(self, name, function):
494
495
        """Register a hook"""
499
500
        hook_name = os.path.basename(args[0])
500
501
        if hook_name in self._hooks:
501
502
            self._hooks[hook_name]()
502
 
            cfg = config()
503
 
            if cfg.implicit_save:
504
 
                cfg.save()
 
503
            if self._config_save:
 
504
                cfg = config()
 
505
                if cfg.implicit_save:
 
506
                    cfg.save()
505
507
        else:
506
508
            raise UnregisteredHookError(hook_name)
507
509