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://'
result_backend
=
'amqp://'
task_result_expires
=
300
task_result_expires
=
300
result_expires
=
300
result_expires
=
300
timezone
=
'
utc
'
timezone
=
'
UTC
'
enable_utc
=
True
enable_utc
=
True
accept_content
=
[
'json'
,
'pickle_v2'
]
accept_content
=
[
'json'
,
'pickle_v2'
,
'pickle'
]
task_serializer
=
'json'
task_serializer
=
'json'
result_serializer
=
'pickle_v2'
result_serializer
=
'pickle_v2'
task_store_errors_even_if_ignored
=
True
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):
...
@@ -198,42 +198,48 @@ def create(vm_desc):
return
vm_xml_dump
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).
""" Shutdown virtual machine (need ACPI support).
Return When domain is missiing.
Return When domain is missiing.
This job is abortable:
This job is abortable:
AbortableAsyncResult(id="<<jobid>>").abort()
AbortableAsyncResult(id="<<jobid>>").abort()
"""
"""
time_limit
=
120
from
time
import
sleep
name
,
=
args
@req_connection
logger
.
info
(
"Shutdown started for vm:
%
s"
,
name
)
def
run
(
self
,
args
):
try
:
from
time
import
sleep
# VM lookup
name
,
=
args
domain
=
lookupByName
(
name
)
logger
.
info
(
"Shutdown started for vm:
%
s"
,
name
)
logger
.
info
(
"
%
s domain found in shutdown"
,
name
)
try
:
# ACPI shutdown
domain
=
lookupByName
(
name
)
domain
.
shutdown
()
logger
.
info
(
"
%
s domain found in shutdown"
,
name
)
logger
.
info
(
"Domain shutdown called for vm:
%
s"
,
name
)
domain
.
shutdown
()
# Wait for disappearance
logger
.
info
(
"Domain shutdown called for vm:
%
s"
,
name
)
while
True
:
while
True
:
try
:
try
:
Connection
.
get
()
.
lookupByName
(
name
)
Connection
.
get
()
.
lookupByName
(
name
)
except
libvirt
.
libvirtError
as
e
:
except
libvirt
.
libvirtError
as
e
:
if
e
.
get_error_code
()
==
libvirt
.
VIR_ERR_NO_DOMAIN
:
if
e
.
get_error_code
()
==
libvirt
.
VIR_ERR_NO_DOMAIN
:
return
return
else
:
raise
else
:
else
:
if
self
.
is_aborted
():
raise
logger
.
info
(
"Shutdown aborted on vm:
%
s"
,
name
)
else
:
return
if
self
.
is_aborted
():
sleep
(
5
)
logger
.
info
(
"Shutdown aborted on vm:
%
s"
,
name
)
except
libvirt
.
libvirtError
as
e
:
return
new_e
=
Exception
(
e
.
get_error_message
())
sleep
(
5
)
new_e
.
libvirtError
=
True
except
libvirt
.
libvirtError
as
e
:
raise
new_e
new_e
=
Exception
(
e
.
get_error_message
())
new_e
.
libvirtError
=
True
raise
new_e
@celery.task
@celery.task
@req_connection
@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