def check_debug(self, enabled, mock_config, get_network_address, relation_ids, related_units, relation_get): cfg = {'debug': enabled, 'prefer-ipv6': False, 'corosync_mcastport': '1234', 'corosync_transport': 'udpu', 'corosync_mcastaddr': 'corosync_mcastaddr'} def c(k): return cfg.get(k) mock_config.side_effect = c get_network_address.return_value = "127.0.0.1" relation_ids.return_value = ['foo:1'] related_units.return_value = ['unit-machine-0'] relation_get.return_value = 'iface' conf = utils.get_corosync_conf() if enabled: self.assertEqual(conf['debug'], enabled) else: self.assertFalse('debug' in conf) self.assertTrue(utils.emit_corosync_conf()) with open(utils.COROSYNC_CONF, 'rt') as fd: content = fd.read() if enabled: pattern = 'debug: on\n' else: pattern = 'debug: off\n' matches = re.findall(pattern, content, re.M) self.assertEqual(len(matches), 2, str(matches))
def hanode_relation_departed(relid=None): if config('maintenance-mode'): log('pcmk is in maintenance mode - skip any action', DEBUG) return # Note(aluria): all units will update corosync.conf list of nodes # in the aim of having up to date stored configurations. However, # corosync reloads (or restarts) won't be triggered at this point # (update-ring action will do) if emit_corosync_conf(): log('corosync.conf updated') else: log('corosync.conf not updated')
def _trigger_corosync_update(): # Trigger emit_corosync_conf() and corosync-cfgtool -R # for all the hanode peer units to run relid = relation_ids('hanode') if len(relid) < 1: action_fail('no peer ha nodes') return corosync_update_uuid = uuid.uuid1().hex reldata = {'trigger-corosync-update': corosync_update_uuid} relation_set(relation_id=relid[0], relation_settings=reldata) # Trigger the same logic in the leader (no hanode-relation-changed # hook will be received by self) if (is_update_ring_requested(corosync_update_uuid) and emit_corosync_conf()): cmd = 'corosync-cfgtool -R' pcmk.commit(cmd)