diff options
author | Alex Shatov <alexs@att.com> | 2018-08-10 11:03:02 -0400 |
---|---|---|
committer | Alex Shatov <alexs@att.com> | 2018-08-10 11:03:02 -0400 |
commit | 1c4c6626f2abb24bcb35af581c6e57130f0ccae2 (patch) | |
tree | 50685aa2bbb965a6a281eef50e449b48c2e3e87c /policyhandler/policy_utils.py | |
parent | d7f34d4b71ec4d86547628cda351d20bff4d017f (diff) |
4.0.1 fix for removing the non-matching policy
- fixed removing the policy that no longer match the filter
= sending an empty policy_filter_matches for the policy_id
- cleaner workaround on getting the updated policy
when policy-engine sent policy-update notification
before finishing the update on there side
= using the collection of expected_versions instead
of min_version_expected
- some minor refactoring on policy_matcher and audit
Change-Id: Ica3cb810378e61d6991c616f88265ff170d32a64
Signed-off-by: Alex Shatov <alexs@att.com>
Issue-ID: DCAEGEN2-492
Diffstat (limited to 'policyhandler/policy_utils.py')
-rw-r--r-- | policyhandler/policy_utils.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/policyhandler/policy_utils.py b/policyhandler/policy_utils.py index c63f382..da83935 100644 --- a/policyhandler/policy_utils.py +++ b/policyhandler/policy_utils.py @@ -76,7 +76,7 @@ class PolicyUtils(object): return {POLICY_ID:policy_id, POLICY_BODY:policy_body} @staticmethod - def select_latest_policy(policy_bodies, min_version_expected=None, ignore_policy_names=None): + def select_latest_policy(policy_bodies, expected_versions=None, ignore_policy_names=None): """For some reason, the policy-engine returns all version of the policy_bodies. DCAE-Controller is only interested in the latest version """ @@ -88,14 +88,13 @@ class PolicyUtils(object): policy_version = policy_body.get(POLICY_VERSION) if not policy_name or not policy_version or not policy_version.isdigit(): continue - policy_version = int(policy_version) - if min_version_expected and policy_version < min_version_expected: + if expected_versions and policy_version not in expected_versions: continue if ignore_policy_names and policy_name in ignore_policy_names: continue if (not latest_policy_body - or int(latest_policy_body[POLICY_VERSION]) < policy_version): + or int(latest_policy_body[POLICY_VERSION]) < int(policy_version)): latest_policy_body = policy_body return PolicyUtils.parse_policy_config(PolicyUtils.convert_to_policy(latest_policy_body)) |