X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwlaunchpad%2Fplugins%2Frwnsm%2Frift%2Ftasklets%2Frwnsmtasklet%2Fopenmano_nsm.py;h=fa933ba72b500d3535d05f2a0a3518354dbfe429;hb=35d84b48b655192bf5427d88c7c73ecb9925c92b;hp=d6f8483b384f4a62c9896f13273e997301a7f351;hpb=89cd782ebbb7f7b2e6bf45ac590025383a4d26cc;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 d6f8483b..fa933ba7 100644 --- a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py +++ b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/openmano_nsm.py @@ -161,7 +161,8 @@ class VnfrConsoleOperdataDtsHandler(object): class OpenmanoVnfr(object): - def __init__(self, log, loop, cli_api, http_api, vnfr, nsd, ssh_key=None): + def __init__(self, project, log, loop, cli_api, http_api, vnfr, nsd, ssh_key=None): + self._project = project self._log = log self._loop = loop self._cli_api = cli_api @@ -195,7 +196,7 @@ class OpenmanoVnfr(object): @property def openmano_vnfd(self): self._log.debug("Converting vnfd %s from rift to openmano", self.vnfd.id) - openmano_vnfd = rift2openmano.rift2openmano_vnfd(self.vnfd, self.nsd, self._http_api) + openmano_vnfd = rift2openmano.rift2openmano_vnfd(self.vnfd, self.nsd, self._http_api, self._project) return openmano_vnfd @property @@ -226,9 +227,11 @@ class OpenmanoVnfr(object): if self._vnf_id is None: self._log.warning("Openmano vnf id not set. Cannot delete.") return - - self._cli_api.vnf_delete(self._vnf_id) - + try: + self._cli_api.vnf_delete(self._vnf_id) + except Exception as e: + self._log.error(e) + raise e class OpenmanoNSRecordState(Enum): """ Network Service Record State """ @@ -572,7 +575,7 @@ class OpenmanoNsr(object): @asyncio.coroutine def add_vnfr(self, vnfr): - vnfr = OpenmanoVnfr(self._log, self._loop, self._cli_api, self.http_api, + vnfr = OpenmanoVnfr(self._project, self._log, self._loop, self._cli_api, self.http_api, vnfr, nsd=self.nsd, ssh_key=self._ssh_key) yield from vnfr.create() self._vnfrs.append(vnfr) @@ -616,7 +619,14 @@ class OpenmanoNsr(object): deleted_vnf_id_list = [] for vnfr in self._vnfrs: if vnfr.vnfr.vnfd.id not in deleted_vnf_id_list: - vnfr.delete() + try: + vnfr.delete() + except Exception as e: + self._log.error("Failed to delete the vnf at the RO") + if "Resource is not free" in str(e): + self._log.error("Resource is not free, hence forego the vnf-delete") + else: + raise e deleted_vnf_id_list.append(vnfr.vnfr.vnfd.id) @asyncio.coroutine @@ -1206,8 +1216,12 @@ class OpenmanoNsPlugin(nsmpluginbase.NsmPluginBase): del self._openmano_nsrs[nsr_id] def terminate(self, openmano_nsr): - openmano_nsr.terminate() - openmano_nsr.delete() + try: + openmano_nsr.terminate() + openmano_nsr.delete() + except Exception as e: + self._log.error("The NSR terminate failed for {}".format(openmano_nsr)) + raise e @asyncio.coroutine def terminate_vnf(self, nsr, vnfr, scalein=False): @@ -1217,8 +1231,13 @@ class OpenmanoNsPlugin(nsmpluginbase.NsmPluginBase): if scalein: self._log.debug("Terminating Scaling VNFR - {}".format(vnfr)) openmano_vnf_nsr = self._openmano_nsr_by_vnfr_id[vnfr.id] - openmano_vnf_nsr.terminate() - openmano_vnf_nsr.delete() + try: + openmano_vnf_nsr.terminate() + openmano_vnf_nsr.delete() + except Exception as e: + self._log.error("The NSR terminate failed for {}".format(openmano_nsr)) + raise e + yield from openmano_vnf_nsr.remove_vnf(vnfr) @asyncio.coroutine