From: magnussonl Date: Mon, 20 Jan 2020 17:38:18 +0000 (+0100) Subject: Modifications for test of feature 7953 X-Git-Tag: v7.1.0rc1~28 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=f318b3045ae5e005f6241ec170ea943c92cc67d6;p=osm%2FNBI.git Modifications for test of feature 7953 Updated after review Resolved merge conflict in osm_nbi/__init__.py Change-Id: Ie7fd9c21d3d3369986e96e48b6dc9d29b79b36af Signed-off-by: magnussonl --- diff --git a/osm_nbi/instance_topics.py b/osm_nbi/instance_topics.py index 09a8c1b..8ca35d0 100644 --- a/osm_nbi/instance_topics.py +++ b/osm_nbi/instance_topics.py @@ -947,6 +947,19 @@ class NsLcmOpTopic(BaseTopic): } return nslcmop + def _get_enabled_vims(self, session): + """ + Retrieve and return VIM accounts that are accessible by current user and has state ENABLE + :param session: current session with user information + """ + db_filter = self._get_project_filter(session) + db_filter["_admin.operationalState"] = "ENABLED" + vims = self.db.get_list("vim_accounts", db_filter) + vimAccounts = [] + for vim in vims: + vimAccounts.append(vim['_id']) + return vimAccounts + def new(self, rollback, session, indata=None, kwargs=None, headers=None, slice_object=False): """ Performs a new operation over a ns @@ -1002,6 +1015,9 @@ class NsLcmOpTopic(BaseTopic): nslcmop_desc = self._create_nslcmop(nsInstanceId, operation, indata) _id = nslcmop_desc["_id"] self.format_on_new(nslcmop_desc, session["project_id"], make_public=session["public"]) + if indata.get("placement-engine"): + # Save valid vim accounts in lcm operation descriptor + nslcmop_desc['operationParams']['validVimAccounts'] = self._get_enabled_vims(session) self.db.create("nslcmops", nslcmop_desc) rollback.append({"topic": "nslcmops", "_id": _id}) if not slice_object: diff --git a/osm_nbi/tests/test_instance_topics.py b/osm_nbi/tests/test_instance_topics.py index 5c91114..e6cc254 100644 --- a/osm_nbi/tests/test_instance_topics.py +++ b/osm_nbi/tests/test_instance_topics.py @@ -80,7 +80,7 @@ class TestNsLcmOpTopic(unittest.TestCase): rollback = [] headers = {} - nslcmop_id, _ = self.nslcmop_topic.new(rollback, session, indata=indata, kwargs=None, headers=headers) + nslcmop_id, _ = self.nslcmop_topic.new(rollback, session, indata=deepcopy(indata), kwargs=None, headers=headers) # check nslcmop is created at database self.assertEqual(self.db.create.call_count, 1, "database create not called, or called more than once") diff --git a/osm_nbi/validation.py b/osm_nbi/validation.py index c398a00..69c42ae 100644 --- a/osm_nbi/validation.py +++ b/osm_nbi/validation.py @@ -265,6 +265,8 @@ ns_instantiate = { "nsdId": id_schema, "vimAccountId": id_schema, "wimAccountId": {"OneOf": [id_schema, bool_schema, null_schema]}, + "placement-engine": string_schema, + "placement-constraints": object_schema, "additionalParamsForNs": object_schema, "additionalParamsForVnf": additional_params_for_vnf, "ssh_keys": {"type": "array", "items": {"type": "string"}},