summaryrefslogtreecommitdiffstats
path: root/apps/slice_selection
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2020-10-07 17:01:58 +0530
committerkrishnaa96 <krishna.moorthy6@wipro.com>2020-10-07 19:52:51 +0530
commitf173849ec0e08930f7c546543a8dd6b14954c308 (patch)
tree4db58d8f1b520817405e5cd8641972e304456772 /apps/slice_selection
parent21587bf56798b440dd4ddf6e35f121505b90fb0d (diff)
Return empty solution if no candidate found
Update policy filter for NSI selection Return empty solution instead of error if no candidate is found Issue-ID: OPTFRA-855 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: I2f5ecbb9464fef3dbc844339968f6cdb1123b2b5
Diffstat (limited to 'apps/slice_selection')
-rw-r--r--apps/slice_selection/optimizers/conductor/remote_opt_processor.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/apps/slice_selection/optimizers/conductor/remote_opt_processor.py b/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
index bb9d289..432655b 100644
--- a/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
+++ b/apps/slice_selection/optimizers/conductor/remote_opt_processor.py
@@ -78,7 +78,7 @@ class SliceSelectionOptimizer(Thread):
model_info = self.request_json.get(app_info['model_info'])
model_name = model_info['name']
policies = self.get_app_policies(model_name, app_info['app_name'])
- request_parameters = self.get_request_parameters(requirements)
+ request_parameters = self.get_request_parameters(requirements, model_info)
demands = [
{
@@ -97,6 +97,8 @@ class SliceSelectionOptimizer(Thread):
except RequestException as e:
resp = e.response.json()
error = resp['plans'][0]['message']
+ if "Unable to find any" in error:
+ return self.response_processor.get_slice_selection_response([])
error_log.error('Error from conductor {}'.format(error))
return self.response_processor.process_error_response(error)
@@ -106,7 +108,7 @@ class SliceSelectionOptimizer(Thread):
if self.request_json.get('subnetCapabilities') else []
return self.response_processor.process_response(recommendations, model_info, subnets)
- def get_request_parameters(self, requirements):
+ def get_request_parameters(self, requirements, model_info):
camel_to_snake = self.slice_config['attribute_mapping']['camel_to_snake']
request_params = {camel_to_snake[key]: value for key, value in requirements.items()}
subnet_capabilities = self.request_json.get('subnetCapabilities')
@@ -116,11 +118,16 @@ class SliceSelectionOptimizer(Thread):
capability_details = subnet_capability['capabilityDetails']
for key, value in capability_details.items():
request_params[f"{domain_type}{camel_to_snake[key]}"] = value
+ request_params.update(model_info)
return request_params
def get_app_policies(self, model_name, app_name):
policy_request_json = self.request_json.copy()
policy_request_json['serviceInfo'] = {'serviceName': model_name}
- if 'preferReuse' in self.request_json:
- policy_request_json['preferReuse'] = "reuse" if self.request_json['preferReuse'] else "create_new"
+ if 'serviceProfile' in self.request_json:
+ slice_scope = self.request_json['serviceProfile']['resourceSharingLevel']
+ if 'preferReuse' in self.request_json and slice_scope == "shared":
+ slice_scope = slice_scope + "," + ("reuse" if self.request_json['preferReuse'] else "create_new")
+ policy_request_json['slice_scope'] = slice_scope
+ debug_log.debug("policy_request_json {}".format(str(policy_request_json)))
return get_policies(policy_request_json, app_name)