summaryrefslogtreecommitdiffstats
path: root/conductor
diff options
context:
space:
mode:
Diffstat (limited to 'conductor')
-rw-r--r--conductor/conductor/data/plugins/inventory_provider/candidates/slice_profiles_candidate.py13
-rw-r--r--conductor/conductor/data/plugins/inventory_provider/cps.py145
-rw-r--r--conductor/conductor/data/plugins/inventory_provider/generator.py43
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/coverage_area.json26
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/gen_demand_list.json12
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/generated_candidates.json84
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/resolved_demands_gen.json5
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/test_candidates.py4
-rw-r--r--conductor/conductor/tests/unit/data/plugins/inventory_provider/test_generator.py28
9 files changed, 297 insertions, 63 deletions
diff --git a/conductor/conductor/data/plugins/inventory_provider/candidates/slice_profiles_candidate.py b/conductor/conductor/data/plugins/inventory_provider/candidates/slice_profiles_candidate.py
index db10ee5..83ca4d7 100644
--- a/conductor/conductor/data/plugins/inventory_provider/candidates/slice_profiles_candidate.py
+++ b/conductor/conductor/data/plugins/inventory_provider/candidates/slice_profiles_candidate.py
@@ -41,7 +41,6 @@ ATTRIBUTE_AGGREGATION = {
"exp_data_rate_ul": min,
"exp_data_rate_dl": min,
"ue_mobility_level": copy_first,
- "coverage_area_ta_list": copy_first,
"activity_factor": copy_first,
"survival_time": copy_first,
"max_number_of_conns": copy_first
@@ -58,6 +57,7 @@ class SliceProfilesCandidate(Candidate):
else:
self.slice_requirements = None
self.other = kwargs["default_fields"]
+ self.coverage_area = kwargs["coverage_area"]
def convert_nested_dict_to_dict(self):
nested_dict = self.__dict__
@@ -86,9 +86,12 @@ def get_slice_requirements(subnet_requirements):
slice_profile_tuples = {}
for key in slice_requirements_keys:
- attributes = []
- for slice_profile in subnet_requirements.values():
- attributes.append(slice_profile.get(key))
- slice_profile_tuples[key] = attributes
+ if key == "coverage_area_ta_list":
+ pass
+ else:
+ attributes = []
+ for slice_profile in subnet_requirements.values():
+ attributes.append(slice_profile.get(key))
+ slice_profile_tuples[key] = attributes
return {attr: ATTRIBUTE_AGGREGATION[attr](values) for attr, values in slice_profile_tuples.items()}
diff --git a/conductor/conductor/data/plugins/inventory_provider/cps.py b/conductor/conductor/data/plugins/inventory_provider/cps.py
new file mode 100644
index 0000000..c92d167
--- /dev/null
+++ b/conductor/conductor/data/plugins/inventory_provider/cps.py
@@ -0,0 +1,145 @@
+#
+# -------------------------------------------------------------------------
+# Copyright (C) 2021 Wipro Limited.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+from conductor.common import rest
+from conductor.i18n import _LE
+from oslo_config import cfg
+from oslo_log import log
+import time
+import uuid
+
+
+LOG = log.getLogger(__name__)
+
+CONF = cfg.CONF
+
+CPS_OPTS = [
+ cfg.StrOpt('table_prefix',
+ default='cps',
+ help='Data Store table prefix.'),
+ cfg.StrOpt('server_url',
+ default='https://controller:8443/cps',
+ help='Base URL for CPS, up to and not including '
+ 'the version, and without a trailing slash.'),
+ cfg.StrOpt('cps_rest_timeout',
+ default='30',
+ help='Timeout for CPS Rest Call'),
+ cfg.StrOpt('cps_retries',
+ default='3',
+ help='Number of retry for CPS Rest Call'),
+ # TODO(larry): follow-up with ONAP people on this (CPS basic auth username and password?)
+ cfg.StrOpt('certificate_file',
+ default='certificate.pem',
+ help='SSL/TLS certificate file in pem format. '
+ 'This certificate must be registered with the CPS '
+ 'endpoint.'),
+ cfg.StrOpt('certificate_key_file',
+ default='certificate_key.pem',
+ help='Private Certificate Key file in pem format.'),
+ cfg.StrOpt('certificate_authority_bundle_file',
+ default='certificate_authority_bundle.pem',
+ help='Certificate Authority Bundle file in pem format. '
+ 'Must contain the appropriate trust chain for the '
+ 'Certificate file.'),
+ cfg.StrOpt('username',
+ default='',
+ help='Username for CPS.'),
+ cfg.StrOpt('password',
+ default='',
+ help='Password for CPS.'),
+ cfg.StrOpt('get_ta_list_url',
+ default='',
+ help="url to get ta_list")
+]
+
+CONF.register_opts(CPS_OPTS, group='cps')
+
+
+class CPS(object):
+
+ def __init__(self):
+ """Initializer"""
+
+ self.conf = CONF
+
+ self.base = self.conf.cps.server_url.rstrip('/')
+ self.cert = self.conf.cps.certificate_file
+ self.key = self.conf.cps.certificate_key_file
+ self.verify = self.conf.cps.certificate_authority_bundle_file
+ self.timeout = self.conf.cps.cps_rest_timeout
+ self.retries = self.conf.cps.cps_retries
+ self.username = self.conf.cps.username
+ self.password = self.conf.cps.password
+ self._init_python_request()
+
+ def _request(self, method='post', path='/', data=None,
+ context=None, value=None):
+ """Performs HTTP request."""
+ headers = {
+ 'X-FromAppId': 'CONDUCTOR',
+ 'X-TransactionId': str(uuid.uuid4()),
+ }
+ kwargs = {
+ "method": method,
+ "path": path,
+ "headers": headers,
+ "data": data,
+ }
+
+ # TODO(jdandrea): Move timing/response logging into the rest helper?
+ start_time = time.time()
+ response = self.rest.request(**kwargs)
+ elapsed = time.time() - start_time
+ LOG.debug("Total time for CPS request "
+ "({0:}: {1:}): {2:.3f} sec".format(context, value, elapsed))
+
+ if response is None:
+ LOG.error(_LE("No response from CPS ({}: {})").
+ format(context, value))
+ elif response.status_code != 200:
+ LOG.error(_LE("CPS request ({}: {}) returned HTTP "
+ "status {} {}, link: {}{}").
+ format(context, value,
+ response.status_code, response.reason,
+ self.base, path))
+ return response
+
+ def _init_python_request(self):
+
+ kwargs = {
+ "server_url": self.base,
+ "retries": self.retries,
+ "username": self.username,
+ "password": self.password,
+ "read_timeout": self.timeout,
+ }
+ self.rest = rest.REST(**kwargs)
+
+ def get_coveragearea_ta(self, args):
+ response = self.get_cps_response(args)
+ return response
+
+ def get_cps_response(self, args):
+ path = self.conf.cps.get_ta_list_url
+ data = {}
+ data['input'] = {'zone_id': args}
+ cps_response = self._request('post', path, data=data)
+ if cps_response is None or cps_response.status_code != 200:
+ return None
+ if cps_response:
+ return cps_response.json()
diff --git a/conductor/conductor/data/plugins/inventory_provider/generator.py b/conductor/conductor/data/plugins/inventory_provider/generator.py
index 17fe7a5..4664347 100644
--- a/conductor/conductor/data/plugins/inventory_provider/generator.py
+++ b/conductor/conductor/data/plugins/inventory_provider/generator.py
@@ -29,6 +29,7 @@ from conductor.data.plugins.inventory_provider import base
from conductor.data.plugins.inventory_provider.candidates.candidate import Candidate
from conductor.data.plugins.inventory_provider.candidates.slice_profiles_candidate import get_slice_requirements
from conductor.data.plugins.inventory_provider.candidates.slice_profiles_candidate import SliceProfilesCandidate
+from conductor.data.plugins.inventory_provider.cps import CPS
LOG = log.getLogger(__name__)
@@ -87,7 +88,11 @@ class Generator(base.InventoryProviderBase):
'reliability': {'values': [99.999]}},
'ran': {'latency': {'min': 10, 'max': 20, 'steps': 1},
'reliability': {'values': [99.99]},
- 'coverage_area_ta_list': {'values': ['City: Chennai']}}}
+ 'coverage_area_ta_list': {"derive_from":{"method":"get_tracking_area",
+ "args": {
+ "coverage_area": {"get_param": "coverageArea"}
+ }}}}}
+
It will generate slice profile combination from the attributes for each subnet and
generates combination of slice profile tuples from the each subnet.
"""
@@ -103,8 +108,9 @@ class Generator(base.InventoryProviderBase):
if is_valid(get_slice_requirements(combination), filtering_attributes['service_profile']):
info = Candidate.build_candidate_info(self.name(), inventory_type, 1.0, candidate_uniqueness,
str(uuid.uuid4()))
+ coverage_area = filtering_attributes['service_profile'].get("coverage_area").get("value")
candidate = SliceProfilesCandidate(info=info, subnet_requirements=combination,
- default_fields=default_fields)
+ default_fields=default_fields, coverage_area=coverage_area)
converted_candidate = candidate.convert_nested_dict_to_dict()
candidates.append(converted_candidate)
@@ -113,11 +119,26 @@ class Generator(base.InventoryProviderBase):
def is_valid(converted_candidate, service_profile):
for attr, attr_value in service_profile.items():
- if not OPERATORS[attr_value['operator']](converted_candidate[attr], attr_value['value']):
- return False
+ if attr == "coverage_area":
+ pass
+ else:
+ if not OPERATORS[attr_value['operator']](converted_candidate[attr], attr_value['value']):
+ return False
return True
+def get_tracking_area(args):
+ coverage_list = []
+ coverage_area_zones_list = args.split("-")
+ zone_id_list = coverage_area_zones_list[1].split(",")
+ for zone_id in zone_id_list:
+ values = CPS().get_coveragearea_ta(zone_id)
+ for x in values:
+ if not x.get("nRTAC") in coverage_list:
+ coverage_list.append(x.get("nRTAC"))
+ return coverage_list
+
+
def generate_combinations(attributes):
"""Generates all combination of the given attribute values.
@@ -125,13 +146,21 @@ def generate_combinations(attributes):
from which the combinations are generated.
"""
attr = dict()
+ ta_list = []
+
for attribute, attr_params in attributes.items():
- values = attr_params.get('values')
- if not values:
+ if attr_params.get('values'):
+ values = attr_params.get('values')
+ elif attr_params.get('derive_from'):
+ derive_from = attr_params.get("derive_from")
+ method_name = derive_from.get("method")
+ args = derive_from.get("args").get("coverage_area")
+ ta_list = (eval(method_name)(args))
+ values = [ta_list]
+ else:
values = range(attr_params.get('min', 1), attr_params.get('max'),
attr_params.get('steps', 1))
attr[attribute] = values
-
return get_combinations_from_dict(attr)
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/coverage_area.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/coverage_area.json
new file mode 100644
index 0000000..0a250d8
--- /dev/null
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/coverage_area.json
@@ -0,0 +1,26 @@
+[
+ {
+ "nRTAC":234,
+ "taCellsList":[
+ {
+ "cellLocalId":15709
+ }
+ ]
+ },
+ {
+ "nRTAC":123,
+ "taCellsList":[
+ {
+ "cellLocalId":15709
+ }
+ ]
+ },
+ {
+ "nRTAC":421,
+ "taCellsList":[
+ {
+ "cellLocalId":15709
+ }
+ ]
+ }
+] \ No newline at end of file
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/gen_demand_list.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/gen_demand_list.json
index a21b0ac..efd54ec 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/gen_demand_list.json
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/gen_demand_list.json
@@ -18,7 +18,8 @@
"filtering_attributes": {
"service_profile": {
"latency": {"value": 20, "operator": "lte"},
- "reliability": {"value": 99.99, "operator": "gte"}
+ "reliability": {"value": 99.99, "operator": "gte"},
+ "coverage_area": {"value": "City: Chennai-1,2,3", "operator": "eq"}
},
"subnets": {
"core": {
@@ -46,7 +47,8 @@
"filtering_attributes": {
"service_profile": {
"latency": {"value": 20, "operator": "lte"},
- "reliability": {"value": 99.99, "operator": "gte"}
+ "reliability": {"value": 99.99, "operator": "gte"},
+ "coverage_area": {"value": "City: Chennai-1,2,3", "operator": "eq"}
},
"subnets": {
"core": {
@@ -71,7 +73,11 @@
"values": [
99.99
]
- }
+ },
+ "coverage_area_ta_list": {"derive_from":{"method":"get_tracking_area",
+ "args": {
+ "coverage_area": "City: Chennai-1,2,3"
+ }}}
}
}
},
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/generated_candidates.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/generated_candidates.json
index 135b254..25faf46 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/generated_candidates.json
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/generated_candidates.json
@@ -6,12 +6,12 @@
"cost": 1.0,
"latency": 25,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 15,
"core_reliability": 99.99,
"ran_latency": 10,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -21,12 +21,12 @@
"cost": 1.0,
"latency": 26,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 15,
"core_reliability": 99.99,
"ran_latency": 11,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -36,12 +36,12 @@
"cost": 1.0,
"latency": 27,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 15,
"core_reliability": 99.99,
"ran_latency": 12,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -51,12 +51,12 @@
"cost": 1.0,
"latency": 28,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 15,
"core_reliability": 99.99,
"ran_latency": 13,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -66,12 +66,12 @@
"cost": 1.0,
"latency": 29,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 15,
"core_reliability": 99.99,
"ran_latency": 14,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -81,12 +81,12 @@
"cost": 1.0,
"latency": 30,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 15,
"core_reliability": 99.99,
"ran_latency": 15,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -96,12 +96,12 @@
"cost": 1.0,
"latency": 26,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 16,
"core_reliability": 99.99,
"ran_latency": 10,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -111,12 +111,12 @@
"cost": 1.0,
"latency": 27,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 16,
"core_reliability": 99.99,
"ran_latency": 11,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -126,12 +126,12 @@
"cost": 1.0,
"latency": 28,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 16,
"core_reliability": 99.99,
"ran_latency": 12,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -141,12 +141,12 @@
"cost": 1.0,
"latency": 29,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 16,
"core_reliability": 99.99,
"ran_latency": 13,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -156,12 +156,12 @@
"cost": 1.0,
"latency": 30,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 16,
"core_reliability": 99.99,
"ran_latency": 14,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -171,12 +171,12 @@
"cost": 1.0,
"latency": 27,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 17,
"core_reliability": 99.99,
"ran_latency": 10,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -186,12 +186,12 @@
"cost": 1.0,
"latency": 28,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 17,
"core_reliability": 99.99,
"ran_latency": 11,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -201,12 +201,12 @@
"cost": 1.0,
"latency": 29,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 17,
"core_reliability": 99.99,
"ran_latency": 12,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -216,12 +216,12 @@
"cost": 1.0,
"latency": 30,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 17,
"core_reliability": 99.99,
"ran_latency": 13,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -231,12 +231,12 @@
"cost": 1.0,
"latency": 28,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 18,
"core_reliability": 99.99,
"ran_latency": 10,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -246,12 +246,12 @@
"cost": 1.0,
"latency": 29,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 18,
"core_reliability": 99.99,
"ran_latency": 11,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -261,12 +261,12 @@
"cost": 1.0,
"latency": 30,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 18,
"core_reliability": 99.99,
"ran_latency": 12,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -276,12 +276,12 @@
"cost": 1.0,
"latency": 29,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 19,
"core_reliability": 99.99,
"ran_latency": 10,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -291,12 +291,12 @@
"cost": 1.0,
"latency": 30,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 19,
"core_reliability": 99.99,
"ran_latency": 11,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
},
{
@@ -306,12 +306,12 @@
"cost": 1.0,
"latency": 30,
"reliability": 99.99,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 20,
"core_reliability": 99.99,
"ran_latency": 10,
"ran_reliability": 99.99,
- "ran_coverage_area_ta_list": "City: Chennai",
+ "ran_coverage_area_ta_list": [234,123,421],
"creation_cost": 0.9
}
]
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/resolved_demands_gen.json b/conductor/conductor/tests/unit/data/plugins/inventory_provider/resolved_demands_gen.json
index ac9c674..72a305b 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/resolved_demands_gen.json
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/resolved_demands_gen.json
@@ -8,6 +8,7 @@
"cost": 1.0,
"reliability": 99.99,
"latency": 15,
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 15,
"core_reliability": 99.99,
"creation_cost": 0.9
@@ -19,6 +20,7 @@
"cost": 1.0,
"reliability": 99.99,
"latency": 16,
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 16,
"core_reliability": 99.99,
"creation_cost": 0.9
@@ -30,6 +32,7 @@
"cost": 1.0,
"reliability": 99.99,
"latency": 17,
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 17,
"core_reliability": 99.99,
"creation_cost": 0.9
@@ -41,6 +44,7 @@
"cost": 1.0,
"reliability": 99.99,
"latency": 18,
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 18,
"core_reliability": 99.99,
"creation_cost": 0.9
@@ -52,6 +56,7 @@
"cost": 1.0,
"reliability": 99.99,
"latency": 19,
+ "coverage_area": "City: Chennai-1,2,3",
"core_latency": 19,
"core_reliability": 99.99,
"creation_cost": 0.9
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_candidates.py b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_candidates.py
index 8d9bcc5..ded58ad 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_candidates.py
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_candidates.py
@@ -38,7 +38,7 @@ class TestCandidates(unittest.TestCase):
"core_latency": 15,
"core_reliability": 99.99,
"cost": 1.0,
- "coverage_area_ta_list": "City: Chennai",
+ "coverage_area": "City: Chennai",
"inventory_provider": "generator",
"inventory_type": "slice_profiles",
"latency": 25,
@@ -55,6 +55,6 @@ class TestCandidates(unittest.TestCase):
}
candidate = SliceProfilesCandidate(info=info, subnet_requirements=subnet_requirements,
- default_fields={"creation_cost": 0.9})
+ default_fields={"creation_cost": 0.9},coverage_area="City: Chennai")
self.assertEqual(expected_candidate, candidate.convert_nested_dict_to_dict())
diff --git a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_generator.py b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_generator.py
index 2c0f207..6978940 100644
--- a/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_generator.py
+++ b/conductor/conductor/tests/unit/data/plugins/inventory_provider/test_generator.py
@@ -19,7 +19,9 @@
import unittest
import json
+import mock
from mock import patch
+from conductor.data.plugins.inventory_provider.cps import CPS
from conductor.data.plugins.inventory_provider.generator import Generator
@@ -36,23 +38,33 @@ class TestGenerator(unittest.TestCase):
candidates_file = './conductor/tests/unit/data/plugins/inventory_provider/generated_candidates.json'
expected_candidates = json.loads(open(candidates_file).read())
-
+ coverage_area_file='./conductor/tests/unit/data/plugins/inventory_provider/coverage_area.json'
+ coverage_area_json = json.loads(open(coverage_area_file).read())
generator = Generator()
filtering_attributes = {
'service_profile': {
'latency': {'value': 30, 'operator': 'lte'},
'reliability': {'value': 99.99, 'operator': 'gte'},
- 'coverage_area_ta_list': {'value': 'City: Chennai', 'operator': 'eq'}
+ 'coverage_area': {'value': 'City: Chennai-1,2,3', 'operator': 'eq'}
},
'subnets': {
'core': {'latency': {'min': 15, 'max': 30, 'steps': 1},
'reliability': {'values': [99.99]}},
'ran': {'latency': {'min': 10, 'max': 30, 'steps': 1},
'reliability': {'values': [99.99]},
- 'coverage_area_ta_list': {'values': ['City: Chennai']}}
+ 'coverage_area_ta_list': {"derive_from":{"method":"get_tracking_area",
+ "args": {
+ "coverage_area": "Chennai-1,2,3"
+ }}}}
}
}
+ self.mock_get_coverage_area_ta = mock.patch.object(CPS, 'get_coveragearea_ta',
+ return_value=coverage_area_json)
+
+ self.mock_get_coverage_area_ta.start()
+
+ self.maxDiff=None
generated_candidates = generator.generate_candidates('slice_profiles', filtering_attributes,
candidate_uniqueness='true',
@@ -62,7 +74,7 @@ class TestGenerator(unittest.TestCase):
self.assertIsNotNone(candidate['candidate_id'])
del candidate['candidate_id']
- self.assertCountEqual(expected_candidates, generated_candidates)
+ self.assertEqual(expected_candidates, generated_candidates)
self.assertEqual([], generator.generate_candidates('cloud', filtering_attributes,
candidate_uniqueness='true',
@@ -71,11 +83,19 @@ class TestGenerator(unittest.TestCase):
def test_resolve_demands(self):
demands_file = './conductor/tests/unit/data/plugins/inventory_provider/gen_demand_list.json'
demands = json.loads(open(demands_file).read())
+ coverage_area_file = './conductor/tests/unit/data/plugins/inventory_provider/coverage_area.json'
+ coverage_area_json = json.loads(open(coverage_area_file).read())
resolved_demands_file = './conductor/tests/unit/data/plugins/inventory_provider/resolved_demands_gen.json'
expected_resolved_demands = json.loads(open(resolved_demands_file).read())
generator = Generator()
+ self.mock_get_coverage_area_ta = mock.patch.object(CPS, 'get_coveragearea_ta',
+ return_value=coverage_area_json)
+
+ self.mock_get_coverage_area_ta.start()
+
+ self.maxDiff=None
resolved_demands = generator.resolve_demands(demands, plan_info=None, triage_translator_data=None)
for _, candidate_list in resolved_demands.items():
for candidate in candidate_list: