X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwnsm%2Frift%2Ftasklets%2Frwnsmtasklet%2Fopenmano_nsm.py;h=2bb4d189c4ca9968aaf221fadb199158c0c6ab33;hb=a3bb91f092d378448cb870eccd45d43865de143c;hp=d53d701dcfded52dede0d03aef71a88f5545074b;hpb=c000b620bb2cbf1be0a04d6cdf79151b23b8db65;p=osm%2FSO.git diff --git a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py index d53d701d..2bb4d189 100644 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py @@ -102,7 +102,7 @@ class VnfrConsoleOperdataDtsHandler(object): ) if action == rwdts.QueryAction.READ: - schema = RwVnfrYang.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur.schema() + schema = RwVnfrYang.YangData_RwProject_Project_VnfrConsole_Vnfr_Vdur.schema() path_entry = schema.keyspec_to_entry(ks_path) try: @@ -118,7 +118,7 @@ class VnfrConsoleOperdataDtsHandler(object): self._nsr._nsr_uuid, self._vdur_id ) - vdur_console = RwVnfrYang.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur() + vdur_console = RwVnfrYang.YangData_RwProject_Project_VnfrConsole_Vnfr_Vdur() vdur_console.id = self._vdur_id if console_url: vdur_console.console_url = console_url @@ -128,7 +128,7 @@ class VnfrConsoleOperdataDtsHandler(object): except openmano_client.InstanceStatusError as e: self._log.error("Could not get NS instance console URL: %s", str(e)) - vdur_console = RwVnfrYang.YangData_RwVnfr_VnfrConsole_Vnfr_Vdur() + vdur_console = RwVnfrYang.YangData_RwProject_Project_VnfrConsole_Vnfr_Vdur() vdur_console.id = self._vdur_id vdur_console.console_url = 'none' @@ -225,7 +225,6 @@ class OpenmanoVnfr(object): self._created = True - @asyncio.coroutine def delete(self): if not self._created: return @@ -235,11 +234,7 @@ class OpenmanoVnfr(object): self._log.warning("Openmano vnf id not set. Cannot delete.") return - yield from self._loop.run_in_executor( - None, - self._cli_api.vnf_delete, - self._vnf_id, - ) + self._cli_api.vnf_delete(self._vnf_id) class OpenmanoNSRecordState(Enum): @@ -260,6 +255,7 @@ class OpenmanoNSRecordState(Enum): class OpenmanoNsr(object): TIMEOUT_SECS = 300 + INSTANCE_TERMINATE_TIMEOUT = 60 def __init__(self, dts, log, loop, publisher, cli_api, http_api, nsd_msg, nsr_config_msg,key_pairs): self._dts = dts @@ -446,23 +442,20 @@ class OpenmanoNsr(object): yield from vnfr.create() self._vnfrs.append(vnfr) - @asyncio.coroutine def delete(self): if not self._created: self._log.debug("NSD wasn't created. Skipping delete.") return self._log.debug("Deleting openmano nsr") - - yield from self._loop.run_in_executor( - None, - self._cli_api.ns_delete, - self._nsd_uuid, - ) + self._cli_api.ns_delete(self._nsd_uuid) self._log.debug("Deleting openmano vnfrs") + deleted_vnf_id_list = [] for vnfr in self._vnfrs: - yield from vnfr.delete() + if vnfr.vnfr.vnfd.id not in deleted_vnf_id_list: + vnfr.delete() + deleted_vnf_id_list.append(vnfr.vnfr.vnfd.id) @asyncio.coroutine @@ -678,7 +671,6 @@ class OpenmanoNsr(object): yield from self._publisher.publish_vnfr(None, vnfr_msg) active_vnfs.append(vnfr) - except Exception as e: vnfr_msg.operational_status = "failed" self._state = OpenmanoNSRecordState.FAILED @@ -725,26 +717,22 @@ class OpenmanoNsr(object): self.instance_monitor_task(), loop=self._loop ) - @asyncio.coroutine def terminate(self): - - for _,handler in self._vdur_console_handler.items(): - handler._regh.deregister() - if self._nsr_uuid is None: - self._log.warning("Cannot terminate an un-instantiated nsr") - return + start_time = time.time() + while ((time.time() - start_time) < OpenmanoNsr.INSTANCE_TERMINATE_TIMEOUT) and (self._nsr_uuid is None): + time.sleep(5) + self._log.warning("Waiting for nsr to get instatiated") + if self._nsr_uuid is None: + self._log.warning("Cannot terminate an un-instantiated nsr") + return if self._monitor_task is not None: self._monitor_task.cancel() self._monitor_task = None self._log.debug("Terminating openmano nsr") - yield from self._loop.run_in_executor( - None, - self._cli_api.ns_terminate, - self._nsr_uuid, - ) + self._cli_api.ns_terminate(self._nsr_uuid) @asyncio.coroutine def create_vlr(self,vlr): @@ -885,7 +873,7 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase): def vnfr_uptime_update(self, vnfr): try: - vnfr_ = RwVnfrYang.YangData_Vnfr_VnfrCatalog_Vnfr.from_dict({'id': vnfr.id}) + vnfr_ = RwVnfrYang.YangData_RwProject_Project_VnfrCatalog_Vnfr.from_dict({'id': vnfr.id}) while True: vnfr_.uptime = int(time.time()) - vnfr._create_time yield from self._publisher.publish_vnfr(None, vnfr_) @@ -914,8 +902,14 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase): nsr_id = nsr.id openmano_nsr = self._openmano_nsrs[nsr_id] - yield from openmano_nsr.terminate() - yield from openmano_nsr.delete() + for _,handler in openmano_nsr._vdur_console_handler.items(): + handler._regh.deregister() + + yield from self._loop.run_in_executor( + None, + self.terminate, + openmano_nsr, + ) with self._dts.transaction() as xact: for vnfr in openmano_nsr.vnfrs: @@ -924,6 +918,10 @@ class OpenmanoNsPlugin(rwnsmplugin.NsmPluginBase): del self._openmano_nsrs[nsr_id] + def terminate(self, openmano_nsr): + openmano_nsr.terminate() + openmano_nsr.delete() + @asyncio.coroutine def terminate_vnf(self, vnfr): """