summaryrefslogtreecommitdiffstats
path: root/conductor
diff options
context:
space:
mode:
authordhebeha <dhebeha.mj71@wipro.com>2020-08-24 19:50:43 +0530
committerdhebeha mj <dhebeha.mj71@wipro.com>2020-09-01 07:36:42 +0000
commit11f579c76967eec1c4959ba02dbdfc6f19575a84 (patch)
treedae98f32711d544b2c541bcf6ad6c750436aaafe /conductor
parent58926cce98f4c590a98e042c94c7ea0ddeff4672 (diff)
Add support for NSI candidate
Issue-ID: OPTFRA-802 Signed-off-by: dhebeha <dhebeha.mj71@wipro.com> Change-Id: Ibcc6760e6cc80a507a2ea2efab7088e1f09f5672
Diffstat (limited to 'conductor')
-rw-r--r--conductor/conductor/data/plugins/inventory_provider/aai.py2
-rw-r--r--conductor/conductor/data/service.py29
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_candidate.json29
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_demand_list.json17
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_response.json66
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/test_aai.py47
-rw-r--r--conductor/tox.ini2
7 files changed, 174 insertions, 18 deletions
diff --git a/conductor/conductor/data/plugins/inventory_provider/aai.py b/conductor/conductor/data/plugins/inventory_provider/aai.py
index 9defe94..dc30a59 100644
--- a/conductor/conductor/data/plugins/inventory_provider/aai.py
+++ b/conductor/conductor/data/plugins/inventory_provider/aai.py
@@ -1649,7 +1649,7 @@ class AAI(base.InventoryProviderBase):
# add candidate to demand candidates
resolved_demands[name].append(candidate)
- elif inventory_type == 'nssi':
+ elif inventory_type == 'nssi' or inventory_type == 'nsi':
if filtering_attributes and model_invariant_id:
second_level_match = aai_utils.get_first_level_and_second_level_filter(filtering_attributes,
"service_instance")
diff --git a/conductor/conductor/data/service.py b/conductor/conductor/data/service.py
index 07f66c3..67d3c8c 100644
--- a/conductor/conductor/data/service.py
+++ b/conductor/conductor/data/service.py
@@ -54,15 +54,17 @@ DATA_OPTS = [
'mode. When set to False, data will flush any abandoned '
'messages at startup.'),
cfg.FloatOpt('existing_placement_cost',
- default=-8000.0,
- help='Default value is -8000, which is the diameter of the earth. '
- 'The distance cannot larger than this value'),
+ default=-8000.0,
+ help='Default value is -8000, which is the diameter of the earth.The distance cannot larger than '
+ 'this value'),
cfg.FloatOpt('cloud_candidate_cost',
- default=2.0),
+ default=2.0),
cfg.FloatOpt('service_candidate_cost',
- default=1.0),
+ default=1.0),
cfg.FloatOpt('nssi_candidate_cost',
default=1.0),
+ cfg.FloatOpt('nsi_candidate_cost',
+ default=1.0),
]
CONF.register_opts(DATA_OPTS, group='data')
@@ -84,14 +86,11 @@ class DataServiceLauncher(object):
def init_extension_managers(self, conf):
"""Initialize extension managers."""
- self.ip_ext_manager = (
- ip_ext.Manager(conf, 'conductor.inventory_provider.plugin'))
+ self.ip_ext_manager = (ip_ext.Manager(conf, 'conductor.inventory_provider.plugin'))
self.ip_ext_manager.initialize()
- self.vc_ext_manager = (
- vc_ext.Manager(conf, 'conductor.vim_controller.plugin'))
+ self.vc_ext_manager = (vc_ext.Manager(conf, 'conductor.vim_controller.plugin'))
self.vc_ext_manager.initialize()
- self.sc_ext_manager = (
- sc_ext.Manager(conf, 'conductor.service_controller.plugin'))
+ self.sc_ext_manager = (sc_ext.Manager(conf, 'conductor.service_controller.plugin'))
self.sc_ext_manager.initialize()
def run(self):
@@ -237,7 +236,7 @@ class DataEndpoint(object):
discard_set.add(candidate.get("candidate_id"))
return discard_set
- #(TODO:Larry) merge this function with the "get_candidate_discard_set"
+ # (TODO:Larry) merge this function with the "get_candidate_discard_set"
def get_candidate_discard_set_by_cloud_region(self, value, candidate_list, value_attrib):
discard_set = set()
@@ -260,7 +259,6 @@ class DataEndpoint(object):
return discard_set
-
def get_inventory_group_candidates(self, ctx, arg):
candidate_list = arg["candidate_list"]
resolved_candidate = arg["resolved_candidate"]
@@ -639,7 +637,7 @@ class DataEndpoint(object):
self.triage_data_trans['plan_name'] = triage_translator_data['plan_name']
self.triage_data_trans['plan_id'] = triage_translator_data['plan_id']
self.triage_data_trans['translator_triage'].append(triage_translator_data['dropped_candidates'])
- elif (not self.triage_data_trans['plan_id'] == triage_translator_data['plan_id']) :
+ elif not self.triage_data_trans['plan_id'] == triage_translator_data['plan_id'] :
self.triage_data_trans = {
'plan_id': None,
'plan_name': None,
@@ -655,7 +653,7 @@ class DataEndpoint(object):
return {'response': {'resolved_demands': resolved_demands,
'trans': self.triage_data_trans},
- 'error': error }
+ 'error': error}
def resolve_location(self, ctx, arg):
@@ -667,7 +665,6 @@ class DataEndpoint(object):
host_name = arg.get('host_name')
clli_code = arg.get('clli_code')
-
if host_name:
results = self.ip_ext_manager.map_method(
'resolve_host_location',
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_candidate.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_candidate.json
new file mode 100644
index 0000000..edd5d78
--- /dev/null
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_candidate.json
@@ -0,0 +1,29 @@
+[
+ {
+ "candidate_id":"89ad9f49-4201-4e3a-aac1-b0f27902c299",
+ "inventory_type":"nsi",
+ "uniqueness": "true",
+ "cost":1.0,
+ "inventory_provider": "aai",
+ "instance_name": "nsi_test_0211",
+ "instance_id": "4115d3c8-dd59-45d6-b09d-e756dee9b518",
+ "creation_cost": 1,
+
+ "profile_id": "89ad9f49-4201-4e3a-aac1-b0f27902c299",
+ "latency": 20,
+ "max_number_of_UEs": 10,
+ "coverage_area_TA_list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue_mobility_level": "stationary",
+ "resource_sharing_level": "0",
+ "exp_data_rate_UL": 100,
+ "exp_data_rate_DL": 100,
+ "activity_factor": 0,
+ "e2e_latency": 20,
+ "jitter": 1,
+ "survival_time": 0,
+ "exp_data_rate": 100,
+ "payload_size": 0,
+ "traffic_density": 0,
+ "conn_density": 100
+ }
+]
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_demand_list.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_demand_list.json
new file mode 100644
index 0000000..7f48042
--- /dev/null
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_demand_list.json
@@ -0,0 +1,17 @@
+{
+ "embb_nst": [{
+ "inventory_provider": "aai",
+ "inventory_type": "nsi",
+ "unique": "true",
+ "filtering_attributes": {
+ "model-version-id": "67ea363e-e39c-4bd9-a9d5-1371c28f4d22",
+ "model-invariant-id": "51e57d4b-52ad-4d3c-a798-248b5bb9124a",
+ "orchestration-status": "active",
+ "service-role": "nsi",
+ "environment-context": "shared"
+ },
+ "default_attributes": {
+ "creation-cost": 1
+ }
+ }]
+}
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_response.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_response.json
new file mode 100644
index 0000000..8acb33d
--- /dev/null
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/nsi_response.json
@@ -0,0 +1,66 @@
+{
+ "service-instance": [
+ {
+ "service-instance-id": "4115d3c8-dd59-45d6-b09d-e756dee9b518",
+ "service-instance-name": "nsi_test_0211",
+ "service-type": "embb",
+ "service-role": "nsi",
+ "environment-context": "shared",
+ "model-invariant-id": "51e57d4b-52ad-4d3c-a798-248b5bb9124a",
+ "model-version-id": "67ea363e-e39c-4bd9-a9d5-1371c28f4d22",
+ "resource-version": "1581418601616",
+ "orchestration-status": "active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-to": "service-instance",
+ "relationship-label": "org.onap.relationships.inventory.ComposedOf",
+ "related-link": "/aai/v16/business/customers/customer/5GCustomer/service-subscriptions/service-subscription/5G/service-instances/service-instance/1a636c4d-5e76-427e-bfd6-241a947224b0",
+ "relationship-data": [
+ {
+ "relationship-key": "customer.global-customer-id",
+ "relationship-value": "5GCustomer"
+ },
+ {
+ "relationship-key": "service-subscription.service-type",
+ "relationship-value": "5G"
+ },
+ {
+ "relationship-key": "service-instance.service-instance-id",
+ "relationship-value": "1a636c4d-5e76-427e-bfd6-241a947224b0"
+ }
+ ],
+ "related-to-property": [
+ {
+ "property-key": "service-instance.service-instance-name",
+ "property-value": "nssi_test_0211"
+ }
+ ]
+ }
+ ]
+ },
+ "service-profiles": {
+ "service-profile": [
+ {
+ "profile-id": "89ad9f49-4201-4e3a-aac1-b0f27902c299",
+ "latency": 20,
+ "max-number-of-UEs": 10,
+ "coverage-area-TA-list": "[{\"province\":\"??\",\"city\":\"???\",\"county\":\"???\",\"street\":\"?????\"}]",
+ "ue-mobility-level": "stationary",
+ "resource-sharing-level": "0",
+ "exp-data-rate-UL": 100,
+ "exp-data-rate-DL": 100,
+ "activity-factor": 0,
+ "e2e-latency": 20,
+ "jitter": 1,
+ "survival-time": 0,
+ "exp-data-rate": 100,
+ "payload-size": 0,
+ "traffic-density": 0,
+ "conn-density": 100,
+ "resource-version": "1581418602494"
+ }
+ ]
+ }
+}
+ ]}
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 4c38feb..157c1d9 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
@@ -782,3 +782,50 @@ tenant/3c6c471ada7747fe8ff7f28e100b61e8/vservers/vserver/00bddefc-126e-4e4f-a18d
self.assertEqual(result, self.aai_ep.resolve_demands(demands_list, plan_info=plan_info,
triage_translator_data=triage_translator_data))
+
+ def test_filter_nsi_candidates(self):
+ nsi_response_file = './conductor/tests/unit/data/plugins/inventory_provider/nsi_response.json'
+ nsi_response = json.loads(open(nsi_response_file).read())
+ nsi_candidates_file = './conductor/tests/unit/data/plugins/inventory_provider/nsi_candidate.json'
+ nsi_candidates = json.loads(open(nsi_candidates_file).read())
+
+ service_role = 'nsi'
+ second_level_filter = dict()
+ second_level_filter['service-role'] = service_role
+ default_attributes = dict()
+ default_attributes['creation_cost'] = 1
+
+ self.assertEqual(nsi_candidates, self.aai_ep.filter_nxi_candidates(nsi_response, second_level_filter,
+ default_attributes, "true", service_role))
+ nsi_response['service-instance'][0]['service-role'] = 'service'
+
+ self.assertEqual([], self.aai_ep.filter_nxi_candidates(nsi_response, second_level_filter, default_attributes,
+ "true", service_role))
+
+ def test_resolve_demands_inventory_type_nsi(self):
+ self.aai_ep.conf.HPA_enabled = True
+ TraigeTranslator.getPlanIdNAme = mock.MagicMock(return_value=None)
+ TraigeTranslator.addDemandsTriageTranslator = mock.MagicMock(return_value=None)
+
+ plan_info = {
+ 'plan_name': 'name',
+ 'plan_id': 'id'
+ }
+ triage_translator_data = None
+
+ demands_list_file = './conductor/tests/unit/data/plugins/inventory_provider/nsi_demand_list.json'
+ demands_list = json.loads(open(demands_list_file).read())
+
+ nsi_response_file = './conductor/tests/unit/data/plugins/inventory_provider/nsi_response.json'
+ nsi_response = json.loads(open(nsi_response_file).read())
+ nsi_candidates_file = './conductor/tests/unit/data/plugins/inventory_provider/nsi_candidate.json'
+ nsi_candidates = json.loads(open(nsi_candidates_file).read())
+ result = dict()
+ result['embb_nst'] = nsi_candidates
+
+ self.mock_get_nxi_candidates = mock.patch.object(AAI, 'get_nxi_candidates',
+ return_value=nsi_response)
+ self.mock_get_nxi_candidates.start()
+ self.maxDiff = None
+ self.assertEqual(result, self.aai_ep.resolve_demands(demands_list, plan_info=plan_info,
+ triage_translator_data=triage_translator_data))
diff --git a/conductor/tox.ini b/conductor/tox.ini
index b65abd4..d6d120d 100644
--- a/conductor/tox.ini
+++ b/conductor/tox.ini
@@ -62,7 +62,7 @@ commands = bash -x oslo_debug_helper {posargs}
[flake8]
select = E,H,W,F
max-line-length = 119
-exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,install-guide,*/tests/*
+exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build,install-guide,*/tests/*,conductor/data/service.py
show-source = True
ignore= W503 #conflict with W504
per-file-ignores= conductor/data/plugins/inventory_provider/aai.py:F821