Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9f3a4d19
authored
Aug 16, 2013
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding LIBVIRT_KEEPALIVE os environment setting
parent
c2c050a7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
vmdriver.py
+7
-2
No files found.
vmdriver.py
View file @
9f3a4d19
...
@@ -25,6 +25,9 @@ state_dict = {0: 'NOSTATE',
...
@@ -25,6 +25,9 @@ state_dict = {0: 'NOSTATE',
@decorator
@decorator
def
req_connection
(
original_function
,
*
args
,
**
kw
):
def
req_connection
(
original_function
,
*
args
,
**
kw
):
'''Connection checking decorator for libvirt.
'''Connection checking decorator for libvirt.
If envrionment variable LIBVIRT_KEEPALIVE is set
it will use the connection from the celery worker.
'''
'''
logging
.
debug
(
"Decorator running"
)
logging
.
debug
(
"Decorator running"
)
global
connection
global
connection
...
@@ -50,12 +53,14 @@ def connect(connection_string='qemu:///system'):
...
@@ -50,12 +53,14 @@ def connect(connection_string='qemu:///system'):
connection_string or the local root.
connection_string or the local root.
'''
'''
global
connection
global
connection
if
os
.
getenv
(
'LIBVIRT_KEEPALIVE'
)
is
None
:
if
connection
is
None
:
if
connection
is
None
:
connection
=
libvirt
.
open
(
connection_string
)
connection
=
libvirt
.
open
(
connection_string
)
logging
.
debug
(
"Connection estabilished to libvirt."
)
logging
.
debug
(
"Connection estabilished to libvirt."
)
else
:
else
:
logging
.
error
(
"There is already an active connection to libvirt."
)
logging
.
debug
(
"There is already an active connection to libvirt."
)
else
:
connection
=
lib_connection
@celery.task
@celery.task
def
disconnect
():
def
disconnect
():
...
...
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