diff options
author | Ankitkumar Patel <ankit@research.att.com> | 2018-05-19 12:47:27 -0400 |
---|---|---|
committer | Ankitkumar Patel <ankit@research.att.com> | 2018-05-19 12:48:14 -0400 |
commit | 8ea30a38468373dfd9715d720c085c8a6ac4ee29 (patch) | |
tree | 7d6bac9fdc2b963b9960962ffa5b04c167d3f055 /osdf | |
parent | 12f9060558172ee282c6fb1b18e9955f00a41807 (diff) |
Fix the bug in translating a policy
Fix the bug in translating the VNF policy
Issue-ID: OPTFRA-239
Change-Id: I0c9f678f22fec4eb3f5e190ea0080c899fb95445
Signed-off-by: Ankitkumar Patel <ankit@research.att.com>
Diffstat (limited to 'osdf')
-rw-r--r-- | osdf/adapters/local_data/local_policies.py | 13 | ||||
-rw-r--r-- | osdf/optimizers/placementopt/conductor/translation.py | 21 |
2 files changed, 23 insertions, 11 deletions
diff --git a/osdf/adapters/local_data/local_policies.py b/osdf/adapters/local_data/local_policies.py index e722fe2..6e49388 100644 --- a/osdf/adapters/local_data/local_policies.py +++ b/osdf/adapters/local_data/local_policies.py @@ -33,11 +33,14 @@ def get_local_policies(local_policy_folder, local_policy_list, policy_id_list=No :return: get policies """ policies = [] - for fname in local_policy_list: # ugly removal of .json from file name - if policy_id_list and fname[:-5] not in policy_id_list: - continue - with open(os.path.join(local_policy_folder, fname)) as fid: - policies.append(json.load(fid)) + if policy_id_list: + for policy_id in policy_id_list: + with open(os.path.join(local_policy_folder, policy_id + ".json")) as fid: + policies.append(json.load(fid)) + else: + for fname in local_policy_list: + with open(os.path.join(local_policy_folder, fname)) as fid: + policies.append(json.load(fid)) return policies diff --git a/osdf/optimizers/placementopt/conductor/translation.py b/osdf/optimizers/placementopt/conductor/translation.py index 5f44c83..e703c36 100644 --- a/osdf/optimizers/placementopt/conductor/translation.py +++ b/osdf/optimizers/placementopt/conductor/translation.py @@ -221,12 +221,21 @@ def get_demand_properties(demand, policies): for policy_property in get_policy_properties(demand, policies): prop = dict(inventory_provider=policy_property['inventoryProvider'], inventory_type=policy_property['inventoryType'], - service_resource_id=demand['serviceResourceId']) - if 'attributes' in policy_property: - prop['attributes'] = get_augmented_policy_attributes(policy_property, demand) - for k1, v1, k2, v2 in policy_config_mapping['extra_fields']: - if k1 == v1: - prop[k2] = v2 + service_type=demand['serviceResourceId']) + attributes = policy_config_mapping['attributes'] + prop['attributes'] = { + 'customer-id': policy_property['customerId'], + 'orchestration-status': "", + 'model-invariant-id': demand['resourceModelInfo']['modelInvariantId'], + 'model-version-id': demand['resourceModelInfo']['modelVersionId'], + 'service-type': demand['serviceResourceId'], + 'equipment-role': policy_property['equipmentRole'] + } + # if 'attributes' in policy_property: + # prop['attributes'] = get_augmented_policy_attributes(policy_property, demand) + # for k1, v1, k2, v2 in policy_config_mapping['extra_fields']: + # if k1 == v1: + # prop[k2] = v2 prop.update(get_candidates_demands(demand)) # for excluded and partial-rehoming cases demand_properties.append(prop) return demand_properties |