summaryrefslogtreecommitdiffstats
path: root/apps/slice_selection
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2020-05-14 18:22:46 +0530
committerkrishnaa96 <krishna.moorthy6@wipro.com>2020-05-14 18:22:46 +0530
commit349bbf794dbc34a96755ae40e98b8ba83a074a02 (patch)
treea62e3aafc9cc385ed09dcbe619a5790962a19033 /apps/slice_selection
parent0227fc0b5a69558cb68fd9977e12558fbb51a203 (diff)
Handle has exceptions for slice selection
Issue-ID: OPTFRA-754 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: I66904680a4b9a2bc69c144f05b95fb4f999d0e93
Diffstat (limited to 'apps/slice_selection')
-rw-r--r--apps/slice_selection/optimizers/conductor/remote_opt_processor.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/apps/slice_selection/optimizers/conductor/remote_opt_processor.py b/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
index b34c8b1..40638fc 100644
--- a/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
+++ b/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
@@ -66,10 +66,13 @@ def process_nsi_selection_opt(request_json, osdf_config):
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)
- if resp["plans"][0].get("status") == "not found":
- resp["recommendations"] = list()
+ try:
+ resp = conductor.request(req_info, demands, request_parameters, service_info, False,
+ osdf_config, policies)
+ except RequestException as e:
+ resp = e.response.json()
+ error = resp['plans'][0]['message']
+ error_log.error('Error from conductor {}'.format(error))
debug_log.debug("Response from conductor {}".format(str(resp)))
overall_recommendations[nst_name] = resp["plans"][0].get("recommendations")
@@ -78,18 +81,12 @@ def process_nsi_selection_opt(request_json, osdf_config):
solutions['newNSISolutions'] = new_nsi_solutions
solutions['sharedNSISolutions'] = []
return get_nsi_selection_response(req_info, solutions)
- else:
+ 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()))
- if isinstance(ex, RequestException):
- try:
- error_message = json.loads(ex.response)['plans'][0]['message']
- except Exception:
- error_message = "Problem connecting to conductor"
- else:
- error_message = str(ex)
+ error_message = str(ex)
return conductor_error_response_processor(req_info, error_message)