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:: ...@@ -28,9 +28,8 @@ Configure Open vSwitch bridge that handle vitual connections::
Enable passwordless Open vSwitch commands:: Enable passwordless Open vSwitch commands::
$ sudo tee /etc/sudoers.d/netdriver <<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
cloud ALL = (ALL) NOPASSWD: /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl, /sbin/ip link set *
END
$ sudo chmod 660 /etc/sudoers.d/netdriver $ sudo chmod 660 /etc/sudoers.d/netdriver
Configuring the libvirt daemon Configuring the libvirt daemon
...@@ -76,7 +75,7 @@ Save configuration to virtualenv and activate environment:: ...@@ -76,7 +75,7 @@ Save configuration to virtualenv and activate environment::
export LIBVIRT_KEEPALIVE=True export LIBVIRT_KEEPALIVE=True
export LIBVIRT_URI=test:///default export LIBVIRT_URI=test:///default
export AMQP_URI=amqp://cloud:password@$(hostname)/circle export AMQP_URI=amqp://cloud:password@$(hostname)/circle
export HYPERVISOR_TYPE=test export HYPERVISOR_TYPE=test
END END
Copy the libvrit bindings to the local virtualenv directory:: Copy the libvrit bindings to the local virtualenv directory::
...@@ -95,4 +94,4 @@ Copy the upstart scripts for celery services:: ...@@ -95,4 +94,4 @@ Copy the upstart scripts for celery services::
Start celery daemons:: Start celery daemons::
$ sudo start vmcelery $ sudo start vmcelery
$ sudo start netcelery $ sudo start netcelery
\ No newline at end of file
...@@ -8,8 +8,8 @@ setgid libvirtd ...@@ -8,8 +8,8 @@ setgid libvirtd
instance $NAME instance $NAME
script script
cd /home/cloud/vmdriver cd /home/kohlkriszto/Documents/vmdriver
. /home/cloud/.virtualenvs/vmdriver/local/bin/activate . /home/kohlkriszto/Documents/vmdriver_venv/bin/activate
. /home/cloud/.virtualenvs/vmdriver/local/bin/postactivate . /home/kohlkriszto/Documents/vmdriver_venv/bin/postactivate
exec celery -A netcelery worker --loglevel=info -n ${NAME} exec celery -A netcelery worker --loglevel=info -n ${NAME}
end script end script
...@@ -12,4 +12,5 @@ Restart=always ...@@ -12,4 +12,5 @@ Restart=always
WorkingDirectory=/home/cloud/vmdriver 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 ...@@ -8,8 +8,8 @@ setgid libvirtd
instance $NAME instance $NAME
script script
cd /home/cloud/vmdriver cd /home/kohlkriszto/Documents/vmdriver
. /home/cloud/.virtualenvs/vmdriver/local/bin/activate . /home/kohlkriszto/Documents/vmdriver_venv/bin/activate
. /home/cloud/.virtualenvs/vmdriver/local/bin/postactivate . /home/kohlkriszto/Documents/vmdriver_venv/bin/postactivate
exec celery -A vmcelery worker --loglevel=info -n $NAME exec celery -A vmcelery worker --loglevel=info -n $NAME
end script end script
...@@ -12,4 +12,5 @@ Restart=always ...@@ -12,4 +12,5 @@ Restart=always
WorkingDirectory=/home/cloud/vmdriver 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', ...@@ -36,11 +36,12 @@ celery = Celery('netcelery',
broker=AMQP_URI, broker=AMQP_URI,
include=['netdriver']) include=['netdriver'])
celery.config_from_object('celeryconfig')
celery.conf.update( celery.conf.update(
CELERY_RESULT_BACKEND='amqp',
CELERY_TASK_RESULT_EXPIRES=300,
CELERY_QUEUES=( CELERY_QUEUES=(
Queue(HOSTNAME, Exchange( Queue(HOSTNAME, Exchange(
'netdriver', type='direct'), routing_key="netdriver"), '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 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 lxml==3.4.2
psutil==1.1.3 libvirt-python==7.10.0
Pillow==2.3.0 pillow==8.4.0
GitPython==0.3.6 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 = { ...@@ -26,12 +26,12 @@ vmdict = {
'graphics': graphics 'graphics': graphics
} }
print vm.VMNetwork.deserialize(netdict).dump_xml() print((vm.VMNetwork.deserialize(netdict).dump_xml()))
print vm.VMDisk.deserialize(diskdict).dump_xml() print((vm.VMDisk.deserialize(diskdict).dump_xml()))
asd = vm.VMInstance.deserialize(vmdict) asd = vm.VMInstance.deserialize(vmdict)
print asd.dump_xml() print((asd.dump_xml()))
# Enable logging # Enable logging
# logging.basicConfig(filename='example.log', level=logging.DEBUG) # logging.basicConfig(filename='example.log', level=logging.DEBUG)
......
...@@ -173,7 +173,7 @@ class VMInstance: ...@@ -173,7 +173,7 @@ class VMInstance:
def dump_xml(self): def dump_xml(self):
return ET.tostring(self.build_xml(), return ET.tostring(self.build_xml(),
encoding='utf8', encoding='unicode',
method='xml', method='xml',
pretty_print=True) pretty_print=True)
...@@ -231,7 +231,7 @@ class VMDisk: ...@@ -231,7 +231,7 @@ class VMDisk:
def dump_xml(self): def dump_xml(self):
return ET.tostring(self.build_xml(), return ET.tostring(self.build_xml(),
encoding='utf8', encoding='unicode',
method='xml', method='xml',
pretty_print=True) pretty_print=True)
...@@ -323,6 +323,6 @@ class VMNetwork: ...@@ -323,6 +323,6 @@ class VMNetwork:
return xml_top return xml_top
def dump_xml(self): def dump_xml(self):
return ET.tostring(self.build_xml(), encoding='utf8', return ET.tostring(self.build_xml(), encoding='unicode',
method='xml', method='xml',
pretty_print=True) pretty_print=True)
""" Celery module for libvirt RPC calls. """ """ Celery module for libvirt RPC calls. """
from celery import Celery from celery import Celery
from kombu import Queue, Exchange from kombu import Queue, Exchange
from os import getenv from os import getenv
...@@ -41,11 +42,13 @@ celery = Celery('vmcelery', ...@@ -41,11 +42,13 @@ celery = Celery('vmcelery',
broker=AMQP_URI, broker=AMQP_URI,
include=['vmdriver']) include=['vmdriver'])
celery.config_from_object('celeryconfig')
celery.conf.update( celery.conf.update(
CELERY_RESULT_BACKEND='amqp',
CELERY_TASK_RESULT_EXPIRES=300,
CELERY_QUEUES=( CELERY_QUEUES=(
Queue(HOSTNAME, Exchange( Queue(HOSTNAME, Exchange(
'vmdriver', type='direct'), routing_key="vmdriver"), 'vmdriver', type='direct'), routing_key="vmdriver"),
) )
) )
...@@ -8,7 +8,7 @@ import json ...@@ -8,7 +8,7 @@ import json
from decorator import decorator from decorator import decorator
import lxml.etree as ET 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 from celery.contrib.abortable import AbortableTask
...@@ -183,6 +183,7 @@ def create(vm_desc): ...@@ -183,6 +183,7 @@ def create(vm_desc):
domain.suspend() domain.suspend()
# Real driver create # Real driver create
else: else:
logging.info("Virtual machine %s being created from xml", vm.name)
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)
...@@ -419,7 +420,7 @@ def node_info(): ...@@ -419,7 +420,7 @@ def node_info():
keys = ['model', 'memory', 'cpus', 'mhz', keys = ['model', 'memory', 'cpus', 'mhz',
'nodes', 'sockets', 'cores', 'threads'] 'nodes', 'sockets', 'cores', 'threads']
values = Connection.get().getInfo() values = Connection.get().getInfo()
return dict(zip(keys, values)) return dict(list(zip(keys, values)))
def _parse_info(values): def _parse_info(values):
...@@ -430,7 +431,7 @@ def _parse_info(values): ...@@ -430,7 +431,7 @@ def _parse_info(values):
""" """
keys = ['state', 'maxmem', 'memory', 'virtcpunum', 'cputime'] keys = ['state', 'maxmem', 'memory', 'virtcpunum', 'cputime']
info = dict(zip(keys, values)) info = dict(list(zip(keys, values)))
# Change state to proper ENUM # Change state to proper ENUM
info['state'] = state_dict[info['state']] info['state'] = state_dict[info['state']]
return info return info
...@@ -474,7 +475,7 @@ def network_info(name, network): ...@@ -474,7 +475,7 @@ def network_info(name, network):
'tx_bytes', 'tx_packets', 'tx_errs', 'tx_drop'] 'tx_bytes', 'tx_packets', 'tx_errs', 'tx_drop']
dom = lookupByName(name) dom = lookupByName(name)
values = dom.interfaceStats(network) values = dom.interfaceStats(network)
info = dict(zip(keys, values)) info = dict(list(zip(keys, values)))
return info return info
...@@ -579,7 +580,7 @@ def __check_detach(domain, disk): ...@@ -579,7 +580,7 @@ def __check_detach(domain, disk):
root = ET.fromstring(xml) root = ET.fromstring(xml)
devices = root.find('devices') devices = root.find('devices')
for d in devices.findall("disk"): 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. " raise Exception("Disk could not been detached. "
"Check if hot plug support is " "Check if hot plug support is "
"enabled (acpiphp module on Linux).") "enabled (acpiphp module on Linux).")
...@@ -631,7 +632,7 @@ def get_architecture(): ...@@ -631,7 +632,7 @@ def get_architecture():
@celery.task @celery.task
def get_core_num(): def get_core_num():
return NUM_CPUS return cpu_count
@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