diff options
11 files changed, 60 insertions, 27 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) diff --git a/config/common_config.yaml b/config/common_config.yaml index 8f028b3..d720fb2 100644 --- a/config/common_config.yaml +++ b/config/common_config.yaml @@ -64,12 +64,9 @@ references: subscriber_role: source: onap.policies.optimization.SubscriberPolicy value: properties.properties.subscriberRole - resource_sharing_level: + slice_scope: source: request - value: serviceProfile.resourceSharingLevel - reuse_preference: - source: request - value: preferReuse + value: slice_scope policy_info: prioritization_attributes: @@ -86,8 +83,7 @@ policy_info: policy_scope: - scope: - - get_param: resource_sharing_level - - get_param: reuse_preference + - get_param: slice_scope services: - get_param: service_name resources: diff --git a/test/policy-local-files/slice-selection-files/opt_policy_nsi_reuse.json b/test/policy-local-files/slice-selection-files/opt_policy_nsi_reuse.json index 33dbfee..fa02d4e 100644 --- a/test/policy-local-files/slice-selection-files/opt_policy_nsi_reuse.json +++ b/test/policy-local-files/slice-selection-files/opt_policy_nsi_reuse.json @@ -24,8 +24,7 @@ "embb-nst" ], "scope": [ - "REUSE", - "SHARED" + "shared,reuse" ], "services": [ "embb-nst" diff --git a/test/policy-local-files/slice-selection-files/opt_policy_nssi.json b/test/policy-local-files/slice-selection-files/opt_policy_nssi.json index 2b7cbf8..196add0 100644 --- a/test/policy-local-files/slice-selection-files/opt_policy_nssi.json +++ b/test/policy-local-files/slice-selection-files/opt_policy_nssi.json @@ -24,7 +24,7 @@ "embb-cn" ], "scope": [ - "SHARED" + "OSDF_GUILIN" ], "services": [ "embb-cn" diff --git a/test/policy-local-files/slice-selection-files/query_policy_nsi.json b/test/policy-local-files/slice-selection-files/query_policy_nsi.json index 49b1ca6..c370ccd 100644 --- a/test/policy-local-files/slice-selection-files/query_policy_nsi.json +++ b/test/policy-local-files/slice-selection-files/query_policy_nsi.json @@ -10,7 +10,9 @@ }, "properties":{ "scope":[ - "OSDF_GUILIN" + "shared,reuse", + "shared,create_new", + "not-shared" ], "services":[ "embb-nst" @@ -37,6 +39,14 @@ { "attribute":"tn_bh_latency", "attribute_location":"tn_bh_latency" + }, + { + "attribute":"model_invariant_id", + "attribute_location":"invariantUUID" + }, + { + "attribute":"model_version_id", + "attribute_location":"UUID" } ] } diff --git a/test/policy-local-files/slice-selection-files/query_policy_nssi.json b/test/policy-local-files/slice-selection-files/query_policy_nssi.json index 5e5893b..c1e941f 100644 --- a/test/policy-local-files/slice-selection-files/query_policy_nssi.json +++ b/test/policy-local-files/slice-selection-files/query_policy_nssi.json @@ -10,7 +10,7 @@ }, "properties":{ "scope":[ - "SHARED" + "OSDF_GUILIN" ], "services":[ "embb-cn" @@ -25,6 +25,14 @@ { "attribute":"reliability", "attribute_location":"reliability" + }, + { + "attribute":"model_invariant_id", + "attribute_location":"invariantUUID" + }, + { + "attribute":"model_version_id", + "attribute_location":"UUID" } ] } diff --git a/test/policy-local-files/slice-selection-files/threshold_policy_nsi.json b/test/policy-local-files/slice-selection-files/threshold_policy_nsi.json index 6e518dd..8769641 100644 --- a/test/policy-local-files/slice-selection-files/threshold_policy_nsi.json +++ b/test/policy-local-files/slice-selection-files/threshold_policy_nsi.json @@ -14,7 +14,9 @@ "embb-nst" ], "scope":[ - "OSDF_GUILIN" + "shared,reuse", + "shared,create_new", + "not-shared" ], "services":[ "embb-nst" diff --git a/test/policy-local-files/slice-selection-files/threshold_policy_nssi.json b/test/policy-local-files/slice-selection-files/threshold_policy_nssi.json index 72a24da..bf8690f 100644 --- a/test/policy-local-files/slice-selection-files/threshold_policy_nssi.json +++ b/test/policy-local-files/slice-selection-files/threshold_policy_nssi.json @@ -14,7 +14,7 @@ "embb-cn" ], "scope":[ - "SHARED" + "OSDF_GUILIN" ], "services":[ "embb-cn" diff --git a/test/policy-local-files/slice-selection-files/vnf_policy_nsi_non_shared_case.json b/test/policy-local-files/slice-selection-files/vnf_policy_nsi_non_shared_case.json index 1774780..09aba6e 100644 --- a/test/policy-local-files/slice-selection-files/vnf_policy_nsi_non_shared_case.json +++ b/test/policy-local-files/slice-selection-files/vnf_policy_nsi_non_shared_case.json @@ -9,8 +9,7 @@ "identity":"vnf_URLLC", "resources":["embb-nst"], "scope":[ - "OSDF_GUILIN", - "non-shared" + "not-shared" ], "services":[ "embb-nst" @@ -19,6 +18,11 @@ "vnfProperties":[ { "attributes":{ + "service_profile": { + "latency": {"value": {"get_param": "latency"}, "operator": "lte"}, + "reliability": {"value": {"get_param": "reliability"}, "operator": "gte"} + }, + "subnets": { "core":{ "latency":{ "max":{"get_param":"latency"}, @@ -58,6 +62,7 @@ ] } } + } }, "inventoryProvider":"generator", "inventoryType":"slice_profiles", diff --git a/test/policy-local-files/slice-selection-files/vnf_policy_nsi_shared_case.json b/test/policy-local-files/slice-selection-files/vnf_policy_nsi_shared_case.json index 9932cc1..0446748 100644 --- a/test/policy-local-files/slice-selection-files/vnf_policy_nsi_shared_case.json +++ b/test/policy-local-files/slice-selection-files/vnf_policy_nsi_shared_case.json @@ -9,8 +9,8 @@ "identity":"vnf_URLLC", "resources":["embb-nst"], "scope":[ - "OSDF_GUILIN", - "shared" + "shared,reuse", + "shared,create_new" ], "services":[ "embb-nst" @@ -19,8 +19,8 @@ "vnfProperties":[ { "attributes":{ - "modelInvariantId":"bfbg3636-e39c-iidd-0987-27c28f4oo3", - "modelVersionId":"bfbg3636-e39c-iidd-0987-27c28f4d33", + "modelInvariantId":{"get_param":"model_invariant_id"}, + "modelVersionId":{"get_param":"model_version_id"}, "environment-context":"shared", "service-role":"nsi" }, @@ -33,6 +33,11 @@ }, { "attributes":{ + "service_profile": { + "latency": {"value": {"get_param": "latency"}, "operator": "lte"}, + "reliability": {"value": {"get_param": "reliability"}, "operator": "gte"} + }, + "subnets": { "core":{ "latency":{ "max":{"get_param":"latency"}, @@ -72,6 +77,7 @@ ] } } + } }, "inventoryProvider":"generator", "inventoryType":"slice_profiles", diff --git a/test/policy-local-files/slice-selection-files/vnf_policy_nssi_shared.json b/test/policy-local-files/slice-selection-files/vnf_policy_nssi_shared.json index bd12f84..b5c81d1 100644 --- a/test/policy-local-files/slice-selection-files/vnf_policy_nssi_shared.json +++ b/test/policy-local-files/slice-selection-files/vnf_policy_nssi_shared.json @@ -9,7 +9,7 @@ "identity":"vnf_URLLC", "resources":["embb-cn"], "scope":[ - "SHARED" + "OSDF_GUILIN" ], "services":[ "embb-cn" @@ -18,8 +18,8 @@ "vnfProperties":[ { "attributes":{ - "modelInvariantId":"bfbg3636-e39c-iidd-0987-27c28f4oo3", - "modelVersionId":"bfbg3636-e39c-iidd-0987-27c28f4d33", + "modelInvariantId":{"get_param":"model_invariant_id"}, + "modelVersionId":{"get_param":"model_version_id"}, "environment-context":"shared", "service-role":"nssi" }, |