From: velandy Date: Thu, 27 Apr 2017 17:01:32 +0000 (+0200) Subject: Merge "Remove config template from use in ping-pong" X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=a5d82a2b619c0537dac2d34a21e09981a53ac1f6;hp=-c;p=osm%2FSO.git Merge "Remove config template from use in ping-pong" --- a5d82a2b619c0537dac2d34a21e09981a53ac1f6 diff --combined rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py index c3ef3e75,9e8b944e..bd880900 --- a/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py +++ b/rwcm/plugins/rwconman/rift/tasklets/rwconmantasklet/rwconman_config.py @@@ -30,11 -30,14 +30,14 @@@ from gi.repository import ) import rift.tasklets + import rift.package.script + import rift.package.store from . import rwconman_conagent as conagent from . import RiftCM_rpc from . import riftcm_config_plugin + if sys.version_info < (3, 4, 4): asyncio.ensure_future = asyncio.async @@@ -792,37 -795,32 +795,32 @@@ class ConfigManagerConfig(object) format(inp_file, e)) def get_script_file(self, script_name, d_name, d_id, d_type): - # Get the full path to the script - script = '' - # If script name starts with /, assume it is full path - if script_name[0] == '/': - # The script has full path, use as is - script = script_name - else: - script = os.path.join(os.environ['RIFT_ARTIFACTS'], - 'launchpad/packages', - d_type, - d_id, - d_name, - 'scripts', - script_name) - self._log.debug("Checking for script at %s", script) - if not os.path.exists(script): - self._log.warning("Did not find script %s", script) - script = os.path.join(os.environ['RIFT_INSTALL'], - 'usr/bin', - script_name) - - # Seen cases in jenkins, where the script execution fails - # with permission denied. Setting the permission on script - # to make sure it has execute permission - perm = os.stat(script).st_mode - if not (perm & stat.S_IXUSR): - self._log.warning("NSR/VNFR {} initial config script {} " \ + if d_type == "vnfd": + package_store = rift.package.store.VnfdPackageFilesystemStore(self._log) + package_store.refresh() + elif d_type == "nsd": + package_store = rift.package.store.NsdPackageFilesystemStore(self._log) + package_store.refresh() + else: + raise + script_extractor = rift.package.script.PackageScriptExtractor(self._log) + script = script_extractor.get_extracted_script_path(d_id, script_name) + + self._log.debug("Checking for script at %s", script) + if not os.path.exists(script): + self._log.warning("Did not find script %s", script) + return + + # Seen cases in jenkins, where the script execution fails + # with permission denied. Setting the permission on script + # to make sure it has execute permission + perm = os.stat(script).st_mode + if not (perm & stat.S_IXUSR): + self._log.warning("NSR/VNFR {} script {} " \ "without execute permission: {}". format(d_name, script, perm)) - os.chmod(script, perm | stat.S_IXUSR) - return script + os.chmod(script, perm | stat.S_IXUSR) + return script @asyncio.coroutine def process_ns_initial_config(self, nsr_obj): @@@ -854,11 -852,11 +852,11 @@@ vnf_cfg = vnfd.vnf_configuration for conf in vnf_cfg.initial_config_primitive: - self._log.debug("VNFR {} initial config: {}". - format(vnfr_name, conf)) + self._log.debug("VNFR {} initial config: {} for vnfd id {}". + format(vnfr_name, conf, vnfd.id)) if not conf.user_defined_script: - self._log.debug("VNFR {} did not fine user defined script: {}". + self._log.debug("VNFR {} did not find user defined script: {}". format(vnfr_name, conf)) continue @@@ -1360,13 -1358,11 +1358,13 @@@ class XPaths(object) @staticmethod def nsr_config(k=None): - return ("C,/nsr:ns-instance-config/nsr:nsr[nsr:id='{}']".format(k) if k is not None else "") + return ("C,/nsr:ns-instance-config/nsr:nsr" + + ("[nsr:id='{}']".format(k) if k is not None else "")) @staticmethod def vlr(k=None): - return ("D,/vlr:vlr-catalog/vlr:vlr[vlr:id='{}']".format(k) if k is not None else "") + return ("D,/vlr:vlr-catalog/vlr:vlr" + + ("[vlr:id='{}']".format(k) if k is not None else "")) class ConfigManagerDTS(object): ''' This class either reads from DTS or publishes to DTS '''