From 44e10699827c4f0a7d18deab2cd53e3c99d30361 Mon Sep 17 00:00:00 2001 From: Benjamin MALYNOVYTCH Date: Wed, 7 Oct 2015 16:11:12 +0200 Subject: [PATCH 1/2] Add the ability to select which routes should be accessible through the module --- etc/modules/ws_arbiter.cfg | 1 + module/module.py | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/etc/modules/ws_arbiter.cfg b/etc/modules/ws_arbiter.cfg index bbac80b..1ab2abb 100644 --- a/etc/modules/ws_arbiter.cfg +++ b/etc/modules/ws_arbiter.cfg @@ -9,4 +9,5 @@ define module { port 7760 username anonymous ; If you want auth, set username and password. #password secret + routes push_check_result ; restart,reload,acknowledge,downtime,recheck } diff --git a/module/module.py b/module/module.py index e3f6178..1580cf6 100644 --- a/module/module.py +++ b/module/module.py @@ -369,6 +369,11 @@ def __init__(self, modconf): self.password = getattr(modconf, 'password', '') self.port = int(getattr(modconf, 'port', '7760')) self.host = getattr(modconf, 'host', '0.0.0.0') + + self.routes = getattr(modconf, 'routes', None) + if self.routes is not None: + self.routes = self.routes.split(',') + logger.info("[WS_Arbiter] Configuration done, host: %s(%s), username: %s)" %(self.host, self.port, self.username)) except AttributeError: logger.error("[WS_Arbiter] The module is missing a property, check module declaration in shinken-specific.cfg") @@ -389,12 +394,24 @@ def init_http(self): logger.info("[WS_Arbiter] Server started") # And we link our page - route('/push_check_result', callback=get_page, method='POST') - route('/restart', callback=do_restart, method='POST') - route('/reload', callback=do_reload, method='POST') - route('/acknowledge', callback=do_acknowledge, method='POST') - route('/downtime', callback=do_downtime, method='POST') - route('/recheck', callback=do_recheck, method='POST') + + if self.routes is None or 'push_check_result' in self.routes: + route('/push_check_result', callback=get_page, method='POST') + + if self.routes is None or 'restart' in self.routes: + route('/restart', callback=do_restart, method='POST') + + if self.routes is None or 'reload' in self.routes: + route('/reload', callback=do_reload, method='POST') + + if self.routes is None or 'acknowledge' in self.routes: + route('/acknowledge', callback=do_acknowledge, method='POST') + + if self.routes is None or 'downtime' in self.routes: + route('/downtime', callback=do_downtime, method='POST') + + if self.routes is None or 'recheck' in self.routes: + route('/recheck', callback=do_recheck, method='POST') # When you are in "external" mode, that is the main loop of your process def main(self): From fcf2437d3ad8a75f71c4046c01780ca3bae91e9e Mon Sep 17 00:00:00 2001 From: Benjamin MALYNOVYTCH Date: Wed, 7 Oct 2015 17:57:21 +0200 Subject: [PATCH 2/2] Restore default behavior --- etc/modules/ws_arbiter.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/modules/ws_arbiter.cfg b/etc/modules/ws_arbiter.cfg index 1ab2abb..30f71c7 100644 --- a/etc/modules/ws_arbiter.cfg +++ b/etc/modules/ws_arbiter.cfg @@ -9,5 +9,5 @@ define module { port 7760 username anonymous ; If you want auth, set username and password. #password secret - routes push_check_result ; restart,reload,acknowledge,downtime,recheck + #routes push_check_result ; restart,reload,acknowledge,downtime,recheck }