def config_changed(): 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() configure_cluster_global() configure_monitor_host() configure_stonith() update_nrpe_config() cfg = config() if (is_leader() and cfg.previous('maintenance-mode') != cfg['maintenance-mode']): maintenance_mode(cfg['maintenance-mode'])
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())
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() failure_timeout = config('failure_timeout') configure_cluster_global(failure_timeout) configure_monitor_host() configure_stonith() update_nrpe_config() cfg = config() if (is_leader() and cfg.previous('maintenance-mode') != cfg['maintenance-mode']): maintenance_mode(cfg['maintenance-mode'])
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() configure_cluster_global() configure_monitor_host() configure_stonith() update_nrpe_config() cfg = config() if (is_leader() and cfg.previous('maintenance-mode') != cfg['maintenance-mode']): maintenance_mode(cfg['maintenance-mode'])
def test_maintenance_mode(self, mock_get_property, mock_set_property): # enable maintenance-mode mock_get_property.return_value = 'false\n' utils.maintenance_mode(True) mock_get_property.assert_called_with('maintenance-mode') mock_set_property.assert_called_with('maintenance-mode', 'true') mock_get_property.reset_mock() mock_set_property.reset_mock() mock_get_property.return_value = 'true\n' utils.maintenance_mode(True) mock_get_property.assert_called_with('maintenance-mode') mock_set_property.assert_not_called() # disable maintenance-mode mock_get_property.return_value = 'true\n' utils.maintenance_mode(False) mock_get_property.assert_called_with('maintenance-mode') mock_set_property.assert_called_with('maintenance-mode', 'false') mock_get_property.reset_mock() mock_set_property.reset_mock() mock_get_property.return_value = 'false\n' utils.maintenance_mode(False) mock_get_property.assert_called_with('maintenance-mode') mock_set_property.assert_not_called()