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:
2020-06-06 11:49:21 -04:00
parent b5434ba744
commit ce60836c34
6 changed files with 72 additions and 32 deletions

View File

@ -1365,7 +1365,8 @@ class API_VM_Node(Resource):
{ 'name': 'action', 'choices': ('migrate', 'unmigrate', 'move'), 'helptext': "A valid action must be specified", 'required': True },
{ 'name': 'node' },
{ 'name': 'force' },
{ 'name': 'wait' }
{ 'name': 'wait' },
{ 'name': 'force_live' }
])
@Authenticator
def post(self, vm, reqargs):
@ -1396,6 +1397,10 @@ class API_VM_Node(Resource):
name: wait
type: boolean
description: Whether to block waiting for the migration to complete
- in: query
name: force_live
type: boolean
description: Whether to enforce live migration and disable shutdown-based fallback migration
responses:
200:
description: OK
@ -1412,13 +1417,14 @@ class API_VM_Node(Resource):
node = reqargs.get('node', None)
force = bool(strtobool(reqargs.get('force', 'false')))
wait = bool(strtobool(reqargs.get('wait', 'false')))
force_live = bool(strtobool(reqargs.get('force_live', 'false')))
if action == 'move':
return api_helper.vm_move(vm, node, wait)
return api_helper.vm_move(vm, node, wait, force_live)
if action == 'migrate':
return api_helper.vm_migrate(vm, node, force, wait)
return api_helper.vm_migrate(vm, node, force, wait, force_live)
if action == 'unmigrate':
return api_helper.vm_unmigrate(vm, wait)
return api_helper.vm_unmigrate(vm, wait, force_live)
abort(400)
api.add_resource(API_VM_Node, '/vm/<vm>/node')

View File

@ -661,12 +661,12 @@ def vm_disable(name):
}
return output, retcode
def vm_move(name, node, wait):
def vm_move(name, node, wait, force_live):
"""
Move a VM to another node.
"""
zk_conn = pvc_common.startZKConnection(config['coordinators'])
retflag, retdata = pvc_vm.move_vm(zk_conn, name, node, wait)
retflag, retdata = pvc_vm.move_vm(zk_conn, name, node, wait, force_live)
pvc_common.stopZKConnection(zk_conn)
if retflag:
@ -679,12 +679,12 @@ def vm_move(name, node, wait):
}
return output, retcode
def vm_migrate(name, node, flag_force, wait):
def vm_migrate(name, node, flag_force, wait, force_live):
"""
Temporarily migrate a VM to another node.
"""
zk_conn = pvc_common.startZKConnection(config['coordinators'])
retflag, retdata = pvc_vm.migrate_vm(zk_conn, name, node, flag_force, wait)
retflag, retdata = pvc_vm.migrate_vm(zk_conn, name, node, flag_force, wait, force_live)
pvc_common.stopZKConnection(zk_conn)
if retflag:
@ -697,12 +697,12 @@ def vm_migrate(name, node, flag_force, wait):
}
return output, retcode
def vm_unmigrate(name, wait):
def vm_unmigrate(name, wait, force_live):
"""
Unmigrate a migrated VM.
"""
zk_conn = pvc_common.startZKConnection(config['coordinators'])
retflag, retdata = pvc_vm.unmigrate_vm(zk_conn, name, wait)
retflag, retdata = pvc_vm.unmigrate_vm(zk_conn, name, wait, force_live)
pvc_common.stopZKConnection(zk_conn)
if retflag: