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
f408ecd0
authored
Nov 28, 2025
by
Szeberényi Imre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fured fix
parent
840dd333
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
32 deletions
+41
-32
celeryconfig.py
+2
-2
miscellaneous/netdriver.sudo
+3
-0
vmdriver.py
+36
-30
No files found.
celeryconfig.py
View file @
f408ecd0
result_backend
=
'amqp://'
task_result_expires
=
300
result_expires
=
300
timezone
=
'
utc
'
timezone
=
'
UTC
'
enable_utc
=
True
accept_content
=
[
'json'
,
'pickle_v2'
]
accept_content
=
[
'json'
,
'pickle_v2'
,
'pickle'
]
task_serializer
=
'json'
result_serializer
=
'pickle_v2'
task_store_errors_even_if_ignored
=
True
...
...
miscellaneous/netdriver.sudo
0 → 100644
View file @
f408ecd0
Defaults: cloud !requiretty
cloud ALL = (ALL) NOPASSWD: /usr/bin/ovs-ofctl, /usr/bin/ovs-vsctl, /sbin/ip link set *
vmdriver.py
View file @
f408ecd0
...
...
@@ -198,42 +198,48 @@ def create(vm_desc):
return
vm_xml_dump
class
shutdown
(
AbortableTask
):
@celery.task
(
name
=
'vmdriver.shutdown'
,
bind
=
True
,
base
=
AbortableTask
,
time_limit
=
120
,
)
@req_connection
@wrap_libvirtError
def
shutdown
(
self
,
args
):
""" Shutdown virtual machine (need ACPI support).
Return When domain is missiing.
This job is abortable:
AbortableAsyncResult(id="<<jobid>>").abort()
"""
time_limit
=
120
@req_connection
def
run
(
self
,
args
):
from
time
import
sleep
name
,
=
args
logger
.
info
(
"Shutdown started for vm:
%
s"
,
name
)
try
:
domain
=
lookupByName
(
name
)
logger
.
info
(
"
%
s domain found in shutdown"
,
name
)
domain
.
shutdown
()
logger
.
info
(
"Domain shutdown called for vm:
%
s"
,
name
)
while
True
:
try
:
Connection
.
get
()
.
lookupByName
(
name
)
except
libvirt
.
libvirtError
as
e
:
if
e
.
get_error_code
()
==
libvirt
.
VIR_ERR_NO_DOMAIN
:
return
else
:
raise
from
time
import
sleep
name
,
=
args
logger
.
info
(
"Shutdown started for vm:
%
s"
,
name
)
try
:
# VM lookup
domain
=
lookupByName
(
name
)
logger
.
info
(
"
%
s domain found in shutdown"
,
name
)
# ACPI shutdown
domain
.
shutdown
()
logger
.
info
(
"Domain shutdown called for vm:
%
s"
,
name
)
# Wait for disappearance
while
True
:
try
:
Connection
.
get
()
.
lookupByName
(
name
)
except
libvirt
.
libvirtError
as
e
:
if
e
.
get_error_code
()
==
libvirt
.
VIR_ERR_NO_DOMAIN
:
return
else
:
if
self
.
is_aborted
():
logger
.
info
(
"Shutdown aborted on vm:
%
s"
,
name
)
return
sleep
(
5
)
except
libvirt
.
libvirtError
as
e
:
new_e
=
Exception
(
e
.
get_error_message
())
new_e
.
libvirtError
=
True
raise
new_e
raise
else
:
if
self
.
is_aborted
():
logger
.
info
(
"Shutdown aborted on vm:
%
s"
,
name
)
return
sleep
(
5
)
except
libvirt
.
libvirtError
as
e
:
new_e
=
Exception
(
e
.
get_error_message
())
new_e
.
libvirtError
=
True
raise
new_e
@celery.task
@req_connection
...
...
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