summaryrefslogtreecommitdiffstats
path: root/apps/slice_selection
diff options
context:
space:
mode:
authordhebeha <dhebeha.mj71@wipro.com>2020-05-13 01:33:52 +0530
committerdhebeha <dhebeha.mj71@wipro.com>2020-05-13 10:39:41 +0530
commit0227fc0b5a69558cb68fd9977e12558fbb51a203 (patch)
treed906c0db686b0c5dc8b6d93cb746de3d271534ae /apps/slice_selection
parent76efb65c4fffbd5b940a75c36329a2e0409be382 (diff)
return slice profile when serviceProfile is non shareable
Issue-ID: OPTFRA-754 Signed-off-by: dhebeha <dhebeha.mj71@wipro.com> Change-Id: Ib330881be60d8bcc5683571a76ef8fe52452b869
Diffstat (limited to 'apps/slice_selection')
-rw-r--r--apps/slice_selection/optimizers/conductor/remote_opt_processor.py45
-rw-r--r--apps/slice_selection/optimizers/conductor/response_processor.py39
2 files changed, 58 insertions, 26 deletions
diff --git a/apps/slice_selection/optimizers/conductor/remote_opt_processor.py b/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
index edad9ba..b34c8b1 100644
--- a/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
+++ b/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
@@ -25,7 +25,7 @@ import traceback
from requests import RequestException
from apps.slice_selection.optimizers.conductor.response_processor \
- import conductor_response_processor, conductor_error_response_processor
+ import conductor_response_processor, conductor_error_response_processor, solution_with_only_slice_profile, get_nsi_selection_response
from osdf.adapters.conductor import conductor
from osdf.adapters.policy.interface import get_policies
from osdf.adapters.policy.utils import group_policies_gen
@@ -46,29 +46,40 @@ def process_nsi_selection_opt(request_json, osdf_config):
overall_recommendations = dict()
nst_info_map = dict()
+ new_nsi_solutions = list()
for nst_info in request_json["NSTInfoList"]:
nst_name = nst_info["modelName"]
- nst_info_map["nst_name"] = {"NSTName": nst_name,
- "UUID": nst_info["modelVersionId"],
- "invariantUUID": nst_info["modelInvariantId"]}
+ nst_info_map[nst_name] = {"NSTName": nst_name,
+ "UUID": nst_info["modelVersionId"],
+ "invariantUUID": nst_info["modelInvariantId"]}
- policy_request_json = request_json.copy()
- policy_request_json['serviceInfo']['serviceName'] = nst_name
+ if request_json["serviceProfile"]["resourceSharingLevel"] == "non-shared":
+ new_nsi_solution = solution_with_only_slice_profile(request_json['serviceProfile'], nst_info_map.get(nst_name))
+ new_nsi_solutions.append(new_nsi_solution)
+ else:
+ policy_request_json = request_json.copy()
+ policy_request_json['serviceInfo']['serviceName'] = nst_name
+ policies = get_policies(policy_request_json, "slice_selection")
- policies = get_policies(policy_request_json, "slice_selection")
+ demands = get_slice_demands(nst_name, policies, osdf_config.core)
- demands = get_slice_demands(nst_name, policies, osdf_config.core)
-
- request_parameters = request_json.get('serviceProfile',{})
- service_info = {}
- req_info['numSolutions'] = 'all'
- resp = conductor.request(req_info, demands, request_parameters, service_info, False,
+ request_parameters = request_json.get('serviceProfile',{})
+ service_info = {}
+ req_info['numSolutions'] = 'all'
+ resp = conductor.request(req_info, demands, request_parameters, service_info, False,
osdf_config, policies)
- debug_log.debug("Response from conductor {}".format(str(resp)))
- overall_recommendations[nst_name] = resp["plans"][0].get("recommendations")
-
- return conductor_response_processor(overall_recommendations, nst_info_map, req_info)
+ if resp["plans"][0].get("status") == "not found":
+ resp["recommendations"] = list()
+ debug_log.debug("Response from conductor {}".format(str(resp)))
+ overall_recommendations[nst_name] = resp["plans"][0].get("recommendations")
+ if request_json["serviceProfile"]["resourceSharingLevel"] == "non-shared":
+ solutions = dict()
+ solutions['newNSISolutions'] = new_nsi_solutions
+ solutions['sharedNSISolutions'] = []
+ return get_nsi_selection_response(req_info, solutions)
+ else:
+ return conductor_response_processor(overall_recommendations, nst_info_map, req_info, request_json["serviceProfile"])
except Exception as ex:
error_log.error("Error for {} {}".format(req_info.get('requestId'),
traceback.format_exc()))
diff --git a/apps/slice_selection/optimizers/conductor/response_processor.py b/apps/slice_selection/optimizers/conductor/response_processor.py
index c175c1a..9b57092 100644
--- a/apps/slice_selection/optimizers/conductor/response_processor.py
+++ b/apps/slice_selection/optimizers/conductor/response_processor.py
@@ -23,15 +23,15 @@ Module for processing response from conductor for slice selection
from osdf.logging.osdf_logging import debug_log
-SLICE_PROFILE_FIELDS = ["latency", "max_number_of_ues", "coverage_area_ta_list",
- "ue_mobility_level", "resource_sharing_level", "exp_data_rate_ul",
- "exp_data_rate_dl", "area_traffic_cap_ul", "area_traffic_cap_dl",
- "activity_factor", "e2e_latency", "jitter", "survival_time",
- "exp_data_rate", "payload_size", "traffic_density", "conn_density",
- "reliability", "service_area_dimension", "cs_availability"]
+SLICE_PROFILE_FIELDS = {"latency":"latency", "max_number_of_ues":"maxNumberOfUEs", "coverage_area_ta_list": "coverageAreaTAList",
+ "ue_mobility_level":"uEMobilityLevel", "resource_sharing_level":"resourceSharingLevel", "exp_data_rate_ul": "expDataRateUL",
+ "exp_data_rate_dl":"expDataRateDL", "area_traffic_cap_ul":"areaTrafficCapUL", "area_traffic_cap_dl": "areaTrafficCapDL",
+ "activity_factor":"activityFactor", "e2e_latency":"e2eLatency", "jitter":"jitter", "survival_time": "survivalTime",
+ "exp_data_rate":"expDataRate", "payload_size":"payloadSize", "traffic_density":"trafficDensity", "conn_density":"connDensity",
+ "reliability":"reliability", "service_area_dimension":"serviceAreaDimension", "cs_availability": "csAvailability"}
-def conductor_response_processor(overall_recommendations, nst_info_map, request_info):
+def conductor_response_processor(overall_recommendations, nst_info_map, request_info, service_profile):
"""Process conductor response to form the response for the API request
:param overall_recommendations: recommendations from conductor
:param nst_info_map: NST info from the request
@@ -40,8 +40,12 @@ def conductor_response_processor(overall_recommendations, nst_info_map, request_
"""
shared_nsi_solutions = list()
new_nsi_solutions = list()
-
for nst_name, recommendations in overall_recommendations.items():
+ if not (recommendations):
+ new_nsi_solution = solution_with_only_slice_profile(service_profile, nst_info_map.get(nst_name))
+ new_nsi_solutions.append(new_nsi_solution)
+ continue
+
for recommendation in recommendations:
nsi_set = set(values['candidate']['nsi_id'] for key, values in recommendation.items())
if len(nsi_set) == 1:
@@ -82,6 +86,14 @@ def conductor_response_processor(overall_recommendations, nst_info_map, request_
return get_nsi_selection_response(request_info, solutions)
+def solution_with_only_slice_profile(service_profile, nst_info):
+ nssi_solutions = get_slice_profile_from_service_profile(service_profile)
+ new_nsi_solution = dict()
+ new_nsi_solution['matchLevel'] = ""
+ new_nsi_solution['NSTInfo'] = nst_info
+ new_nsi_solution['NSSISolutions'] = nssi_solutions
+ return new_nsi_solution
+
def conductor_error_response_processor(request_info, error_message):
"""Form response message from the error message
:param request_info: request info
@@ -94,6 +106,14 @@ def conductor_error_response_processor(request_info, error_message):
'statusMessage': error_message}
+def get_slice_profile_from_service_profile(service_profile):
+ nssi_solutions = list()
+ service_profile["domainType"] = "cn"
+ nssi_solution = {"sliceProfile": service_profile}
+ nssi_solutions.append(nssi_solution)
+ return nssi_solutions
+
+
def get_nssi_solutions(recommendation):
"""Get nssi solutions from recommendation
:param recommendation: recommendation from conductor
@@ -123,7 +143,7 @@ def get_solution_from_candidate(candidate):
for field in SLICE_PROFILE_FIELDS:
if candidate[field]:
- slice_profile[field] = candidate[field]
+ slice_profile[SLICE_PROFILE_FIELDS[field]] = candidate[field]
return nssi_info, slice_profile
@@ -139,3 +159,4 @@ def get_nsi_selection_response(request_info, solutions):
'requestStatus': 'completed',
'statusMessage': '',
'solutions': solutions}
+