Exemplo n.º 1
0
def maintenance_mode(enable):
    """Enable/disable pacemaker's maintenance mode"""

    log('Setting maintenance-mode to %s' % enable, level=INFO)

    try:
        current_state = pcmk.get_property('maintenance-mode').strip().lower()
    except pcmk.PropertyNotFound:
        current_state = 'false'

    current_state = True if current_state == 'true' else False
    log('Is maintenance-mode currently enabled? %s' % current_state,
        level=DEBUG)
    if current_state != enable:
        pcmk.set_property('maintenance-mode', str(enable).lower())
    else:
        log('Desired value for maintenance-mode is already set', level=DEBUG)
Exemplo n.º 2
0
def maintenance_mode(enable):
    """Enable/disable pacemaker's maintenance mode"""

    log('Setting maintenance-mode to %s' % enable, level=INFO)

    try:
        current_state = pcmk.get_property('maintenance-mode').strip().lower()
    except pcmk.PropertyNotFound:
        current_state = 'false'

    current_state = True if current_state == 'true' else False
    log('Is maintenance-mode currently enabled? %s' % current_state,
        level=DEBUG)
    if current_state != enable:
        pcmk.set_property('maintenance-mode', str(enable).lower())
    else:
        log('Desired value for maintenance-mode is already set', level=DEBUG)
Exemplo n.º 3
0
def config_changed():

    # if we are paused, delay doing any config changed hooks.
    # It is forced on the resume.
    if is_unit_paused_set():
        log("Unit is pause or upgrading. Skipping config_changed", "WARN")
        return

    setup_ocf_files()

    if config('prefer-ipv6'):
        assert_charm_supports_ipv6()

    corosync_key = config('corosync_key')
    if not corosync_key:
        message = 'No Corosync key supplied, cannot proceed'
        status_set('blocked', message)
        raise Exception(message)

    enable_lsb_services('pacemaker')

    for rid in relation_ids('hanode'):
        hanode_relation_joined(rid)

    status_set('maintenance', "Setting up corosync")
    if configure_corosync():
        try_pcmk_wait()
        if is_leader():
            run_initial_setup()

    update_nrpe_config()

    cfg = config()
    if (is_leader()
            and cfg.previous('maintenance-mode') != cfg['maintenance-mode']):
        maintenance_mode(cfg['maintenance-mode'])

    if config('no_quorum_policy').lower() in [
            'ignore', 'freeze', 'stop', 'suicide'
    ]:
        pcmk.set_property("no-quorum-policy",
                          config('no_quorum_policy').lower())
    else:
        message = 'Invalid setting for no_quorum_policy'
        status_set('blocked', message)
    status_set(*assess_status_helper())
Exemplo n.º 4
0
 def test_set_property(self, mock_check_output):
     pcmk.set_property('maintenance-mode', 'false')
     mock_check_output.assert_called_with(['crm', 'configure', 'property',
                                           'maintenance-mode=false'],
                                          universal_newlines=True)
Exemplo n.º 5
0
 def test_set_property(self, mock_check_output):
     pcmk.set_property('maintenance-mode', 'false')
     mock_check_output.assert_called_with(['crm', 'configure', 'property',
                                           'maintenance-mode=false'],
                                          universal_newlines=True)