aboutsummaryrefslogtreecommitdiffstats
path: root/policyhandler/policy_updater.py
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2018-02-01 14:16:56 -0500
committerAlex Shatov <alexs@att.com>2018-02-01 14:16:56 -0500
commitac779d374ca12099eaeb8e5d89e65df37fd8a8f4 (patch)
tree181e0b72ead781dcab526124c81096980a552e8b /policyhandler/policy_updater.py
parent2322ef8736e839d62930d9b6c847ce818261c26c (diff)
improved message to deployment-handler and on API
* added errored_scopes and scope_prefixes to the message to deployment-handler - to prevent erroneous removal of policies * hardcoded condition for scope not found 404 at policy-engine to separate it from error on the scope retrieval 400 * adjusting the web API message in sync with notification to deployment-handler * unit test coverage 74% Change-Id: Ie736a1b7aee0631b6785669c6b765bd240dd77b8 Issue-ID: DCAEGEN2-249 Signed-off-by: Alex Shatov <alexs@att.com>
Diffstat (limited to 'policyhandler/policy_updater.py')
-rw-r--r--policyhandler/policy_updater.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/policyhandler/policy_updater.py b/policyhandler/policy_updater.py
index 0e06f2c..2bce30b 100644
--- a/policyhandler/policy_updater.py
+++ b/policyhandler/policy_updater.py
@@ -1,6 +1,6 @@
# org.onap.dcae
# ================================================================================
-# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
# ================================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -19,14 +19,15 @@
"""policy-updater thread"""
-import logging
import json
+import logging
from Queue import Queue
-from threading import Thread, Lock
+from threading import Lock, Thread
-from .policy_rest import PolicyRest
from .deploy_handler import DeployHandler
from .onap.audit import Audit
+from .policy_consts import CATCH_UP, LATEST_POLICIES, REMOVED_POLICIES
+from .policy_rest import PolicyRest
class PolicyUpdater(Thread):
"""queue and handle the policy-updates in a separate thread"""
@@ -72,7 +73,8 @@ class PolicyUpdater(Thread):
updated_policies, removed_policies = PolicyRest.get_latest_updated_policies(
(audit, policies_updated, policies_removed))
- DeployHandler.policy_update(audit, updated_policies, removed_policies=removed_policies)
+ message = {LATEST_POLICIES: updated_policies, REMOVED_POLICIES: removed_policies}
+ DeployHandler.policy_update(audit, message)
audit.audit_done()
self._queue.task_done()
@@ -114,15 +116,16 @@ class PolicyUpdater(Thread):
return False
PolicyUpdater._logger.info("catch_up")
- latest_policies, errored_policies = PolicyRest.get_latest_policies(aud_catch_up)
+
+ result = PolicyRest.get_latest_policies(aud_catch_up)
+ result[CATCH_UP] = True
if not aud_catch_up.is_success():
PolicyUpdater._logger.warn("not sending catch-up to deployment-handler due to errors")
if not audit:
self._queue.task_done()
else:
- DeployHandler.policy_update(
- aud_catch_up, latest_policies, errored_policies=errored_policies, catch_up=True)
+ DeployHandler.policy_update(aud_catch_up, result)
self._reset_queue()
success, _, _ = aud_catch_up.audit_done()
PolicyUpdater._logger.info("policy_handler health: %s", json.dumps(Audit.health()))