Commit 4d2840b4 by Guba Sándor

driver: adding domain_info return values to all function

parent 9308614f
...@@ -128,6 +128,7 @@ def create(vm_desc): ...@@ -128,6 +128,7 @@ def create(vm_desc):
connection.createXML( connection.createXML(
vm.dump_xml(), libvirt.VIR_DOMAIN_START_PAUSED) vm.dump_xml(), libvirt.VIR_DOMAIN_START_PAUSED)
logging.info("Virtual machine %s is created from xml", vm.name) logging.info("Virtual machine %s is created from xml", vm.name)
return domain_info(vm.name)
@celery.task @celery.task
...@@ -138,6 +139,7 @@ def shutdown(name): ...@@ -138,6 +139,7 @@ def shutdown(name):
''' '''
domain = lookupByName(name) domain = lookupByName(name)
domain.shutdown() domain.shutdown()
return _parse_info(domain.info())
@celery.task @celery.task
...@@ -148,6 +150,7 @@ def delete(name): ...@@ -148,6 +150,7 @@ def delete(name):
''' '''
domain = lookupByName(name) domain = lookupByName(name)
domain.destroy() domain.destroy()
return _parse_info(domain.info())
@celery.task @celery.task
...@@ -198,10 +201,11 @@ def start(name): ...@@ -198,10 +201,11 @@ def start(name):
@req_connection @req_connection
@wrap_libvirtError @wrap_libvirtError
def suspend(name): def suspend(name):
'''Stop virtual machine and save its memory to path. '''Stop virtual machine and keep memory in RAM.
''' '''
domain = lookupByName(name) domain = lookupByName(name)
domain.suspend() domain.suspend()
return _parse_info(domain.info())
@celery.task @celery.task
...@@ -217,10 +221,11 @@ def save(name, path): ...@@ -217,10 +221,11 @@ def save(name, path):
@celery.task @celery.task
@req_connection @req_connection
@wrap_libvirtError @wrap_libvirtError
def restore(path): def restore(path, name):
'''Restore a saved virtual machine '''Restore a saved virtual machine
from the memory image stored at path.''' from the memory image stored at path.'''
connection.restore(path) connection.restore(path)
return domain_info(name)
@celery.task @celery.task
...@@ -231,6 +236,7 @@ def resume(name): ...@@ -231,6 +236,7 @@ def resume(name):
''' '''
domain = lookupByName(name) domain = lookupByName(name)
domain.resume() domain.resume()
return _parse_info(domain.info())
@celery.task @celery.task
...@@ -241,6 +247,7 @@ def reset(name): ...@@ -241,6 +247,7 @@ def reset(name):
''' '''
domain = lookupByName(name) domain = lookupByName(name)
domain.reset() domain.reset()
return _parse_info(domain.info())
@celery.task @celery.task
...@@ -251,6 +258,7 @@ def reboot(name): ...@@ -251,6 +258,7 @@ def reboot(name):
''' '''
domain = lookupByName(name) domain = lookupByName(name)
domain.reboot() domain.reboot()
return _parse_info(domain.info())
@celery.task @celery.task
...@@ -277,6 +285,15 @@ def node_info(): ...@@ -277,6 +285,15 @@ def node_info():
return dict(zip(keys, values)) return dict(zip(keys, values))
def _parse_info(values):
'''Parse libvirt domain info into dict'''
keys = ['state', 'maxmem', 'memory', 'virtcpunum', 'cputime']
info = dict(zip(keys, values))
# Change state to proper ENUM
info['state'] = state_dict[info['state']]
return info
@celery.task @celery.task
@req_connection @req_connection
@wrap_libvirtError @wrap_libvirtError
...@@ -288,13 +305,8 @@ def domain_info(name): ...@@ -288,13 +305,8 @@ def domain_info(name):
virtcpunum the number of virtual CPUs for the domain virtcpunum the number of virtual CPUs for the domain
cputime the CPU time used in nanoseconds cputime the CPU time used in nanoseconds
''' '''
keys = ['state', 'maxmem', 'memory', 'virtcpunum', 'cputime']
dom = lookupByName(name) dom = lookupByName(name)
values = dom.info() return _parse_info(dom.info())
# Change state to proper ENUM
info = dict(zip(keys, values))
info['state'] = state_dict[info['state']]
return info
@celery.task @celery.task
...@@ -380,3 +392,4 @@ def migrate(name, host, live=False): ...@@ -380,3 +392,4 @@ def migrate(name, host, live=False):
flags=flags, flags=flags,
dname=name, dname=name,
bandwidth=0) bandwidth=0)
#return _parse_info(domain.info())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment