X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fsubscriptions.py;h=8132fe9e7329f96a0fe9738c84f7da2933a6f03c;hp=64fc2bfbd3f0fd7f63279485b4bbdf3b4ad5e429;hb=e4a07d5db1e38e6a52788d5788c6cc3396e1052d;hpb=932499c09d729d235ccd1fc002156b8b23e9f165;ds=sidebyside diff --git a/osm_nbi/subscriptions.py b/osm_nbi/subscriptions.py index 64fc2bf..8132fe9 100644 --- a/osm_nbi/subscriptions.py +++ b/osm_nbi/subscriptions.py @@ -99,7 +99,7 @@ class SubscriptionThread(threading.Thread): self.logger.debug("Starting") while True: try: - self.aiomain_task = asyncio.ensure_future(self.msg.aioread("ns", loop=self.loop, + self.aiomain_task = asyncio.ensure_future(self.msg.aioread(("ns", "nsi"), loop=self.loop, callback=self._msg_callback), loop=self.loop) self.loop.run_until_complete(self.aiomain_task) @@ -122,12 +122,19 @@ class SubscriptionThread(threading.Thread): """ try: if topic == "ns": - if command == "terminated": + if command == "terminated" and params["operationState"] in ("COMPLETED", "PARTIALLY_COMPLETED"): self.logger.debug("received ns terminated {}".format(params)) if params.get("autoremove"): self.engine.del_item(self.internal_session, "nsrs", _id=params["nsr_id"]) self.logger.debug("ns={} deleted from database".format(params["nsr_id"])) return + if topic == "nsi": + if command == "terminated" and params["operationState"] in ("COMPLETED", "PARTIALLY_COMPLETED"): + self.logger.debug("received nsi terminated {}".format(params)) + if params.get("autoremove"): + self.engine.del_item(self.internal_session, "nsis", _id=params["nsir_id"]) + self.logger.debug("nsis={} deleted from database".format(params["nsir_id"])) + return except (EngineException, DbException, MsgException) as e: self.logger.error("Error while processing topic={} command={}: {}".format(topic, command, e)) except Exception as e: