CORD-1013: Temporary workaround for the main synchronization issue we
will addres with this task
Change-Id: I092b4aae639f5680515dec88353c1dc972baccd5
diff --git a/xos/synchronizers/base/ansible_helper.py b/xos/synchronizers/base/ansible_helper.py
index 7c914d8..3040a26 100644
--- a/xos/synchronizers/base/ansible_helper.py
+++ b/xos/synchronizers/base/ansible_helper.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+
import jinja2
import tempfile
import os
@@ -9,6 +10,7 @@
import re
import traceback
import subprocess
+import threading
from xos.config import Config, XOS_DIR
from xos.logger import observer_logger as logger
from multiprocessing import Process, Queue
@@ -47,7 +49,7 @@
return (opts, os.path.join(pathed_sys_dir,objname))
-def run_playbook(ansible_hosts, ansible_config, fqp, opts, q):
+def run_playbook(ansible_hosts, ansible_config, fqp, opts):#, q):
try:
if ansible_config:
os.environ["ANSIBLE_CONFIG"] = ansible_config
@@ -80,9 +82,19 @@
stats = None
aresults = None
- q.put([stats,aresults])
+ #q.put([stats,aresults])
+ return (stats,aresults)
def run_template(name, opts, path='', expected_num=None, ansible_config=None, ansible_hosts=None, run_ansible_script=None, object=None):
+ global uglylock
+ try:
+ if (uglylock):
+ pass
+ except NameError:
+ uglylock = threading.Lock()
+
+ uglylock.acquire()
+
template = os_template_env.get_template(name)
buffer = template.render(opts)
@@ -92,12 +104,17 @@
f.write(buffer)
f.flush()
+ """
q = Queue()
p = Process(target=run_playbook, args=(ansible_hosts, ansible_config, fqp, opts, q,))
p.start()
stats,aresults = q.get()
p.join()
+ """
+ stats,aresults = run_playbook(ansible_hosts,ansible_config,fqp,opts)
+ uglylock.release()
+
output_file = fqp + '.out'
try:
if (aresults is None):