From 1c4c6626f2abb24bcb35af581c6e57130f0ccae2 Mon Sep 17 00:00:00 2001 From: Alex Shatov Date: Fri, 10 Aug 2018 11:03:02 -0400 Subject: 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 Issue-ID: DCAEGEN2-492 --- policyhandler/policy_utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'policyhandler/policy_utils.py') 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)) -- cgit 1.2.3-korg