Commit 62b131b4 by Szeberényi Imre

..celery: Queue and Exchange names are generated from host name

vmdriver: raw data can contain an XML tree.
parent bf0de0cc
...@@ -41,6 +41,6 @@ celery.conf.update( ...@@ -41,6 +41,6 @@ celery.conf.update(
CELERY_TASK_RESULT_EXPIRES=300, CELERY_TASK_RESULT_EXPIRES=300,
CELERY_QUEUES=( CELERY_QUEUES=(
Queue(HOSTNAME, Exchange( Queue(HOSTNAME, Exchange(
'netdriver', type='direct'), routing_key="netdriver"), HOSTNAME, type='direct'), routing_key=HOSTNAME),
) )
) )
...@@ -92,8 +92,14 @@ class VMInstance: ...@@ -92,8 +92,14 @@ class VMInstance:
'type': self.vm_type 'type': self.vm_type
}) })
# Building raw data into xml # Building raw data into xml
# Raw data may contain a tree or a single element
if self.raw_data: if self.raw_data:
xml_top.append(ET.fromstring(self.raw_data)) raw_data = ET.fromstring(self.raw_data)
if len(raw_data):
for child in raw_data:
xml_top.append(child)
else:
xml_top.append(raw_data)
# Basic virtual machine paramaters # Basic virtual machine paramaters
ET.SubElement(xml_top, 'name').text = self.name ET.SubElement(xml_top, 'name').text = self.name
ET.SubElement(xml_top, 'vcpu').text = str(self.vcpu) ET.SubElement(xml_top, 'vcpu').text = str(self.vcpu)
......
...@@ -46,6 +46,6 @@ celery.conf.update( ...@@ -46,6 +46,6 @@ celery.conf.update(
CELERY_TASK_RESULT_EXPIRES=300, CELERY_TASK_RESULT_EXPIRES=300,
CELERY_QUEUES=( CELERY_QUEUES=(
Queue(HOSTNAME, Exchange( Queue(HOSTNAME, Exchange(
'vmdriver', type='direct'), routing_key="vmdriver"), HOSTNAME, type='direct'), routing_key=HOSTNAME),
) )
) )
...@@ -174,7 +174,7 @@ def create(vm_desc): ...@@ -174,7 +174,7 @@ def create(vm_desc):
if vm.vm_type == "test": if vm.vm_type == "test":
vm.arch = "i686" vm.arch = "i686"
vm_xml_dump = vm.dump_xml() vm_xml_dump = vm.dump_xml()
logging.info(vm_xml_dump) logging.debug(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(
...@@ -186,6 +186,8 @@ def create(vm_desc): ...@@ -186,6 +186,8 @@ def create(vm_desc):
Connection.get().createXML( Connection.get().createXML(
vm_xml_dump, 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)
""" What .. is this ?
# context # context
try: try:
sock = socket.create_connection(('127.0.0.1', 1235), 3) sock = socket.create_connection(('127.0.0.1', 1235), 3)
...@@ -195,6 +197,7 @@ def create(vm_desc): ...@@ -195,6 +197,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 vm_xml_dump return vm_xml_dump
......
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