Fix blocking call to execute service primitive
[osm/SO.git] / common / python / rift / mano / config_agent / operdata.py
index 551aea2..0db3f3d 100644 (file)
@@ -406,9 +406,22 @@ class ConfigAgentJobMonitor(object):
     @asyncio.coroutine
     def _monitor_processes(self, registration_handle):
         result = 0
+        errs = ""
         for process in self.job.tasks:
-            rc = yield from process
-            self.log.debug("Process {} returned rc: {}".format(process, rc))
+            if isinstance(process, asyncio.subprocess.Process):
+                rc = yield from process.wait()
+                err = yield from process.stderr.read()
+
+            else:
+                # Task instance
+                rc = yield from process
+                err = ''
+
+            self.log.debug("Process {} returned rc: {}, err: {}".
+                           format(process, rc, err))
+
+            if len(err):
+                errs += "<error>{}</error>".format(err)
             result |= rc
 
         if result == 0:
@@ -416,6 +429,9 @@ class ConfigAgentJobMonitor(object):
         else:
             self.job.job_status = "failure"
 
+        if len(errs):
+            self.job.job.job_status_details = errs
+
         registration_handle.update_element(self.job.xpath, self.job.job)
 
     def get_error_details(self):