Skip to content

Commit

Permalink
Merge pull request #13 from axadil/selective-routes
Browse files Browse the repository at this point in the history
Select which routes should be accessible
  • Loading branch information
olivierHa committed Mar 8, 2016
2 parents ebae795 + fcf2437 commit a2b2315
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions etc/modules/ws_arbiter.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
29 changes: 23 additions & 6 deletions module/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand Down

0 comments on commit a2b2315

Please sign in to comment.