summaryrefslogtreecommitdiffstats
path: root/policyhandler/deploy_handler.py
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2017-09-12 13:00:25 -0400
committerAlex Shatov <alexs@att.com>2017-09-12 13:00:25 -0400
commit42a989a6b9b6388947da6fc273728a24c19fa686 (patch)
tree9d1dfc98ddd56fe058c030f9b4b8ce117aa16717 /policyhandler/deploy_handler.py
parentfe9c74b9933745144bfd8134bc96fd77fa3291f8 (diff)
1.0.0 and policy API to deployment-handler
* policy API to deployment-handler /policy * removed pycrypto of config - the same way as other apps * simple upload of config to consul - curl * preparation for policy-handler blueprint Change-Id: I424a1ded0795562ea36b5409304cbb8b5a7e8a24 Issue-Id: DCAEGEN2-62 Signed-off-by: Alex Shatov <alexs@att.com>
Diffstat (limited to 'policyhandler/deploy_handler.py')
-rw-r--r--policyhandler/deploy_handler.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/policyhandler/deploy_handler.py b/policyhandler/deploy_handler.py
index 02807f8..7d9c513 100644
--- a/policyhandler/deploy_handler.py
+++ b/policyhandler/deploy_handler.py
@@ -30,11 +30,10 @@ from .onap.audit import REQUEST_X_ECOMP_REQUESTID, Audit, AuditHttpCode
class DeployHandler(object):
""" deploy-handler """
_logger = logging.getLogger("policy_handler.deploy_handler")
- _policy_update = '/policy_update'
_lazy_inited = False
_config = None
_url = None
- _path = None
+ _url_path = None
_target_entity = None
@staticmethod
@@ -45,7 +44,7 @@ class DeployHandler(object):
DeployHandler._lazy_inited = True
DeployHandler._target_entity = Config.config["deploy_handler"]
DeployHandler._url = DiscoveryClient.get_service_url(DeployHandler._target_entity)
- DeployHandler._path = DeployHandler._url + DeployHandler._policy_update
+ DeployHandler._url_path = DeployHandler._url + '/policy'
DeployHandler._logger.info("DeployHandler url(%s)", DeployHandler._url)
@staticmethod
@@ -53,24 +52,24 @@ class DeployHandler(object):
""" post policy_updated message to deploy-handler """
DeployHandler._lazy_init()
msg = {"latest_policies":latest_policies}
- sub_aud = Audit(aud_parent=audit, targetEntity=DeployHandler._target_entity, \
- targetServiceName=DeployHandler._path)
+ 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)
headers_str = json.dumps(headers)
- log_line = "post to deployment-handler {0} msg={1} headers={2}".format(\
- DeployHandler._path, msg_str, headers_str)
+ log_line = "post to deployment-handler {0} msg={1} headers={2}".format(
+ DeployHandler._url_path, msg_str, headers_str)
sub_aud.metrics_start(log_line)
DeployHandler._logger.info(log_line)
res = None
try:
- res = requests.post(DeployHandler._path, json=msg, headers=headers)
+ res = requests.post(DeployHandler._url_path, json=msg, headers=headers)
except requests.exceptions.RequestException as ex:
error_msg = "failed to post to deployment-handler {0} {1} msg={2} headers={3}" \
- .format(DeployHandler._path, str(ex), msg_str, headers_str)
+ .format(DeployHandler._url_path, str(ex), msg_str, headers_str)
DeployHandler._logger.exception(error_msg)
sub_aud.set_http_status_code(AuditHttpCode.SERVICE_UNAVAILABLE_ERROR.value)
audit.set_http_status_code(AuditHttpCode.SERVICE_UNAVAILABLE_ERROR.value)
@@ -80,9 +79,10 @@ class DeployHandler(object):
sub_aud.set_http_status_code(res.status_code)
audit.set_http_status_code(res.status_code)
- sub_aud.metrics( \
+ sub_aud.metrics(
"response from deployment-handler to post {0}: {1} msg={2} text={3} headers={4}" \
- .format(DeployHandler._path, res.status_code, msg_str, res.text, res.request.headers))
+ .format(DeployHandler._url_path, res.status_code, msg_str, res.text,
+ res.request.headers))
if res.status_code == requests.codes.ok:
return res.json()