~nicopace/charms/trusty/rabbitmq-server/all-tests

« back to all changes in this revision

Viewing changes to hooks/rabbitmq_server_relations.py

  • Committer: Matt Bruzek
  • Date: 2014-09-11 22:07:20 UTC
  • mfrom: (52.6.3 rabbitmq-server)
  • Revision ID: matthew.bruzek@canonical.com-20140911220720-6squn0p0tx89rp4p
[niedbalski] Only restarts and updates nrpe checks if the HA relation has been made and the node is marked as active.

Show diffs side-by-side

added added

removed removed

Lines of Context:
511
511
    open_port(ssl_port)
512
512
 
513
513
 
 
514
def restart_rabbit_update_nrpe():
 
515
    service_restart('rabbitmq-server')
 
516
    update_nrpe_checks()
 
517
 
514
518
@hooks.hook('config-changed')
515
519
def config_changed():
516
520
    # Add archive source if provided
538
542
 
539
543
    configure_rabbit_ssl()
540
544
 
541
 
    if eligible_leader('res_rabbitmq_vip') or \
542
 
       config('ha-vip-only') is True:
543
 
        service_restart('rabbitmq-server')
 
545
    if is_relation_made("ha"):
 
546
        ha_is_active_active = config("ha-vip-only")
544
547
 
545
 
    update_nrpe_checks()
 
548
        if ha_is_active_active:
 
549
            restart_rabbit_update_nrpe()
 
550
        else:
 
551
            if eligible_leader('res_rabbitmq_vip'):
 
552
                restart_rabbit_update_nrpe()
 
553
            else:
 
554
                log("hacluster relation is present but this node is not active"
 
555
                    " skipping update nrpe checks")
 
556
    else:
 
557
        restart_rabbit_update_nrpe()
546
558
 
547
559
 
548
560
def pre_install_hooks():