Store list of RBD disks in ZK
Store a basic list of RBD disks in Zookeeper for access by the node subsystem to handle RBD locks. This avoids the need to implement complex parsing logic inside the fencing configuration (or elsewhere). Also handle a malformed XML content properly during VM define.
This commit is contained in:
parent
e263a05237
commit
6426607769
|
@ -108,7 +108,10 @@ def getDomainName(zk_conn, domain):
|
||||||
#
|
#
|
||||||
def define_vm(zk_conn, config_data, target_node, selector):
|
def define_vm(zk_conn, config_data, target_node, selector):
|
||||||
# Parse the XML data
|
# Parse the XML data
|
||||||
|
try:
|
||||||
parsed_xml = lxml.objectify.fromstring(config_data)
|
parsed_xml = lxml.objectify.fromstring(config_data)
|
||||||
|
except:
|
||||||
|
return False, 'ERROR: Failed to parse XML data.'
|
||||||
dom_uuid = parsed_xml.uuid.text
|
dom_uuid = parsed_xml.uuid.text
|
||||||
dom_name = parsed_xml.name.text
|
dom_name = parsed_xml.name.text
|
||||||
|
|
||||||
|
@ -118,7 +121,14 @@ def define_vm(zk_conn, config_data, target_node, selector):
|
||||||
# Verify node is valid
|
# Verify node is valid
|
||||||
valid_node = common.verifyNode(zk_conn, target_node)
|
valid_node = common.verifyNode(zk_conn, target_node)
|
||||||
if not valid_node:
|
if not valid_node:
|
||||||
return False, 'Specified node "{}" is invalid.'.format(target_node)
|
return False, 'ERROR: Specified node "{}" is invalid.'.format(target_node)
|
||||||
|
|
||||||
|
# Obtain the RBD disk list using the common functions
|
||||||
|
ddisks = common.getDomainDisks(parsed_xml)
|
||||||
|
rbd_list = []
|
||||||
|
for disk in ddisks:
|
||||||
|
if disk['type'] == 'rbd':
|
||||||
|
rbd_list.append(disk['name'])
|
||||||
|
|
||||||
# Add the new domain to Zookeeper
|
# Add the new domain to Zookeeper
|
||||||
zkhandler.writedata(zk_conn, {
|
zkhandler.writedata(zk_conn, {
|
||||||
|
@ -128,6 +138,7 @@ def define_vm(zk_conn, config_data, target_node, selector):
|
||||||
'/domains/{}/lastnode'.format(dom_uuid): '',
|
'/domains/{}/lastnode'.format(dom_uuid): '',
|
||||||
'/domains/{}/failedreason'.format(dom_uuid): '',
|
'/domains/{}/failedreason'.format(dom_uuid): '',
|
||||||
'/domains/{}/consolelog'.format(dom_uuid): '',
|
'/domains/{}/consolelog'.format(dom_uuid): '',
|
||||||
|
'/domains/{}/rbdlist'.format(dom_uuid): ','.join(rbd_list),
|
||||||
'/domains/{}/xml'.format(dom_uuid): config_data
|
'/domains/{}/xml'.format(dom_uuid): config_data
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue