oneclient: add get_vm_by_id function

master
Justin Riley 2016-07-19 14:05:28 -04:00
parent 38d9e539fb
commit b8b9dab77c
1 changed files with 9 additions and 0 deletions

View File

@ -12,3 +12,12 @@ class OneClient(object):
def vms(self):
self._vm_pool.info(filter=-1)
return self._vm_pool
def get_vm_by_id(self, vm_id):
if type(vm_id) != int or vm_id < 0:
raise TypeError('vm_id must be an integer >= 0')
self._vm_pool.info(filter=-1,
range_start=vm_id,
range_end=vm_id,
vm_state=-2)
return self._vm_pool[0] if self._vm_pool else None