Commit 334c461b by Guba Sándor

fixed xml_dump and returning values

parent 9aa08ea8
...@@ -16,6 +16,7 @@ from vmcelery import celery, lib_connection ...@@ -16,6 +16,7 @@ from vmcelery import celery, lib_connection
sys.path.append(os.path.dirname(os.path.basename(__file__))) sys.path.append(os.path.dirname(os.path.basename(__file__)))
vm_xml_dump = None
state_dict = {0: 'NOSTATE', state_dict = {0: 'NOSTATE',
1: 'RUNNING', 1: 'RUNNING',
...@@ -99,6 +100,10 @@ def wrap_libvirtError(original_function, *args, **kw): ...@@ -99,6 +100,10 @@ def wrap_libvirtError(original_function, *args, **kw):
return 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()) logging.error(e.get_error_message())
e_msg = e.get_error_message()
if vm_xml_dump is not None:
e_msg += "\n"
e_msg += vm_xml_dump
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
...@@ -164,18 +169,18 @@ def create(vm_desc): ...@@ -164,18 +169,18 @@ def create(vm_desc):
vm = VMInstance.deserialize(vm_desc) vm = VMInstance.deserialize(vm_desc)
# Setting proper hypervisor # Setting proper hypervisor
vm.vm_type = os.getenv("HYPERVISOR_TYPE", "test") vm.vm_type = os.getenv("HYPERVISOR_TYPE", "test")
xml = vm.dump_xml() vm_xml_dump = vm.dump_xml()
logging.info(xml) logging.info(vm_xml_dump)
# Emulating DOMAIN_START_PAUSED FLAG behaviour on test driver # Emulating DOMAIN_START_PAUSED FLAG behaviour on test driver
if vm.vm_type == "test": if vm.vm_type == "test":
Connection.get().createXML( Connection.get().createXML(
xml, libvirt.VIR_DOMAIN_NONE) vm_xml_dump, libvirt.VIR_DOMAIN_NONE)
domain = lookupByName(vm.name) domain = lookupByName(vm.name)
domain.suspend() domain.suspend()
# Real driver create # Real driver create
else: else:
Connection.get().createXML( Connection.get().createXML(
vm.dump_xml(), libvirt.VIR_DOMAIN_START_PAUSED) vm_xml_dump, 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)
# context # context
try: try:
...@@ -186,7 +191,7 @@ def create(vm_desc): ...@@ -186,7 +191,7 @@ def create(vm_desc):
sock.close() sock.close()
except socket.error: except socket.error:
logging.error('Unable to connect to context server') logging.error('Unable to connect to context server')
return xml return vm_xml_dump
class shutdown(AbortableTask): class shutdown(AbortableTask):
......
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