Avoid migration to invalid target_nodes

This commit is contained in:
Joshua Boniface 2019-10-17 12:16:21 -04:00
parent 8690d40927
commit 53dc343ea2
1 changed files with 6 additions and 0 deletions

View File

@ -425,6 +425,9 @@ def move_vm(zk_conn, domain, target_node):
common.stopZKConnection(zk_conn)
return False, 'ERROR: VM "{}" is already running on node "{}".'.format(domain, current_node)
if not target_node:
return False, 'ERROR: Could not find a valid migration target for VM "{}".'.format(domain)
current_vm_state = zkhandler.readdata(zk_conn, '/domains/{}/state'.format(dom_uuid))
if current_vm_state == 'start':
zkhandler.writedata(zk_conn, {
@ -485,6 +488,9 @@ def migrate_vm(zk_conn, domain, target_node, force_migrate, is_cli=False):
common.stopZKConnection(zk_conn)
return False, 'ERROR: VM "{}" is already running on node "{}".'.format(domain, current_node)
if not target_node:
return False, 'ERROR: Could not find a valid migration target for VM "{}".'.format(domain)
# Don't overwrite an existing last_node when using force_migrate
if last_node and force_migrate:
current_node = last_node