From 080e54f642d4b1840ec76cf892f8f891bf109e04 Mon Sep 17 00:00:00 2001 From: Patricia Reinoso Date: Tue, 9 May 2023 15:31:26 +0000 Subject: [PATCH] Remove NsState from VNF record Change-Id: I291b37573f5b6b67daf1f4db416922d70cf019e7 Signed-off-by: Patricia Reinoso --- osm_nbi/instance_topics.py | 2 +- osm_nbi/tests/test_db_descriptors.py | 2 -- osm_nbi/tests/test_instance_topics.py | 13 +++++++++---- osm_nbi/tests/test_osm_vnfm.py | 7 +++---- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index c2cd9dd..060e056 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -414,7 +414,7 @@ class NsrTopic(BaseTopic): rollback.append({"topic": "nsrs", "_id": nsr_descriptor["id"]}) def _add_vnfr_to_db(self, vnfr_descriptor, rollback, session): - self.format_on_new( + BaseTopic.format_on_new( vnfr_descriptor, session["project_id"], make_public=session["public"] ) self.db.create("vnfrs", vnfr_descriptor) diff --git a/osm_nbi/tests/test_db_descriptors.py b/osm_nbi/tests/test_db_descriptors.py index 1914190..25817b1 100644 --- a/osm_nbi/tests/test_db_descriptors.py +++ b/osm_nbi/tests/test_db_descriptors.py @@ -471,7 +471,6 @@ db_vnfrs_text = """ - _admin: created: 1566823354.3668208 modified: 1566823354.3668208 - nsState: NOT_INSTANTIATED projects_read: - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 projects_write: @@ -550,7 +549,6 @@ db_vnfrs_text = """ - _admin: created: 1566823354.3703845 modified: 1566823354.3703845 - nsState: NOT_INSTANTIATED projects_read: - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4 projects_write: diff --git a/osm_nbi/tests/test_instance_topics.py b/osm_nbi/tests/test_instance_topics.py index 0d4adec..96da68c 100644 --- a/osm_nbi/tests/test_instance_topics.py +++ b/osm_nbi/tests/test_instance_topics.py @@ -615,6 +615,10 @@ class TestNsrTopic(unittest.TestCase): ) else: nsr_id = created_item["nsr-id-ref"] + self.assertTrue( + "nsState" not in created_item["_admin"], + "Database VNF record must not contain '_admin.nsState'", + ) elif _call[0][0] == "nsrs": created_nsrs.append(created_item) @@ -624,6 +628,11 @@ class TestNsrTopic(unittest.TestCase): ) else: nsr_id = created_item["_id"] + + self.assertTrue( + created_item["_admin"]["nsState"] == "NOT_INSTANTIATED", + "Database record must contain '_admin.nsState=NOT INSTANTIATE'", + ) else: assert True, "created an unknown record {} at database".format( _call[0][0] @@ -638,10 +647,6 @@ class TestNsrTopic(unittest.TestCase): created_item["_admin"], "Database record must contain '_admin.created'", ) - self.assertTrue( - created_item["_admin"]["nsState"] == "NOT_INSTANTIATED", - "Database record must contain '_admin.nstate=NOT INSTANTIATE'", - ) self.assertEqual( len(created_vnfrs), 2, "created a mismatch number of vnfr at database" diff --git a/osm_nbi/tests/test_osm_vnfm.py b/osm_nbi/tests/test_osm_vnfm.py index b298828..c3947b9 100644 --- a/osm_nbi/tests/test_osm_vnfm.py +++ b/osm_nbi/tests/test_osm_vnfm.py @@ -88,10 +88,9 @@ class TestVnfInstances(unittest.TestCase): self.assertEqual( vnfr_id, vnfr["id"], "Mismatch between return id and database id" ) - self.assertEqual( - "NOT_INSTANTIATED", - vnfr["_admin"]["nsState"], - "Database record must contain 'nsState' NOT_INSTANTIATED", + self.assertTrue( + "nsState" not in vnfr["_admin"], + "Database VNF record must not contain 'nsState'", ) self.assertEqual( self.vnfd_id, -- 2.25.1