@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:
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):
# 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):
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:
'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,