Properly handle empty node limit

This commit is contained in:
Joshua Boniface 2020-01-05 13:42:23 -05:00
parent ef293b7778
commit 8cc20fbcfb
1 changed files with 4 additions and 4 deletions

View File

@ -439,8 +439,8 @@ def move_vm(zk_conn, domain, target_node):
return False, 'ERROR: Specified node "{}" is invalid.'.format(target_node) return False, 'ERROR: Specified node "{}" is invalid.'.format(target_node)
# Check if node is within the limit # Check if node is within the limit
node_limit = zkhandler.readdata(zk_conn, '/domains/{}/node_limit'.format(dom_uuid)).split(',') node_limit = zkhandler.readdata(zk_conn, '/domains/{}/node_limit'.format(dom_uuid))
if node_limit and target_node not in node_limit: if node_limit and target_node not in node_limit.split(','):
return False, 'ERROR: Specified node "{}" is not in the allowed list of nodes for VM "{}".'.format(target_node, domain) return False, 'ERROR: Specified node "{}" is not in the allowed list of nodes for VM "{}".'.format(target_node, domain)
# Verify if node is current node # Verify if node is current node
@ -500,8 +500,8 @@ def migrate_vm(zk_conn, domain, target_node, force_migrate, is_cli=False):
return False, 'ERROR: Specified node "{}" is invalid.'.format(target_node) return False, 'ERROR: Specified node "{}" is invalid.'.format(target_node)
# Check if node is within the limit # Check if node is within the limit
node_limit = zkhandler.readdata(zk_conn, '/domains/{}/node_limit'.format(dom_uuid)).split(',') node_limit = zkhandler.readdata(zk_conn, '/domains/{}/node_limit'.format(dom_uuid))
if node_limit and target_node not in node_limit: if node_limit and target_node not in node_limit.split(','):
return False, 'ERROR: Specified node "{}" is not in the allowed list of nodes for VM "{}".'.format(target_node, domain) return False, 'ERROR: Specified node "{}" is not in the allowed list of nodes for VM "{}".'.format(target_node, domain)
# Verify if node is current node # Verify if node is current node