Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fe4837f7
authored
Jan 07, 2022
by
Kohl Krisztofer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First 3.6 version
parent
b6d5c41a
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
32 additions
and
30 deletions
+32
-30
docs/install-node.rst
+2
-3
miscellaneous/netcelery.conf
+3
-3
miscellaneous/netcelery@.service
+2
-1
miscellaneous/vmcelery.conf
+3
-3
miscellaneous/vmcelery@.service
+2
-1
netcelery.py
+2
-2
requirements/base.txt
+6
-6
tests/test.py
+3
-3
vmcelery.py
+3
-2
vmdriver.py
+6
-6
No files found.
docs/install-node.rst
View file @
fe4837f7
...
@@ -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
...
...
miscellaneous/netcelery.conf
View file @
fe4837f7
...
@@ -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
miscellaneous/netcelery@.service
View file @
fe4837f7
...
@@ -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 /home/cloud/.virtualenvs/vmdriver/bin/activate; source /home/cloud/.virtualenvs/vmdriver/bin/activate; exec celery -A netcelery worker --loglevel=info -n $(/bin/hostname -s).%I"
miscellaneous/vmcelery.conf
View file @
fe4837f7
...
@@ -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
miscellaneous/vmcelery@.service
View file @
fe4837f7
...
@@ -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 /home/cloud/.virtualenvs/vmdriver/bin/activate; source /home/cloud/.virtualenvs/vmdriver/bin/activate; exec celery -A vmcelery worker --loglevel=info -n $(/bin/hostname -s).%I"
netcelery.py
View file @
fe4837f7
...
@@ -37,8 +37,8 @@ celery = Celery('netcelery',
...
@@ -37,8 +37,8 @@ celery = Celery('netcelery',
include
=
[
'netdriver'
])
include
=
[
'netdriver'
])
celery
.
conf
.
update
(
celery
.
conf
.
update
(
CELERY_RESULT_BACKEND
=
'amqp'
,
CELERY_RESULT_BACKEND
=
'amqp
://
'
,
CELERY_TASK_RESULT_EXPIRES
=
300
,
CELERY_TASK_RESULT_EXPIRES
=
300
000
,
CELERY_QUEUES
=
(
CELERY_QUEUES
=
(
Queue
(
HOSTNAME
,
Exchange
(
Queue
(
HOSTNAME
,
Exchange
(
'netdriver'
,
type
=
'direct'
),
routing_key
=
"netdriver"
),
'netdriver'
,
type
=
'direct'
),
routing_key
=
"netdriver"
),
...
...
requirements/base.txt
View file @
fe4837f7
celery
==3.1.17
celery
decorator
==3.4.0
decorator
lxml
==3.4.2
lxml
psutil
==1.1.3
psutil
Pillow
==2.3.0
Pillow
GitPython
==0.3.6
GitPython
tests/test.py
100755 → 100644
View file @
fe4837f7
...
@@ -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)
...
...
vmcelery.py
View file @
fe4837f7
""" 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
...
@@ -42,8 +43,8 @@ celery = Celery('vmcelery',
...
@@ -42,8 +43,8 @@ celery = Celery('vmcelery',
include
=
[
'vmdriver'
])
include
=
[
'vmdriver'
])
celery
.
conf
.
update
(
celery
.
conf
.
update
(
CELERY_RESULT_BACKEND
=
'amqp'
,
CELERY_RESULT_BACKEND
=
'amqp
://
'
,
CELERY_TASK_RESULT_EXPIRES
=
300
,
CELERY_TASK_RESULT_EXPIRES
=
300
000
,
CELERY_QUEUES
=
(
CELERY_QUEUES
=
(
Queue
(
HOSTNAME
,
Exchange
(
Queue
(
HOSTNAME
,
Exchange
(
'vmdriver'
,
type
=
'direct'
),
routing_key
=
"vmdriver"
),
'vmdriver'
,
type
=
'direct'
),
routing_key
=
"vmdriver"
),
...
...
vmdriver.py
View file @
fe4837f7
...
@@ -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
...
@@ -419,7 +419,7 @@ def node_info():
...
@@ -419,7 +419,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 +430,7 @@ def _parse_info(values):
...
@@ -430,7 +430,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 +474,7 @@ def network_info(name, network):
...
@@ -474,7 +474,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 +579,7 @@ def __check_detach(domain, disk):
...
@@ -579,7 +579,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 +631,7 @@ def get_architecture():
...
@@ -631,7 +631,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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment