Convert fencing to new ZK schema handler
This commit is contained in:
parent
610f6e8f2c
commit
b94fe88405
|
@ -36,7 +36,7 @@ def fenceNode(node_name, zkhandler, config, logger):
|
||||||
# Wait 5 seconds
|
# Wait 5 seconds
|
||||||
time.sleep(config['keepalive_interval'])
|
time.sleep(config['keepalive_interval'])
|
||||||
# Get the state
|
# Get the state
|
||||||
node_daemon_state = zkhandler.read('/nodes/{}/daemonstate'.format(node_name))
|
node_daemon_state = zkhandler.read(('node.state.daemon', node_name))
|
||||||
# Is it still 'dead'
|
# Is it still 'dead'
|
||||||
if node_daemon_state == 'dead':
|
if node_daemon_state == 'dead':
|
||||||
failcount += 1
|
failcount += 1
|
||||||
|
@ -49,9 +49,9 @@ def fenceNode(node_name, zkhandler, config, logger):
|
||||||
logger.out('Fencing node "{}" via IPMI reboot signal'.format(node_name), state='w')
|
logger.out('Fencing node "{}" via IPMI reboot signal'.format(node_name), state='w')
|
||||||
|
|
||||||
# Get IPMI information
|
# Get IPMI information
|
||||||
ipmi_hostname = zkhandler.read('/nodes/{}/ipmihostname'.format(node_name))
|
ipmi_hostname = zkhandler.read(('node.ipmi.hostname', node_name))
|
||||||
ipmi_username = zkhandler.read('/nodes/{}/ipmiusername'.format(node_name))
|
ipmi_username = zkhandler.read(('node.ipmi.username', node_name))
|
||||||
ipmi_password = zkhandler.read('/nodes/{}/ipmipassword'.format(node_name))
|
ipmi_password = zkhandler.read(('node.ipmi.password', node_name))
|
||||||
|
|
||||||
# Shoot it in the head
|
# Shoot it in the head
|
||||||
fence_status = rebootViaIPMI(ipmi_hostname, ipmi_username, ipmi_password, logger)
|
fence_status = rebootViaIPMI(ipmi_hostname, ipmi_username, ipmi_password, logger)
|
||||||
|
@ -62,11 +62,11 @@ def fenceNode(node_name, zkhandler, config, logger):
|
||||||
if node_name in config['coordinators']:
|
if node_name in config['coordinators']:
|
||||||
logger.out('Forcing secondary status for node "{}"'.format(node_name), state='i')
|
logger.out('Forcing secondary status for node "{}"'.format(node_name), state='i')
|
||||||
zkhandler.write([
|
zkhandler.write([
|
||||||
('/nodes/{}/routerstate'.format(node_name), 'secondary')
|
(('node.state.router', node_name), 'secondary')
|
||||||
])
|
])
|
||||||
if zkhandler.read('/config/primary_node') == node_name:
|
if zkhandler.read('base.config.primary_node') == node_name:
|
||||||
zkhandler.write([
|
zkhandler.write([
|
||||||
('/config/primary_node', 'none')
|
('base.config.primary_node', 'none')
|
||||||
])
|
])
|
||||||
|
|
||||||
# If the fence succeeded and successful_fence is migrate
|
# If the fence succeeded and successful_fence is migrate
|
||||||
|
@ -83,11 +83,11 @@ def migrateFromFencedNode(zkhandler, node_name, config, logger):
|
||||||
logger.out('Migrating VMs from dead node "{}" to new hosts'.format(node_name), state='i')
|
logger.out('Migrating VMs from dead node "{}" to new hosts'.format(node_name), state='i')
|
||||||
|
|
||||||
# Get the list of VMs
|
# Get the list of VMs
|
||||||
dead_node_running_domains = zkhandler.read('/nodes/{}/runningdomains'.format(node_name)).split()
|
dead_node_running_domains = zkhandler.read(('node.running_domains', node_name)).split()
|
||||||
|
|
||||||
# Set the node to a custom domainstate so we know what's happening
|
# Set the node to a custom domainstate so we know what's happening
|
||||||
zkhandler.write([
|
zkhandler.write([
|
||||||
('/nodes/{}/domainstate'.format(node_name), 'fence-flush')
|
(('node.state.domain', node_name), 'fence-flush')
|
||||||
])
|
])
|
||||||
|
|
||||||
# Migrate a VM after a flush
|
# Migrate a VM after a flush
|
||||||
|
@ -99,15 +99,15 @@ def migrateFromFencedNode(zkhandler, node_name, config, logger):
|
||||||
if target_node is not None:
|
if target_node is not None:
|
||||||
logger.out('Migrating VM "{}" to node "{}"'.format(dom_uuid, target_node), state='i')
|
logger.out('Migrating VM "{}" to node "{}"'.format(dom_uuid, target_node), state='i')
|
||||||
zkhandler.write([
|
zkhandler.write([
|
||||||
('/domains/{}/state'.format(dom_uuid), 'start'),
|
(('domain.state', dom_uuid), 'start'),
|
||||||
('/domains/{}/node'.format(dom_uuid), target_node),
|
(('domain.node', dom_uuid), target_node),
|
||||||
('/domains/{}/lastnode'.format(dom_uuid), node_name)
|
(('domain.last_node', dom_uuid), node_name),
|
||||||
])
|
])
|
||||||
else:
|
else:
|
||||||
logger.out('No target node found for VM "{}"; VM will autostart on next unflush/ready of current node'.format(dom_uuid), state='i')
|
logger.out('No target node found for VM "{}"; VM will autostart on next unflush/ready of current node'.format(dom_uuid), state='i')
|
||||||
zkhandler.write({
|
zkhandler.write({
|
||||||
('/domains/{}/state'.format(dom_uuid), 'stopped'),
|
(('domain.state', dom_uuid), 'stopped'),
|
||||||
('/domains/{}/node_autostart'.format(dom_uuid), 'True')
|
(('domain.meta.autostart', dom_uuid), 'True'),
|
||||||
})
|
})
|
||||||
|
|
||||||
# Loop through the VMs
|
# Loop through the VMs
|
||||||
|
@ -116,7 +116,7 @@ def migrateFromFencedNode(zkhandler, node_name, config, logger):
|
||||||
|
|
||||||
# Set node in flushed state for easy remigrating when it comes back
|
# Set node in flushed state for easy remigrating when it comes back
|
||||||
zkhandler.write([
|
zkhandler.write([
|
||||||
('/nodes/{}/domainstate'.format(node_name), 'flushed')
|
(('node.state.domain', node_name), 'flushed')
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue