~corey.bryant/charms/trusty/cinder-ceph/charm-proof-next

« back to all changes in this revision

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

  • Committer: James Page
  • Date: 2014-04-02 08:01:16 UTC
  • Revision ID: james.page@canonical.com-20140402080116-kam8046iathmx7el
Resync helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
194
194
        return None
195
195
 
196
196
 
197
 
def restart_on_change(restart_map):
 
197
def restart_on_change(restart_map, stopstart=False):
198
198
    """Restart services based on configuration files changing
199
199
 
200
200
    This function is used a decorator, for example
219
219
            for path in restart_map:
220
220
                if checksums[path] != file_hash(path):
221
221
                    restarts += restart_map[path]
222
 
            for service_name in list(OrderedDict.fromkeys(restarts)):
223
 
                service('restart', service_name)
 
222
            services_list = list(OrderedDict.fromkeys(restarts))
 
223
            if not stopstart:
 
224
                for service_name in services_list:
 
225
                    service('restart', service_name)
 
226
            else:
 
227
                for action in ['stop', 'start']:
 
228
                    for service_name in services_list:
 
229
                        service(action, service_name)
224
230
        return wrapped_f
225
231
    return wrap
226
232