From: Philip Joseph Date: Mon, 30 Jan 2017 11:04:05 +0000 (+0530) Subject: Bug 190 : Pipe the stdout and stderr, when calling init scripts X-Git-Tag: v1.1.0~11 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=e5e7200b0d281203a77ec6e92cdd2f2c6e696275;p=osm%2FSO.git Bug 190 : Pipe the stdout and stderr, when calling init scripts Signed-off-by: Philip Joseph --- diff --git a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py index 8b47e6bd..26af0564 100644 --- a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py +++ b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py @@ -761,18 +761,24 @@ class ConfigManagerConfig(object): self._log.debug("Running the CMD: {}".format(cmd)) process = yield from asyncio.create_subprocess_shell(cmd, - loop=self._loop) - yield from process.wait() - - if process.returncode: - msg = "NSR/VNFR {} initial config using {} failed with {}". \ + loop=self._loop, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + stdout, stderr = yield from process.communicate() + rc = yield from process.wait() + + if rc: + msg = "NSR/VNFR {} initial config using {} failed with {}: {}". \ format(vnfr_name if vnfr_name else nsr_obj.nsr_name, - script, process.returncode) + script, rc, stderr) self._log.error(msg) raise InitialConfigError(msg) - else: - # os.remove(inp_file) - pass + + try: + os.remove(inp_file) + except Exception as e: + self._log.debug("Error removing input file {}: {}". + format(inp_file, e)) def get_script_file(self, script_name, d_name, d_id, d_type): # Get the full path to the script @@ -791,7 +797,7 @@ class ConfigManagerConfig(object): script_name) self._log.debug("Checking for script at %s", script) if not os.path.exists(script): - self._log.debug("Did not find script %s", script) + self._log.warning("Did not find script %s", script) script = os.path.join(os.environ['RIFT_INSTALL'], 'usr/bin', script_name) @@ -801,9 +807,9 @@ class ConfigManagerConfig(object): # to make sure it has execute permission perm = os.stat(script).st_mode if not (perm & stat.S_IXUSR): - self._log.warn("NSR/VNFR {} initial config script {} " \ - "without execute permission: {}". - format(d_name, script, perm)) + self._log.warning("NSR/VNFR {} initial config script {} " \ + "without execute permission: {}". + format(d_name, script, perm)) os.chmod(script, perm | stat.S_IXUSR) return script @@ -846,8 +852,8 @@ class ConfigManagerConfig(object): continue script = self.get_script_file(conf.user_defined_script, - vnfd.id, vnfd.name, + vnfd.id, 'vnfd') yield from self.process_initial_config(nsr_obj,