diff options
author | hariharan97 <rh20085046@wipro.com> | 2021-04-15 11:05:27 +0530 |
---|---|---|
committer | hariharan97 <rh20085046@wipro.com> | 2021-04-15 11:08:29 +0530 |
commit | fac7fad54201fabab91fb850abf6f7d5c9f772bc (patch) | |
tree | 6c25cfa2afca3a13c6e5f57c3367b2be3d09a537 /apps/slice_selection | |
parent | 7ef613de6d9cd794fd10ae43d98ffa9312418e68 (diff) |
Fix for NSI selection response
Issue-ID: OPTFRA-943
Signed-off-by: hariharan97 <rh20085046@wipro.com>
Change-Id: I88f18e258898683df8e03a531f5c22d11ff7f08f
Diffstat (limited to 'apps/slice_selection')
-rw-r--r-- | apps/slice_selection/optimizers/conductor/remote_opt_processor.py | 2 | ||||
-rw-r--r-- | apps/slice_selection/optimizers/conductor/response_processor.py | 26 |
2 files changed, 14 insertions, 14 deletions
diff --git a/apps/slice_selection/optimizers/conductor/remote_opt_processor.py b/apps/slice_selection/optimizers/conductor/remote_opt_processor.py index 0fbf36e..3c140c5 100644 --- a/apps/slice_selection/optimizers/conductor/remote_opt_processor.py +++ b/apps/slice_selection/optimizers/conductor/remote_opt_processor.py @@ -106,7 +106,7 @@ class SliceSelectionOptimizer(Thread): recommendations = resp["plans"][0].get("recommendations") subnets = [subnet['domainType'] for subnet in self.request_json['subnetCapabilities']] \ if self.request_json.get('subnetCapabilities') else [] - return self.response_processor.process_response(recommendations, model_info, subnets) + return self.response_processor.process_response(recommendations, model_info, subnets, self.model_type) def get_request_parameters(self, requirements, model_info): camel_to_snake = self.slice_config['attribute_mapping']['camel_to_snake'] diff --git a/apps/slice_selection/optimizers/conductor/response_processor.py b/apps/slice_selection/optimizers/conductor/response_processor.py index d2c949b..2357ab9 100644 --- a/apps/slice_selection/optimizers/conductor/response_processor.py +++ b/apps/slice_selection/optimizers/conductor/response_processor.py @@ -28,23 +28,31 @@ class ResponseProcessor(object): self.request_info = request_info self.slice_config = slice_config - def process_response(self, recommendations, model_info, subnets): + def process_response(self, recommendations, model_info, subnets, model_type): """Process conductor response to form the response for the API request :param recommendations: recommendations from conductor :param model_info: model info from the request :param subnets: list of subnets + :param model_type: NSI or NSSI :return: response json as a dictionary """ if not recommendations: return self.get_slice_selection_response([]) model_name = model_info['name'] - solutions = [self.get_solution_from_candidate(rec[model_name]['candidate'], model_info, subnets) + solutions = [self.get_solution_from_candidate(rec[model_name]['candidate'], model_info, subnets, model_type) for rec in recommendations] return self.get_slice_selection_response(solutions) - def get_solution_from_candidate(self, candidate, model_info, subnets): - if candidate['inventory_type'] == 'nssi': + def get_solution_from_candidate(self, candidate, model_info, subnets, model_type): + if candidate['inventory_type'] == 'slice_profiles': + return { + 'existingNSI': False, + 'newNSISolution': { + 'sliceProfiles': self.get_slice_profiles_from_candidate(candidate, subnets) + } + } + elif model_type == 'NSSI': return { 'UUID': model_info['UUID'], 'invariantUUID': model_info['invariantUUID'], @@ -52,7 +60,7 @@ class ResponseProcessor(object): 'NSSIId': candidate['instance_id'] } - elif candidate['inventory_type'] == 'nsi': + elif model_type == 'NSI': return { 'existingNSI': True, 'sharedNSISolution': { @@ -63,14 +71,6 @@ class ResponseProcessor(object): } } - elif candidate['inventory_type'] == 'slice_profiles': - return { - 'existingNSI': False, - 'newNSISolution': { - 'sliceProfiles': self.get_slice_profiles_from_candidate(candidate, subnets) - } - } - def get_slice_profiles_from_candidate(self, candidate, subnets): slice_profiles = [] for subnet in subnets: |