Commit a00ce1bb by Guba Sándor

vmdriver: fixing commits

parent be56fe09
......@@ -11,7 +11,7 @@ celery = Celery('netdriver', backend='amqp',
include=['netdriver'])
celery.conf.update(
CELERY_TASK_RESULT_EXPIRES = 300,
CELERY_QUEUES=(
Queue(HOSTNAME + '.net', Exchange(
'netdriver', type='direct'), routing_key='netdriver'),
......
......@@ -69,6 +69,7 @@ class VMInstance:
self.raw_data = raw_data
self.seclabel_type = seclabel_type
self.seclabel_mode = seclabel_mode
self.boot_token = boot_token
@classmethod
def deserialize(cls, desc):
......@@ -107,6 +108,17 @@ class VMInstance:
devices.append(disk.build_xml())
for network in self.network_list:
devices.append(network.build_xml())
# Serial console
serial = ET.SubElement(devices,
'console',
attrib={'type': 'unix'})
ET.SubElement(serial,
'target',
attrib={'port': '0'})
ET.SubElement(serial,
'source',
attrib={'mode': 'bind',
'path': '/var/lib/libvirt/serial/%s' % self.name})
# Console/graphics section
if self.graphics is not None:
ET.SubElement(devices,
......
......@@ -16,9 +16,12 @@ celery = Celery('vmcelery', backend='amqp',
include=['vmdriver'])
celery.conf.update(
CELERY_TASK_RESULT_EXPIRES = 300,
CELERY_QUEUES=(
Queue(HOSTNAME + '.vm', Exchange(
'vmdriver', type='direct'), routing_key="vmdriver"),
# Queue(HOSTNAME + '.monitor', Exchange(
# 'monitor', type='direct'), routing_key="monitor"),
)
)
......
......@@ -3,6 +3,8 @@ import libvirt
import logging
import os
import sys
import socket
import json
from decorator import decorator
from psutil import NUM_CPUS, virtual_memory
......@@ -174,6 +176,15 @@ def create(vm_desc):
Connection.get().createXML(
vm.dump_xml(), libvirt.VIR_DOMAIN_START_PAUSED)
logging.info("Virtual machine %s is created from xml", vm.name)
# context
try:
sock = socket.create_connection(('127.0.0.1', 1235), 3)
data = {'boot_token': vm.boot_token,
'socket': '/var/lib/libvirt/serial/%s' % vm.name}
sock.sendall(json.dumps(data))
sock.close()
except socket.error:
logging.error('Unable to connect to context server')
return domain_info(vm.name)
......
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