Fix blocking call to execute service primitive 54/454/1
authorPhilip Joseph <philip.joseph@riftio.com>
Fri, 30 Sep 2016 07:54:47 +0000 (13:24 +0530)
committerPhilip Joseph <philip.joseph@riftio.com>
Fri, 30 Sep 2016 11:44:09 +0000 (17:14 +0530)
Signed-off-by: Philip Joseph <philip.joseph@riftio.com>
common/python/rift/mano/config_agent/operdata.py
common/python/rift/mano/utils/juju_api.py
rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/RiftCM_rpc.py
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.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):
index 7ba5304..b452b8a 100644 (file)
@@ -360,8 +360,8 @@ class JujuApi(object):
 
         # Optimizing calls to Juju, as currently we deploy only 1 unit per
         # service.
-        if self.service == service and len(self.units):
-            return self.units
+        if self.service == service and len(self.units):
+            return self.units
 
         if env is None:
             env = self._get_env()
index 91bc1ab..5f33024 100644 (file)
@@ -240,22 +240,20 @@ class RiftCMRPCHandler(object):
             # The script has full path, use as is
             script = rpc_ip.user_defined_script
         else:
-            script = os.path.join(self._rift_artif_dir, 'launchpad/libs', agent_nsr.id, 'scripts',
+            script = os.path.join(self._rift_artif_dir, 'launchpad/packages/nsd',
+                                  agent_nsr.id, 'scripts',
                                   rpc_ip.user_defined_script)
             self._log.debug("CA-RPC: Checking for script in %s", script)
             if not os.path.exists(script):
                 script = os.path.join(self._rift_install_dir, 'usr/bin', rpc_ip.user_defined_script)
 
-        cmd = "{} {}".format(rpc_ip.user_defined_script, tmp_file.name)
+        cmd = "{} {}".format(script, tmp_file.name)
         self._log.debug("CA-RPC: Running the CMD: {}".format(cmd))
 
-        coro = asyncio.create_subprocess_shell(cmd, loop=self._loop,
-                                               stderr=asyncio.subprocess.PIPE)
-        process = yield from coro
-        err = yield from process.stderr.read()
-        task = self._loop.create_task(process.wait())
+        process = asyncio.create_subprocess_shell(cmd, loop=self._loop,
+                                                  stderr=asyncio.subprocess.PIPE)
 
-        return task, err
+        return process
 
     @asyncio.coroutine
     def register(self):
@@ -315,16 +313,12 @@ class RiftCMRPCHandler(object):
                 if nsd_cfg_prim_msg and nsd_cfg_prim_msg.has_field("user_defined_script"):
                     rpc_ip.user_defined_script = nsd_cfg_prim_msg.user_defined_script
 
-                    tasks = []
-                    task, err = yield from self._apply_ns_config(
+                    task = yield from self._apply_ns_config(
                         nsr,
                         vnfrs,
                         rpc_ip)
-                    tasks.append(task)
-                    if err:
-                        rpc_op.job_status_details = err.decode()
 
-                    self.job_manager.add_job(rpc_op, tasks)
+                    self.job_manager.add_job(rpc_op, [task])
                 else:
                     # Otherwise create VNF primitives.
                     for vnf in rpc_ip.vnf_list:
index 01c0dcb..e29f491 100644 (file)
@@ -62,7 +62,7 @@ class ROConfigManager(object):
             'received': nsrY.ConfigStates.CONFIGURING,
             'cfg_delay': nsrY.ConfigStates.CONFIGURING,
             'cfg_process': nsrY.ConfigStates.CONFIGURING,
-            'cfg_process-failed': nsrY.ConfigStates.CONFIGURING,
+            'cfg_process_failed': nsrY.ConfigStates.CONFIGURING,
             'cfg_sched': nsrY.ConfigStates.CONFIGURING,
             'connecting': nsrY.ConfigStates.CONFIGURING,
             'failed_connection': nsrY.ConfigStates.CONFIGURING,