Commit 3a347f2c by Guba Sándor

fixing wrapper and add logging

parent 2543f1aa
...@@ -49,8 +49,9 @@ def req_connection(original_function, *args, **kw): ...@@ -49,8 +49,9 @@ def req_connection(original_function, *args, **kw):
@decorator @decorator
def wrap_libvirtError(original_function, *args, **kw): def wrap_libvirtError(original_function, *args, **kw):
try: try:
original_function(*args, **kw) return original_function(*args, **kw)
except libvirt.libvirtError as e: except libvirt.libvirtError as e:
logging.error(e.get_error_message())
new_e = Exception(e.get_error_message()) new_e = Exception(e.get_error_message())
new_e.libvirtError = True new_e.libvirtError = True
raise new_e raise new_e
...@@ -120,7 +121,7 @@ def create(vm_desc): ...@@ -120,7 +121,7 @@ def create(vm_desc):
if vm.vm_type == "test": if vm.vm_type == "test":
connection.createXML( connection.createXML(
vm.dump_xml(), libvirt.VIR_DOMAIN_NONE) vm.dump_xml(), libvirt.VIR_DOMAIN_NONE)
domain = connection.lookupByName(vm.name) domain = lookupByName(vm.name)
domain.suspend() domain.suspend()
# Real driver create # Real driver create
else: else:
...@@ -169,10 +170,7 @@ def list_domains(): ...@@ -169,10 +170,7 @@ def list_domains():
def lookupByName(name): def lookupByName(name):
'''Return with the requested Domain '''Return with the requested Domain
''' '''
try:
return connection.lookupByName(name) return connection.lookupByName(name)
except libvirt.libvirtError as e:
logging.error(e.get_error_message())
@celery.task @celery.task
......
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