Commit 9f3a4d19 by Guba Sándor

adding LIBVIRT_KEEPALIVE os environment setting

parent c2c050a7
...@@ -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 connection is None: if os.getenv('LIBVIRT_KEEPALIVE') is None:
connection = libvirt.open(connection_string) if connection is None:
logging.debug("Connection estabilished to libvirt.") connection = libvirt.open(connection_string)
logging.debug("Connection estabilished to libvirt.")
else:
logging.debug("There is already an active connection to libvirt.")
else: else:
logging.error("There is already an active connection to libvirt.") connection = lib_connection
@celery.task @celery.task
def disconnect(): def disconnect():
......
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