Commit b036bf5b by Szeberényi Imre

Merge branch 'python3.6' into 'master'

Python3.6

See merge request !1
parents b6d5c41a 9a90fc22
CELERY_RESULT_BACKEND = 'amqp://'
CELERY_TASK_RESULT_EXPIRES = 300
CELERY_TIMEZONE = 'UTC'
CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
......@@ -28,9 +28,8 @@ Configure Open vSwitch bridge that handle vitual connections::
Enable passwordless Open vSwitch commands::
$ sudo tee /etc/sudoers.d/netdriver <<END
cloud ALL = (ALL) NOPASSWD: /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl, /sbin/ip link set *
END
$ sudo tee /etc/sudoers.d/netdriver <<END cloud ALL = (ALL) NOPASSWD: /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl, /sbin/ip link set * END
$ sudo chmod 660 /etc/sudoers.d/netdriver
Configuring the libvirt daemon
......
......@@ -8,8 +8,8 @@ setgid libvirtd
instance $NAME
script
cd /home/cloud/vmdriver
. /home/cloud/.virtualenvs/vmdriver/local/bin/activate
. /home/cloud/.virtualenvs/vmdriver/local/bin/postactivate
cd /home/kohlkriszto/Documents/vmdriver
. /home/kohlkriszto/Documents/vmdriver_venv/bin/activate
. /home/kohlkriszto/Documents/vmdriver_venv/bin/postactivate
exec celery -A netcelery worker --loglevel=info -n ${NAME}
end script
......@@ -12,4 +12,5 @@ Restart=always
WorkingDirectory=/home/cloud/vmdriver
ExecStart=/bin/bash -c "source /etc/profile; workon vmdriver; exec celery -A netcelery worker --loglevel=info -n $(/bin/hostname -s).%I"
ExecStart=/bin/bash -c "source /etc/profile; workon vmdriver; exec celery -A netcelery worker --loglevel=debug -n $(/bin/hostname -s).%I"
......@@ -8,8 +8,8 @@ setgid libvirtd
instance $NAME
script
cd /home/cloud/vmdriver
. /home/cloud/.virtualenvs/vmdriver/local/bin/activate
. /home/cloud/.virtualenvs/vmdriver/local/bin/postactivate
cd /home/kohlkriszto/Documents/vmdriver
. /home/kohlkriszto/Documents/vmdriver_venv/bin/activate
. /home/kohlkriszto/Documents/vmdriver_venv/bin/postactivate
exec celery -A vmcelery worker --loglevel=info -n $NAME
end script
......@@ -12,4 +12,5 @@ Restart=always
WorkingDirectory=/home/cloud/vmdriver
ExecStart=/bin/bash -c "source /etc/profile; workon vmdriver; exec celery -A vmcelery worker --loglevel=info -n $(/bin/hostname -s).%I"
ExecStart=/bin/bash -c "source /etc/profile; workon vmdriver; exec celery -A vmcelery worker --loglevel=debug -n $(/bin/hostname -s).%I"
......@@ -36,11 +36,12 @@ celery = Celery('netcelery',
broker=AMQP_URI,
include=['netdriver'])
celery.config_from_object('celeryconfig')
celery.conf.update(
CELERY_RESULT_BACKEND='amqp',
CELERY_TASK_RESULT_EXPIRES=300,
CELERY_QUEUES=(
Queue(HOSTNAME, Exchange(
'netdriver', type='direct'), routing_key="netdriver"),
)
)
celery==3.1.17
setuptools<58
amqp==1.4.9
billiard==3.3.0.23
celery==3.1.18
decorator==3.4.0
future==0.18.2
GitPython==3.1.18
importlib-metadata==4.8.3
kombu==3.0.30
lxml==3.4.2
psutil==1.1.3
Pillow==2.3.0
GitPython==0.3.6
libvirt-python==7.10.0
pillow==8.4.0
psutil==4.4.2
pytz==2021.3
smmap==5.0.0
typing_extensions==4.0.1
vine==5.0.0
zipp==3.6.0
amqp==1.4.9
anyjson==0.3.3
billiard==3.3.0.23
celery==3.1.18
decorator==3.4.0
future==0.18.2
gitdb==4.0.9
GitPython==3.1.18
importlib-metadata==4.8.3
kombu==3.0.30
libvirt-python==7.10.0
lxml==3.4.2
Pillow==8.4.0
psutil==4.4.2
pytz==2021.3
smmap==5.0.0
typing_extensions==4.0.1
vine==5.0.0
zipp==3.6.0
......@@ -26,12 +26,12 @@ vmdict = {
'graphics': graphics
}
print vm.VMNetwork.deserialize(netdict).dump_xml()
print vm.VMDisk.deserialize(diskdict).dump_xml()
print((vm.VMNetwork.deserialize(netdict).dump_xml()))
print((vm.VMDisk.deserialize(diskdict).dump_xml()))
asd = vm.VMInstance.deserialize(vmdict)
print asd.dump_xml()
print((asd.dump_xml()))
# Enable logging
# logging.basicConfig(filename='example.log', level=logging.DEBUG)
......
......@@ -173,7 +173,7 @@ class VMInstance:
def dump_xml(self):
return ET.tostring(self.build_xml(),
encoding='utf8',
encoding='unicode',
method='xml',
pretty_print=True)
......@@ -231,7 +231,7 @@ class VMDisk:
def dump_xml(self):
return ET.tostring(self.build_xml(),
encoding='utf8',
encoding='unicode',
method='xml',
pretty_print=True)
......@@ -323,6 +323,6 @@ class VMNetwork:
return xml_top
def dump_xml(self):
return ET.tostring(self.build_xml(), encoding='utf8',
return ET.tostring(self.build_xml(), encoding='unicode',
method='xml',
pretty_print=True)
""" Celery module for libvirt RPC calls. """
from celery import Celery
from kombu import Queue, Exchange
from os import getenv
......@@ -41,11 +42,13 @@ celery = Celery('vmcelery',
broker=AMQP_URI,
include=['vmdriver'])
celery.config_from_object('celeryconfig')
celery.conf.update(
CELERY_RESULT_BACKEND='amqp',
CELERY_TASK_RESULT_EXPIRES=300,
CELERY_QUEUES=(
Queue(HOSTNAME, Exchange(
'vmdriver', type='direct'), routing_key="vmdriver"),
)
)
......@@ -8,7 +8,7 @@ import json
from decorator import decorator
import lxml.etree as ET
from psutil import NUM_CPUS, virtual_memory, cpu_percent
from psutil import cpu_count, virtual_memory, cpu_percent
from celery.contrib.abortable import AbortableTask
......@@ -183,6 +183,7 @@ def create(vm_desc):
domain.suspend()
# Real driver create
else:
logging.info("Virtual machine %s being created from xml", vm.name)
Connection.get().createXML(
vm_xml_dump, libvirt.VIR_DOMAIN_START_PAUSED)
logging.info("Virtual machine %s is created from xml", vm.name)
......@@ -419,7 +420,7 @@ def node_info():
keys = ['model', 'memory', 'cpus', 'mhz',
'nodes', 'sockets', 'cores', 'threads']
values = Connection.get().getInfo()
return dict(zip(keys, values))
return dict(list(zip(keys, values)))
def _parse_info(values):
......@@ -430,7 +431,7 @@ def _parse_info(values):
"""
keys = ['state', 'maxmem', 'memory', 'virtcpunum', 'cputime']
info = dict(zip(keys, values))
info = dict(list(zip(keys, values)))
# Change state to proper ENUM
info['state'] = state_dict[info['state']]
return info
......@@ -474,7 +475,7 @@ def network_info(name, network):
'tx_bytes', 'tx_packets', 'tx_errs', 'tx_drop']
dom = lookupByName(name)
values = dom.interfaceStats(network)
info = dict(zip(keys, values))
info = dict(list(zip(keys, values)))
return info
......@@ -579,7 +580,7 @@ def __check_detach(domain, disk):
root = ET.fromstring(xml)
devices = root.find('devices')
for d in devices.findall("disk"):
if disk in d.find('source').attrib.values()[0]:
if disk in list(d.find('source').attrib.values())[0]:
raise Exception("Disk could not been detached. "
"Check if hot plug support is "
"enabled (acpiphp module on Linux).")
......@@ -631,7 +632,7 @@ def get_architecture():
@celery.task
def get_core_num():
return NUM_CPUS
return cpu_count
@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