X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=osm_nbi%2Fsubscriptions.py;fp=osm_nbi%2Fsubscriptions.py;h=8132fe9e7329f96a0fe9738c84f7da2933a6f03c;hb=09e6542ceae8ee08ee7cc372f7344a77bc1f5304;hp=64fc2bfbd3f0fd7f63279485b4bbdf3b4ad5e429;hpb=1f1f6e03c7f6d6c1edd708e8d0b980827c7768ab;p=osm%2FNBI.git 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: