summaryrefslogtreecommitdiffstats
path: root/apps/placement/optimizers/conductor/api_builder.py
diff options
context:
space:
mode:
authorRuoyu Ying <ruoyu.ying@intel.com>2019-12-04 00:48:46 +0800
committerRuoyu Ying <ruoyu.ying@intel.com>2020-03-10 06:30:48 +0800
commitc1625bd8163ca269ee1a6b25a1f569b97b529b17 (patch)
tree38bdef96a04d4b354d77f402a33b02773d98ed1d /apps/placement/optimizers/conductor/api_builder.py
parent998f35e5100014b9d639e52020a70ff4db53ddd3 (diff)
[WIP]Migration to new policy api
*Change retrieval payload send to policy *Change the configs inside common_config Issue-ID: OPTFRA-520 Change-Id: I27a63294cdec3def7d415ed2dcb96e3606d9e21f Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com>
Diffstat (limited to 'apps/placement/optimizers/conductor/api_builder.py')
-rw-r--r--apps/placement/optimizers/conductor/api_builder.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/apps/placement/optimizers/conductor/api_builder.py b/apps/placement/optimizers/conductor/api_builder.py
index 7b61580..cefde51 100644
--- a/apps/placement/optimizers/conductor/api_builder.py
+++ b/apps/placement/optimizers/conductor/api_builder.py
@@ -32,7 +32,7 @@ def _build_parameters(group_policies, request_json):
:param request_json: parameter data received from a client
:return:
"""
- initial_params = tr.get_opt_query_data(request_json, group_policies['request_param_query'])
+ initial_params = tr.get_opt_query_data(request_json, group_policies['onap.policies.optimization.QueryPolicy'])
params = dict()
params.update({"REQUIRED_MEM": initial_params.pop("requiredMemory", "")})
params.update({"REQUIRED_DISK": initial_params.pop("requiredDisk", "")})
@@ -61,22 +61,34 @@ def conductor_api_builder(request_json, flat_policies: list, local_config,
templ = Template(open(template).read())
gp = group_policies_gen(flat_policies, local_config)
demand_vnf_name_list = []
-
for placementDemand in request_json['placementInfo']['placementDemands']:
demand_vnf_name_list.append(placementDemand['resourceModuleName'].lower())
- demand_list = tr.gen_demands(request_json, gp['vnfPolicy'])
+ demand_list = tr.gen_demands(request_json, gp['onap.policies.optimization.VnfPolicy'])
+ # What's the attribute policy? Need an example
attribute_policy_list = tr.gen_attribute_policy(demand_vnf_name_list, gp['attribute'])
distance_to_location_policy_list = tr.gen_distance_to_location_policy(
- demand_vnf_name_list, gp['distance_to_location'])
+ demand_vnf_name_list, gp['onap.policies.optimization.DistancePolicy'])
+ # What's the inventory group policy? A policy to choose the inventory group from existing list?
inventory_policy_list = tr.gen_inventory_group_policy(demand_vnf_name_list, gp['inventory_group'])
+ # What's the instance fit policy, a policy to choose the instance from existing list?
resource_instance_policy_list = tr.gen_resource_instance_policy(
demand_vnf_name_list, gp['instance_fit'])
+ # Need an example for the resource_region_policy
resource_region_policy_list = tr.gen_resource_region_policy(demand_vnf_name_list, gp['region_fit'])
- zone_policy_list = tr.gen_zone_policy(demand_vnf_name_list, gp['zone'])
- optimization_policy_list = tr.gen_optimization_policy(demand_vnf_name_list, gp['placement_optimization'])
+ zone_policy_list = tr.gen_zone_policy(demand_vnf_name_list, gp['onap.policies.optimization.AffinityPolicy'])
+ optimization_policy_list = tr.gen_optimization_policy(demand_vnf_name_list,
+ gp['onap.policies.optimization.OptimizationPolicy'])
+ # Need an example for the instance reservation policy
reservation_policy_list = tr.gen_reservation_policy(demand_vnf_name_list, gp['instance_reservation'])
- capacity_policy_list = tr.gen_capacity_policy(demand_vnf_name_list, gp['vim_fit'])
- hpa_policy_list = tr.gen_hpa_policy(demand_vnf_name_list, gp['hpa'])
+ capacity_policy_list = tr.gen_capacity_policy(demand_vnf_name_list, gp['onap.policies.optimization.Vim_fit'])
+ hpa_policy_list = tr.gen_hpa_policy(demand_vnf_name_list, gp['onap.policies.optimization.HpaPolicy'])
+ #distance_to_location_policy_list = tr.gen_distance_to_location_policy(
+ # demand_vnf_name_list, gp['distance_to_location'])
+ # demand_list = tr.gen_demands(request_json, gp['vnfPolicy'])
+ #zone_policy_list = tr.gen_zone_policy(demand_vnf_name_list, gp['zone'])
+ #optimization_policy_list = tr.gen_optimization_policy(demand_vnf_name_list, gp['placement_optimization'])
+ #capacity_policy_list = tr.gen_capacity_policy(demand_vnf_name_list, gp['vim_fit'])
+ #hpa_policy_list = tr.gen_hpa_policy(demand_vnf_name_list, gp['hpa'])
req_params_dict = _build_parameters(gp, request_json)
conductor_policies = [attribute_policy_list, distance_to_location_policy_list, inventory_policy_list,
resource_instance_policy_list, resource_region_policy_list, zone_policy_list,