Correct some bugs and remove this_node aspect

Addresses #9
This commit is contained in:
2018-07-18 02:30:50 -04:00
parent b12fc956c7
commit 8e7c883d72
2 changed files with 9 additions and 15 deletions

11
pvc.py
View File

@ -354,12 +354,12 @@ def verifyNode(zk_conn, node):
click.echo('ERROR: No node named "{}" is present in the cluster.'.format(node))
exit(1)
def findTargetHypervisor(zk_conn, search_field, dom_uuid, this_node)
def findTargetHypervisor(zk_conn, search_field, dom_uuid)
if search_field == 'mem':
return findTargetHypervisorMem(zk_conn, dom_uuid, this_node)
return findTargetHypervisorMem(zk_conn, dom_uuid)
return None
def findTargetHypervisorMem(zk_conn, dom_uuid, this_node):
def findTargetHypervisorMem(zk_conn, dom_uuid):
# Find a target node
most_allocfree = 0
target_hypervisor = None
@ -367,9 +367,6 @@ def findTargetHypervisorMem(zk_conn, dom_uuid, this_node):
hypervisor_list = zkhandler.listchildren(zk_conn, '/nodes')
current_hypervisor = zkhandler.readdata(zk_conn, '/domains/{}/hypervisor'.format(dom_uuid))
if current_hypervisor != this_node:
continue
for hypervisor in hypervisor_list:
daemon_state = zkhandler.readdata(zk_conn, '/nodes/{}/daemonstate'.format(hypervisor))
domain_state = zkhandler.readdata(zk_conn, '/nodes/{}/domainstate'.format(hypervisor))
@ -983,7 +980,7 @@ def move_vm(domain, target_hypervisor):
current_hypervisor = zk_conn.get('/domains/{}/hypervisor'.format(dom_uuid))[0].decode('ascii')
if target_hypervisor == None:
target_hypervisor = findTargetHypervisor(zk_conn, 'mem', dom_uuid, current_hypervisor)
target_hypervisor = findTargetHypervisor(zk_conn, 'mem', dom_uuid)
else:
if target_hypervisor == current_hypervisor:
click.echo('ERROR: The VM "{}" is already running on hypervisor "{}".'.format(dom_uuid, current_hypervisor))