From 61960d0ca9556843596975506fc949ae90ebb776 Mon Sep 17 00:00:00 2001 From: Ankitkumar Patel Date: Tue, 22 May 2018 22:57:54 -0400 Subject: Eliminating emply elements from HAS template Eliminating empty elements from HAS template Issue-ID: OPTFRA-243 Change-Id: Iec6acf95f6f0a98757e3d208f102998d197b2daa Signed-off-by: Ankitkumar Patel --- .../optimizers/placementopt/conductor/conductor.py | 2 +- .../placementopt/conductor/translation.py | 25 +++++++++------------- osdf/templates/conductor_interface.json | 2 +- .../pdp-has-vcpe-good/Affinity_vCPE_1.json | 2 +- .../pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json | 4 ++-- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/osdf/optimizers/placementopt/conductor/conductor.py b/osdf/optimizers/placementopt/conductor/conductor.py index 49e7bfc..c872e5a 100644 --- a/osdf/optimizers/placementopt/conductor/conductor.py +++ b/osdf/optimizers/placementopt/conductor/conductor.py @@ -106,7 +106,7 @@ def initial_request_to_conductor(rc, conductor_url, conductor_req_json): raise RequestException(response=raw_resp, request=raw_resp.request) time.sleep(10) # 10 seconds wait time to avoid being too quick! plan_url = resp["links"][0][0]["href"] - debug_log.debug("Attemping to read the plan from the conductor provided url {}".format(plan_url)) + debug_log.debug("Attempting to read the plan from the conductor provided url {}".format(plan_url)) raw_resp = rc.request(raw_response=True, url=plan_url) # TODO: check why a list of lists for links resp = raw_resp.json() diff --git a/osdf/optimizers/placementopt/conductor/translation.py b/osdf/optimizers/placementopt/conductor/translation.py index 7bef01c..4206276 100644 --- a/osdf/optimizers/placementopt/conductor/translation.py +++ b/osdf/optimizers/placementopt/conductor/translation.py @@ -222,21 +222,16 @@ def get_demand_properties(demand, policies): prop = dict(inventory_provider=policy_property['inventoryProvider'], inventory_type=policy_property['inventoryType'], service_type=demand['serviceResourceId']) - attributes = policy_config_mapping['attributes'] - prop['attributes'] = { - 'global-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 + prop['attributes'] = dict() + prop['attributes'].update({'global-customer-id': policy_property['customerId']} + if policy_property['customerId'] else {}) + prop['attributes'].update({'model-invariant-id': demand['resourceModelInfo']['modelInvariantId']} + if demand['resourceModelInfo']['modelInvariantId'] else {}) + prop['attributes'].update({'model-version-id': demand['resourceModelInfo']['modelVersionId']} + if demand['resourceModelInfo']['modelVersionId'] else {}) + prop['attributes'].update({'equipment-role': policy_property['equipmentRole']} + if policy_property['equipmentRole'] else {}) + prop.update(get_candidates_demands(demand)) demand_properties.append(prop) return demand_properties diff --git a/osdf/templates/conductor_interface.json b/osdf/templates/conductor_interface.json index 9ab2c82..d2258a0 100755 --- a/osdf/templates/conductor_interface.json +++ b/osdf/templates/conductor_interface.json @@ -4,7 +4,7 @@ "timeout": {{ timeout }}, "limit": {{ limit }}, "template": { - "homing_template_version": "2018-02-01", + "homing_template_version": "2017-10-10", "parameters": { "service_name": "{{ service_name }}", "service_id": "{{ service_id }}", diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Affinity_vCPE_1.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Affinity_vCPE_1.json index c9046dd..6f0ecb3 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Affinity_vCPE_1.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/Affinity_vCPE_1.json @@ -12,7 +12,7 @@ "identity": "affinity_vCPE", "policyScope": ["vCPE", "US", "INTERNATIONAL", "ip", "vGMuxInfra", "vG"], "affinityProperty": { - "qualifier": "different", + "qualifier": "same", "category": "complex" }, "policyType": "zone", diff --git a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json index 7ac6dff..6849105 100644 --- a/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json +++ b/test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/vnfPolicy_vGMuxInfra.json @@ -17,9 +17,9 @@ "vnfProperties": [ { "inventoryProvider": "aai", - "serviceType": "vGMuxInfra", + "serviceType": "vGMuxInfra-xx", "inventoryType": "service", - "customerId": "", + "customerId": "SDN-ETHERNET-INTERNET", "orchestrationStatus": "", "equipmentRole": "" } -- cgit 1.2.3-korg