~gandelman-a/charms/precise/ceph/ocf

« back to all changes in this revision

Viewing changes to hooks/hooks.py

  • Committer: Andres Rodriguez
  • Date: 2013-02-13 23:44:37 UTC
  • Revision ID: andreserl@ubuntu.com-20130213234437-89nopxc415mp23p5
Installs openstack|ceph-resource-agents before trying to configure any otherwise it causes error
Checks whether the services are running and started before trying to cleanup. If they are don't do anything.

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
                       'Related to {} ha services'.format(len(relids)))
198
198
        return
199
199
 
 
200
    if True in [ra.startswith('ocf:openstack')
 
201
                for ra in resources.itervalues()]:
 
202
        utils.install('openstack-resource-agents')
 
203
    if True in [ra.startswith('ocf:ceph')
 
204
                for ra in resources.itervalues()]:
 
205
        utils.install('ceph-resource-agents')
 
206
 
200
207
    utils.juju_log('INFO', 'Configuring and restarting corosync')
201
208
    emit_corosync_conf()
202
209
    restart_corosync()
215
222
    utils.juju_log('INFO', 'Configuring Resources')
216
223
    utils.juju_log('INFO', str(resources))
217
224
 
218
 
    if True in [ra.startswith('ocf:openstack')
219
 
                for ra in resources.itervalues()]:
220
 
        utils.install('openstack-resource-agents')
221
 
    if True in [ra.startswith('ocf:ceph')
222
 
                for ra in resources.itervalues()]:
223
 
        utils.install('ceph-resource-agents')
224
 
 
225
225
    for res_name, res_type in resources.iteritems():
226
226
        # disable the service we are going to put in HA
227
227
        if res_type.split(':')[0] == "lsb":
288
288
            utils.juju_log('INFO', '%s' % cmd)
289
289
 
290
290
    for res_name, res_type in resources.iteritems():
291
 
        # TODO: This should first check that the resources is running
292
291
        if len(init_services) != 0 and res_name in init_services:
293
 
            # If the resource is in HA already, and it is a service, restart
294
 
            # the pcmk resource as the config file might have changed by the
295
 
            # principal charm
296
 
            cmd = 'crm resource restart %s' % res_name
297
 
            pcmk.commit(cmd)
298
 
            # Just in case, cleanup the resources to ensure they get started
299
 
            # in case they failed for some unrelated reason.
300
 
            cmd = 'crm resource cleanup %s' % res_name
301
 
            pcmk.commit(cmd)
 
292
            # Checks that the resources are running and started.
 
293
            if not pcmk.crm_res_running(res_name):
 
294
                # If the resource is in HA already, and it is a service, restart
 
295
                # the pcmk resource as the config file might have changed by the
 
296
                # principal charm
 
297
                #cmd = 'crm resource restart %s' % res_name
 
298
                #pcmk.commit(cmd)
 
299
                # Just in case, cleanup the resources to ensure they get started
 
300
                # in case they failed for some unrelated reason.
 
301
                cmd = 'crm resource cleanup %s' % res_name
 
302
                pcmk.commit(cmd)
302
303
 
303
304
    for rel_id in utils.relation_ids('ha'):
304
305
        utils.relation_set(rid=rel_id,