Use build-in selector and respect limits in client

Use the new built-in selector option, as well as respecting node limits,
when performing migrate or move actions on a VM via the clients.
This commit is contained in:
2019-10-12 01:45:44 -04:00
parent 8dc0c8f0ac
commit e5393082b6
5 changed files with 83 additions and 74 deletions

View File

@ -338,11 +338,6 @@ def api_vm_node(vm):
node = flask.request.values['node']
else:
node = None
# Get target selector
if 'selector' in flask.request.values:
selector = flask.request.values['selector']
else:
selector = None
# Get permanent flag
if 'permanent' in flask.request.values and flask.request.values['permanent']:
flag_permanent = True
@ -358,9 +353,9 @@ def api_vm_node(vm):
is_migrated = pvcapi.vm_is_migrated(vm)
if action == 'migrate' and not flag_permanent:
return pvcapi.vm_migrate(vm, node, selector, flag_force)
return pvcapi.vm_migrate(vm, node, flag_force)
if action == 'migrate' and flag_permanent:
return pvcapi.vm_move(vm, node, selector)
return pvcapi.vm_move(vm, node)
if action == 'unmigrate' and is_migrated:
return pvcapi.vm_unmigrate(vm)