From: Philip Joseph Date: Fri, 30 Sep 2016 07:54:47 +0000 (+0530) Subject: Fix blocking call to execute service primitive X-Git-Tag: v1.0.0~4 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F54%2F454%2F1;p=osm%2FSO.git Fix blocking call to execute service primitive Signed-off-by: Philip Joseph --- diff --git a/common/python/rift/mano/config_agent/operdata.py b/common/python/rift/mano/config_agent/operdata.py index 551aea2d..0db3f3d9 100644 --- a/common/python/rift/mano/config_agent/operdata.py +++ b/common/python/rift/mano/config_agent/operdata.py @@ -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 += "{}".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): diff --git a/common/python/rift/mano/utils/juju_api.py b/common/python/rift/mano/utils/juju_api.py index 7ba53047..b452b8a5 100644 --- a/common/python/rift/mano/utils/juju_api.py +++ b/common/python/rift/mano/utils/juju_api.py @@ -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() diff --git a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/RiftCM_rpc.py b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/RiftCM_rpc.py index 91bc1ab5..5f330249 100644 --- a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/RiftCM_rpc.py +++ b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/RiftCM_rpc.py @@ -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: diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.py index 01c0dcb2..e29f4911 100644 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/rwnsm_conman.py @@ -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,