From ee7f623ef6b19a95f7b3316e497317b8e773a000 Mon Sep 17 00:00:00 2001 From: krishnaa96 Date: Thu, 8 Apr 2021 15:12:52 +0530 Subject: Update AAI plugin for NSSI selection Slice profiles are related to NSSI directly as service-instance instead of allotted resource Issue-ID: OPTFRA-937 Signed-off-by: krishnaa96 Change-Id: I7ffc948b66f13fb7813acbb4151575c838e50141 --- conductor/conductor/data/plugins/inventory_provider/aai.py | 4 +++- .../conductor/data/plugins/inventory_provider/utils/aai_utils.py | 2 +- .../functional/simulators/aaisim/responses/get_nssi_response.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/conductor/conductor/data/plugins/inventory_provider/aai.py b/conductor/conductor/data/plugins/inventory_provider/aai.py index fd5ca3f..93b0a3b 100644 --- a/conductor/conductor/data/plugins/inventory_provider/aai.py +++ b/conductor/conductor/data/plugins/inventory_provider/aai.py @@ -1917,7 +1917,9 @@ class AAI(base.InventoryProviderBase): return candidates def get_profile_instances(self, nxi_instance): - related_nodes = self._get_aai_rel_link_data(nxi_instance, "allotted-resource", + slice_role = nxi_instance['service-role'] + related_key = "allotted-resource" if slice_role == 'nsi' else 'service-instance' + related_nodes = self._get_aai_rel_link_data(nxi_instance, related_key, "service-instance.service-instance-id") profile_instances = [] for node in related_nodes: diff --git a/conductor/conductor/data/plugins/inventory_provider/utils/aai_utils.py b/conductor/conductor/data/plugins/inventory_provider/utils/aai_utils.py index 4c6accc..c88b459 100644 --- a/conductor/conductor/data/plugins/inventory_provider/utils/aai_utils.py +++ b/conductor/conductor/data/plugins/inventory_provider/utils/aai_utils.py @@ -99,4 +99,4 @@ def get_model_ver_info(model_version): def get_profiles(profile_instances, profile_type): profile_type_plural = profile_type + 's' - return [x[profile_type_plural][profile_type][0] for x in profile_instances] + return [x[profile_type_plural][profile_type][0] for x in profile_instances if x.get(profile_type_plural)] diff --git a/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json b/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json index 0e76264..bab57df 100644 --- a/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json +++ b/conductor/conductor/tests/functional/simulators/aaisim/responses/get_nssi_response.json @@ -36,7 +36,7 @@ } ] }, { - "related-to": "allotted-resource", + "related-to": "service-instance", "relationship-label": "org.onap.relationships.inventory.Uses", "related-link": "/aai/v21/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/1c7046f2-a5a3-4d7f-9da8-388ee641a795/allotted-resources/allotted-resource/462e46c2-cd84-45e4-a6c1-77f4ef88328d", "relationship-data": [{ -- cgit 1.2.3-korg