From: lloretgalleg Date: Wed, 22 Jul 2020 10:13:46 +0000 (+0000) Subject: Bug 1166-vnf-show provides status NOT_INSTANTIATED after a NS is successfully deploye... X-Git-Tag: v8.0.0rc3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=85f53a25e5e2461598d197e68bb6cc5344bc9ba4;p=osm%2FLCM.git Bug 1166-vnf-show provides status NOT_INSTANTIATED after a NS is successfully deployed solved Change-Id: I7abb74ca24b70337804661ae21733af0828311ce Signed-off-by: lloretgalleg --- diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 09f44be4..9267b45e 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -1903,6 +1903,7 @@ class NsLcm(LcmBase): db_vnfrs[vnfr["member-vnf-index-ref"]] = vnfr # vnf's dict indexed by member-index: '1', '2', etc vnfd_id = vnfr["vnfd-id"] # vnfd uuid for this vnf vnfd_ref = vnfr["vnfd-ref"] # vnfd name for this vnf + # if we haven't this vnfd, read it from db if vnfd_id not in db_vnfds: # read from db @@ -1939,6 +1940,7 @@ class NsLcm(LcmBase): # set state to INSTANTIATED. When instantiated NBI will not delete directly db_nsr_update["_admin.nsState"] = "INSTANTIATED" self.update_db_2("nsrs", nsr_id, db_nsr_update) + self.db.set_list("vnfrs", {"nsr-id-ref": nsr_id}, {"_admin.nsState": "INSTANTIATED"}) # n2vc_redesign STEP 2 Deploy Network Scenario stage[0] = 'Stage 2/5: deployment of KDUs, VMs and execution environments.' @@ -3346,6 +3348,12 @@ class NsLcm(LcmBase): operation_state=nslcmop_operation_state, other_update=db_nslcmop_update, ) + if ns_state == "NOT_INSTANTIATED": + try: + self.db.set_list("vnfrs", {"nsr-id-ref": nsr_id}, {"_admin.nsState": "NOT_INSTANTIATED"}) + except DbException as e: + self.logger.warn(logging_text + 'Error writing VNFR status for nsr-id-ref: {} -> {}'. + format(nsr_id, e)) if operation_params: autoremove = operation_params.get("autoremove", False) if nslcmop_operation_state: diff --git a/osm_lcm/tests/test_ns.py b/osm_lcm/tests/test_ns.py index fe2b6522..63bfa351 100644 --- a/osm_lcm/tests/test_ns.py +++ b/osm_lcm/tests/test_ns.py @@ -259,6 +259,12 @@ class TestMyNS(asynctest.TestCase): if not getenv("OSMLCMTEST_DB_NOMOCK"): self.assertTrue(self.db.set_one.called, "db.set_one not called") + db_nsr = self.db.get_one("nsrs", {"_id": nsr_id}) + db_vnfrs_list = self.db.get_list("vnfrs", {"nsr-id-ref": nsr_id}) + self.assertEqual(db_nsr["_admin"].get("nsState"), "INSTANTIATED", "Not instantiated") + for vnfr in db_vnfrs_list: + self.assertEqual(vnfr["_admin"].get("nsState"), "INSTANTIATED", "Not instantiated") + if not getenv("OSMLCMTEST_VCA_NOMOCK"): # check intial-primitives called self.assertTrue(self.my_ns.n2vc.exec_primitive.called, @@ -266,6 +272,7 @@ class TestMyNS(asynctest.TestCase): for _call in self.my_ns.n2vc.exec_primitive.call_args_list: self.assertIn(_call[1]["primitive_name"], ("config", "touch"), "called exec primitive with a primitive different than config or touch") + # TODO add more checks of called methods # TODO add a terminate @@ -607,6 +614,9 @@ class TestMyNS(asynctest.TestCase): self.assertEqual(db_nsr.get("currentOperationID"), None, "currentOperationID different than None") self.assertEqual(db_nsr.get("errorDescription "), None, "errorDescription different than None") self.assertEqual(db_nsr.get("errorDetail"), None, "errorDetail different than None") + db_vnfrs_list = self.db.get_list("vnfrs", {"nsr-id-ref": nsr_id}) + for vnfr in db_vnfrs_list: + self.assertEqual(vnfr["_admin"].get("nsState"), "NOT_INSTANTIATED", "Not instantiated") @asynctest.fail_on(active_handles=True) # all async tasks must be completed async def test_terminate_primitive(self):