aboutsummaryrefslogtreecommitdiffstats
path: root/policyhandler/deploy_handler.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/deploy_handler.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/deploy_handler.py')
-rw-r--r--policyhandler/deploy_handler.py25
1 files changed, 6 insertions, 19 deletions
diff --git a/policyhandler/deploy_handler.py b/policyhandler/deploy_handler.py
index 0dc86b9..306a637 100644
--- a/policyhandler/deploy_handler.py
+++ b/policyhandler/deploy_handler.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.
@@ -63,33 +63,20 @@ class DeployHandler(object):
DeployHandler._logger.info("DeployHandler url(%s)", DeployHandler._url)
@staticmethod
- def policy_update(audit, latest_policies, removed_policies=None,
- errored_policies=None, catch_up=False):
+ def policy_update(audit, message):
"""post policy_updated message to deploy-handler"""
- if not latest_policies and not removed_policies and not catch_up:
+ if not message:
return
- latest_policies = latest_policies or {}
- removed_policies = removed_policies or {}
- errored_policies = errored_policies or {}
-
DeployHandler._lazy_init()
- msg = {
- "catch_up" : catch_up,
- "latest_policies" : latest_policies,
- "removed_policies" : removed_policies,
- "errored_policies" : errored_policies
- }
sub_aud = Audit(aud_parent=audit, targetEntity=DeployHandler._target_entity,
targetServiceName=DeployHandler._url_path)
headers = {REQUEST_X_ECOMP_REQUESTID : sub_aud.request_id}
- msg_str = json.dumps(msg)
+ msg_str = json.dumps(message)
headers_str = json.dumps(headers)
- DeployHandler._logger.info(
- "catch_up(%s) latest_policies[%s], removed_policies[%s], errored_policies[%s]",
- catch_up, len(latest_policies), len(removed_policies), len(errored_policies))
+ DeployHandler._logger.info("message: %s", msg_str)
log_line = "post to deployment-handler {0} msg={1} headers={2}".format(
DeployHandler._url_path, msg_str, headers_str)
@@ -107,7 +94,7 @@ class DeployHandler(object):
res = None
try:
res = DeployHandler._requests_session.post(
- DeployHandler._url_path, json=msg, headers=headers
+ DeployHandler._url_path, json=message, headers=headers
)
except requests.exceptions.RequestException as ex:
error_msg = "failed to post to deployment-handler {0} {1} msg={2} headers={3}" \