diff options
author | Patel, Ankitkumar <ankit@research.att.com> | 2018-05-29 11:31:55 -0400 |
---|---|---|
committer | Patel, Ankitkumar <ankit@research.att.com> | 2018-05-29 11:32:57 -0400 |
commit | 49a0eac16462c04c285125686fb235c22c9ad607 (patch) | |
tree | e96d5778f5de6cce5d8007febec78e542d1d70e3 /osdf/optimizers/placementopt/conductor/translation.py | |
parent | b259e6ae5bb534e8885f88a02a9165b8b8442f3e (diff) |
Fixed case sensitive resource matching
Fixed the case sensitive matching for resources between policy and request.
Issue-ID: OPTFRA-247
Change-Id: Ic031f6c950b6c6b44bd2e4231a9ef672beea994b
Signed-off-by: Patel, Ankitkumar <ankit@research.att.com>
Diffstat (limited to 'osdf/optimizers/placementopt/conductor/translation.py')
-rw-r--r-- | osdf/optimizers/placementopt/conductor/translation.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/osdf/optimizers/placementopt/conductor/translation.py b/osdf/optimizers/placementopt/conductor/translation.py index 4206276..f1c12c8 100644 --- a/osdf/optimizers/placementopt/conductor/translation.py +++ b/osdf/optimizers/placementopt/conductor/translation.py @@ -77,11 +77,13 @@ def get_matching_vnfs(resources, vnf_list, match_type="intersection"): :param match_type: "intersection" or "all" or "any" (any => send all_vnfs if there is any intersection) :return: List of matching VNFs """ + resources_lcase = [x.lower() for x in resources] if match_type == "all": # don't bother with any comparisons - return resources if set(resources) <= set(vnf_list) else None - common_vnfs = set(vnf_list) & set(resources) + return resources if set(resources_lcase) <= set(vnf_list) else None + common_vnfs = set(vnf_list) & set(resources_lcase) + common_resources = [x for x in resources if x.lower() in common_vnfs] if match_type == "intersection": # specifically requested intersection - return list(common_vnfs) + return list(common_resources) return resources if common_vnfs else None # "any" match => all resources to be returned @@ -209,7 +211,8 @@ def get_candidates_demands(demand): def get_policy_properties(demand, policies): """Get policy_properties for cases where there is a match with the demand""" for policy in policies: - if demand['resourceModuleName'] not in set(policy['content'].get('resources', [])): + policy_demands = set([x.lower() for x in policy['content'].get('resources', [])]) + if demand['resourceModuleName'].lower() not in policy_demands: continue # no match for this policy for policy_property in policy['content']['vnfProperties']: yield policy_property |