summaryrefslogtreecommitdiffstats
path: root/conductor
diff options
context:
space:
mode:
authorShankaranarayanan Puzhavakath Narayanan <snarayanan@research.att.com>2020-04-29 01:40:15 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-29 01:40:15 +0000
commitca1d19b785a9ffca4946a8a10cf96fd674f3d400 (patch)
tree9b878602a861e6a753954e7425543cfd0db06119 /conductor
parentda6653e0886ea6e20b24324cb608adaf542c5b10 (diff)
parentbf399d2677e5942fe9d07a508774ae9aceaf3e91 (diff)
Merge "Add nsi info to the candidates"
Diffstat (limited to 'conductor')
-rw-r--r--conductor/conductor/data/plugins/inventory_provider/aai.py40
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json5
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py9
3 files changed, 37 insertions, 17 deletions
diff --git a/conductor/conductor/data/plugins/inventory_provider/aai.py b/conductor/conductor/data/plugins/inventory_provider/aai.py
index ddb857b..ae3f203 100644
--- a/conductor/conductor/data/plugins/inventory_provider/aai.py
+++ b/conductor/conductor/data/plugins/inventory_provider/aai.py
@@ -1880,9 +1880,9 @@ class AAI(base.InventoryProviderBase):
elif inventory_type == 'nssi':
if filtering_attributes and model_invariant_id:
- resolved_demands[name] = self.get_nssi_candidates(filtering_attributes,
- model_invariant_id, model_version_id,
- service_role, candidate_uniqueness)
+ resolved_demands[name].append(self.get_nssi_candidates(filtering_attributes,
+ model_invariant_id, model_version_id,
+ service_role, candidate_uniqueness))
else:
LOG.error("Unknown inventory_type "
@@ -1977,7 +1977,6 @@ class AAI(base.InventoryProviderBase):
nssi_instances = response_body.get("service-instance", [])
for nssi_instance in nssi_instances:
-
inventory_attributes = dict()
inventory_attributes["orchestration-status"] = nssi_instance.get('orchestration-status')
inventory_attributes["service-role"] = nssi_instance.get('service-role')
@@ -1985,17 +1984,9 @@ class AAI(base.InventoryProviderBase):
if self.match_inventory_attributes(filtering_attributes, inventory_attributes,
nssi_instance.get('service-instance-id')):
- properties = list()
- relationships = nssi_instance['relationship-list']['relationship']
- for relationship in relationships:
- if relationship['related-to'] == 'service-instance':
- properties = relationship['related-to-property']
+ nsi_link = self._get_aai_rel_link(response_body, 'service-instance')
- nsi_name = None
- if properties:
- for prop in properties:
- if prop['property-key'] == 'service-instance.service-instance-name':
- nsi_name = prop['property-value']
+ nsi_info = self.get_nsi_info(nsi_link)
slice_profiles = nssi_instance.get('slice-profiles').get('slice-profile')
slice_profile = min(slice_profiles, key=lambda x: x['latency'])
@@ -2029,8 +2020,25 @@ class AAI(base.InventoryProviderBase):
candidate['service_area_dimension'] = slice_profile.get('service-area-dimension')
candidate['cs_availability'] = slice_profile.get('cs-availability')
candidate['uniqueness'] = candidate_uniqueness
- if nsi_name:
- candidate['nsi_name'] = nsi_name
+ if nsi_info:
+ candidate['nsi_name'] = nsi_info.get('instance_name')
+ candidate['nsi_id'] = nsi_info.get('instance_id')
+ candidate['nsi_model_version_id'] = nsi_info.get('model_version_id')
+ candidate['nsi_model_invariant_id'] = nsi_info.get('model_invariant_id')
candidates.append(candidate)
return candidates
+
+ def get_nsi_info(self, nsi_link):
+ nsi_info = dict()
+ if nsi_link:
+ nsi_link_path = self._get_aai_path_from_link(nsi_link)
+ nsi_response = self._request('get', nsi_link_path, data=None)
+ if nsi_response and nsi_response.status_code == 200:
+ nsi_response_body = nsi_response.json()
+ nsi_info['instance_id'] = nsi_response_body.get('service-instance-id')
+ nsi_info['instance_name'] = nsi_response_body.get('service-instance-name')
+ nsi_info['model_version_id'] = nsi_response_body.get('model-version-id')
+ nsi_info['model_invariant_id'] = nsi_response_body.get('model-invariant-id')
+
+ return nsi_info
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json
index a26f322..2be5561 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json
@@ -27,7 +27,10 @@
"reliability":null,
"cost":1.0,
"nsi_name": "nsi_test_0211",
+ "nsi_id": "4115d3c8-dd59-45d6-b09d-e756dee9b518",
+ "nsi_model_version_id": "8b664b11-6646-4776-9f59-5c3de46da2d6",
+ "nsi_model_invariant_id": "39b10fe6-efcc-40bc-8184-c38414b80771",
"instance_name": "nssi_test_0211",
"uniqueness": "true"
}
-] \ No newline at end of file
+]
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
index cf18087..295057f 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py
@@ -738,6 +738,15 @@ tenant/3c6c471ada7747fe8ff7f28e100b61e8/vservers/vserver/00bddefc-126e-4e4f-a18d
nssi_candidates_file = './conductor/tests/unit/data/plugins/inventory_provider/nssi_candidate.json'
nssi_candidates = json.loads(open(nssi_candidates_file).read())
+ nsi_info = {'instance_name': 'nsi_test_0211',
+ 'instance_id': '4115d3c8-dd59-45d6-b09d-e756dee9b518',
+ 'model_version_id': '8b664b11-6646-4776-9f59-5c3de46da2d6',
+ 'model_invariant_id': '39b10fe6-efcc-40bc-8184-c38414b80771'}
+
+ self.nsi_patcher = mock.patch('conductor.data.plugins.inventory_provider.aai.AAI.get_nsi_info',
+ return_value=nsi_info)
+ self.nsi_patcher.start()
+
service_role = 'nssi'
model_invariant_id = '21d57d4b-52ad-4d3c-a798-248b5bb9124a'
model_version_id = 'bfba363e-e39c-4bd9-a9d5-1371c28f4d22'