aboutsummaryrefslogtreecommitdiffstats
path: root/policyhandler/web_server.py
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2019-01-31 16:07:48 -0500
committerAlex Shatov <alexs@att.com>2019-01-31 16:07:48 -0500
commitebc1a062328e53e97e4d24ed111534cfc567a809 (patch)
treeb0721077df349f2cee5d1a7426f4de0acc1855cb /policyhandler/web_server.py
parenta39f4e82cef0414f510cf20e25864ac04cc8f055 (diff)
4.6.0 policy-handler - active-passive
DCAEGEN2-931: - exposed POST /reconfigure endpoint on the web-server that initiates the reconfigure process right away DCAEGEN2-932: - mode_of_operation: active or passive = active is as before this change = in passive mode the policy-handler * closes the web-socket to PDP * skips the periodic catch_ups * still periodically checks for reconfigure * still allows usig the web-server to retrieve policies from PDP - default is active - when mode_of_operation changes from passive to active, the policy-handler invokes the catch_up right away - config-kv contains the optional override field mode_of_operation = changing the mode_of_operation in config-kv and invoking POST /reconfigure will bring the new value and change the mode of operation of the policy-handler if no service_activator section is provided in consul-kv record - if config-kv contains the service_activator section, = the policy-handler registers with service_activator - untested = and receives the mode_of_operation - untested = service_activator can POST-notify the policy-handler to initiate the /reconfigure - reduced the default web-socket ping interval from 180 to 30 seconds because PDP changed its default timeout on the web-socket from 400 seconds to 50 seconds Change-Id: If7dd21c008d9906aca97939be65dfa9c2f007535 Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-931 Issue-ID: DCAEGEN2-932
Diffstat (limited to 'policyhandler/web_server.py')
-rw-r--r--policyhandler/web_server.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/policyhandler/web_server.py b/policyhandler/web_server.py
index 73e7fbc..dc76353 100644
--- a/policyhandler/web_server.py
+++ b/policyhandler/web_server.py
@@ -1,5 +1,5 @@
# ================================================================================
-# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2017-2019 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.
@@ -208,7 +208,24 @@ class _PolicyWeb(object):
PolicyWeb.logger.info("%s", req_info)
PolicyReceiver.catch_up(audit)
- res = {"catch-up requested": started}
+ res = {"catch-up requested": started, "request_id": audit.request_id}
+ PolicyWeb.logger.info("requested %s: %s", req_info, json.dumps(res))
+ audit.info_requested(started)
+ return res
+
+ @cherrypy.expose
+ @cherrypy.tools.json_out()
+ def reconfigure(self):
+ """schedule reconfigure"""
+ started = str(datetime.utcnow())
+ req_info = _PolicyWeb._get_request_info(cherrypy.request)
+ audit = Audit(job_name="reconfigure", req_message=req_info,
+ headers=cherrypy.request.headers)
+
+ PolicyWeb.logger.info("%s", req_info)
+ PolicyReceiver.reconfigure(audit)
+
+ res = {"reconfigure requested": started, "request_id": audit.request_id}
PolicyWeb.logger.info("requested %s: %s", req_info, json.dumps(res))
audit.info_requested(started)
return res