Allow enforcement of live migration
Provides a CLI and API argument to force live migration, which triggers a new VM state "migrate-live". The node daemon VMInstance during migrate will read this flag from the state and, if enforced, will not trigger a shutdown migration. Closes #95
This commit is contained in:
@ -203,19 +203,20 @@ def vm_state(config, vm, target_state, wait=False):
|
||||
|
||||
return retstatus, response.json()['message']
|
||||
|
||||
def vm_node(config, vm, target_node, action, force=False, wait=False):
|
||||
def vm_node(config, vm, target_node, action, force=False, wait=False, force_live=False):
|
||||
"""
|
||||
Modify the current node of VM via {action}
|
||||
|
||||
API endpoint: POST /vm/{vm}/node
|
||||
API arguments: node={target_node}, action={action}, force={force}, wait={wait}
|
||||
API arguments: node={target_node}, action={action}, force={force}, wait={wait}, force_live={force_live}
|
||||
API schema: {"message":"{data}"}
|
||||
"""
|
||||
params={
|
||||
'node': target_node,
|
||||
'action': action,
|
||||
'force': str(force).lower(),
|
||||
'wait': str(wait).lower()
|
||||
'wait': str(wait).lower(),
|
||||
'force_live': str(force_live).lower()
|
||||
}
|
||||
response = call_api(config, 'post', '/vm/{vm}/node'.format(vm=vm), params=params)
|
||||
|
||||
|
@ -868,13 +868,17 @@ def vm_disable(domain):
|
||||
'-w', '--wait', 'wait', is_flag=True, default=False,
|
||||
help='Wait for migration to complete before returning.'
|
||||
)
|
||||
@click.option(
|
||||
'--force-live', 'force_live', is_flag=True, default=False,
|
||||
help='Do not fall back to shutdown-based migration if live migration fails.'
|
||||
)
|
||||
@cluster_req
|
||||
def vm_move(domain, target_node, wait):
|
||||
def vm_move(domain, target_node, wait, force_live):
|
||||
"""
|
||||
Permanently move virtual machine DOMAIN, via live migration if running and possible, to another node. DOMAIN may be a UUID or name.
|
||||
"""
|
||||
|
||||
retcode, retmsg = pvc_vm.vm_node(config, domain, target_node, 'move', force=False, wait=wait)
|
||||
retcode, retmsg = pvc_vm.vm_node(config, domain, target_node, 'move', force=False, wait=wait, force_live=force_live)
|
||||
cleanup(retcode, retmsg)
|
||||
|
||||
###############################################################################
|
||||
@ -896,13 +900,17 @@ def vm_move(domain, target_node, wait):
|
||||
'-w', '--wait', 'wait', is_flag=True, default=False,
|
||||
help='Wait for migration to complete before returning.'
|
||||
)
|
||||
@click.option(
|
||||
'--force-live', 'force_live', is_flag=True, default=False,
|
||||
help='Do not fall back to shutdown-based migration if live migration fails.'
|
||||
)
|
||||
@cluster_req
|
||||
def vm_migrate(domain, target_node, force_migrate, wait):
|
||||
def vm_migrate(domain, target_node, force_migrate, wait, force_live):
|
||||
"""
|
||||
Temporarily migrate running virtual machine DOMAIN, via live migration if possible, to another node. DOMAIN may be a UUID or name. If DOMAIN is not running, it will be started on the target node.
|
||||
"""
|
||||
|
||||
retcode, retmsg = pvc_vm.vm_node(config, domain, target_node, 'migrate', force=force_migrate, wait=wait)
|
||||
retcode, retmsg = pvc_vm.vm_node(config, domain, target_node, 'migrate', force=force_migrate, wait=wait, force_live=force_live)
|
||||
cleanup(retcode, retmsg)
|
||||
|
||||
###############################################################################
|
||||
@ -916,13 +924,17 @@ def vm_migrate(domain, target_node, force_migrate, wait):
|
||||
'-w', '--wait', 'wait', is_flag=True, default=False,
|
||||
help='Wait for migration to complete before returning.'
|
||||
)
|
||||
@click.option(
|
||||
'--force-live', 'force_live', is_flag=True, default=False,
|
||||
help='Do not fall back to shutdown-based migration if live migration fails.'
|
||||
)
|
||||
@cluster_req
|
||||
def vm_unmigrate(domain, wait):
|
||||
def vm_unmigrate(domain, wait, force_live):
|
||||
"""
|
||||
Restore previously migrated virtual machine DOMAIN, via live migration if possible, to its original node. DOMAIN may be a UUID or name. If DOMAIN is not running, it will be started on the target node.
|
||||
"""
|
||||
|
||||
retcode, retmsg = pvc_vm.vm_node(config, domain, None, 'unmigrate', force=False, wait=wait)
|
||||
retcode, retmsg = pvc_vm.vm_node(config, domain, None, 'unmigrate', force=False, wait=wait, force_live=force_live)
|
||||
cleanup(retcode, retmsg)
|
||||
|
||||
###############################################################################
|
||||
|
Reference in New Issue
Block a user