Add limit negation to VM list
When using the "state", "node", or "tag" arguments to a VM list, add support for a "negate" flag to look for all VMs *not in* the state, node, or tag state.
This commit is contained in:
@ -354,7 +354,7 @@ def vm_state(zkhandler, vm):
|
||||
"""
|
||||
Return the state of virtual machine VM.
|
||||
"""
|
||||
retflag, retdata = pvc_vm.get_list(zkhandler, None, None, None, vm, is_fuzzy=False)
|
||||
retflag, retdata = pvc_vm.get_list(zkhandler, None, None, None, vm, is_fuzzy=False, negate=False)
|
||||
|
||||
if retflag:
|
||||
if retdata:
|
||||
@ -383,7 +383,7 @@ def vm_node(zkhandler, vm):
|
||||
"""
|
||||
Return the current node of virtual machine VM.
|
||||
"""
|
||||
retflag, retdata = pvc_vm.get_list(zkhandler, None, None, None, vm, is_fuzzy=False)
|
||||
retflag, retdata = pvc_vm.get_list(zkhandler, None, None, None, vm, is_fuzzy=False, negate=False)
|
||||
|
||||
if retflag:
|
||||
if retdata:
|
||||
@ -437,11 +437,11 @@ def vm_console(zkhandler, vm, lines=None):
|
||||
|
||||
@pvc_common.Profiler(config)
|
||||
@ZKConnection(config)
|
||||
def vm_list(zkhandler, node=None, state=None, tag=None, limit=None, is_fuzzy=True):
|
||||
def vm_list(zkhandler, node=None, state=None, tag=None, limit=None, is_fuzzy=True, negate=False):
|
||||
"""
|
||||
Return a list of VMs with limit LIMIT.
|
||||
"""
|
||||
retflag, retdata = pvc_vm.get_list(zkhandler, node, state, tag, limit, is_fuzzy)
|
||||
retflag, retdata = pvc_vm.get_list(zkhandler, node, state, tag, limit, is_fuzzy, negate)
|
||||
|
||||
if retflag:
|
||||
if retdata:
|
||||
@ -880,7 +880,7 @@ def vm_flush_locks(zkhandler, vm):
|
||||
"""
|
||||
Flush locks of a (stopped) VM.
|
||||
"""
|
||||
retflag, retdata = pvc_vm.get_list(zkhandler, None, None, None, vm, is_fuzzy=False)
|
||||
retflag, retdata = pvc_vm.get_list(zkhandler, None, None, None, vm, is_fuzzy=False, negate=False)
|
||||
|
||||
if retdata[0].get('state') not in ['stop', 'disable']:
|
||||
return {"message": "VM must be stopped to flush locks"}, 400
|
||||
|
Reference in New Issue
Block a user