From f64f75190af83fae9a4ccc6a1ce10ee885c7d4ce Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Wed, 12 Jun 2019 19:29:34 +0200 Subject: [PATCH] Added version API, logs and variable. Added linebreak after some API answers. Fixed > to >= for redis_manager count. Bumped version to 3. --- redis-manager.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/redis-manager.py b/redis-manager.py index 74de278..551fb8d 100755 --- a/redis-manager.py +++ b/redis-manager.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # Author : Yohan Bataille (ING) -# redis-manager v2 +# redis-manager +version = "3" # Requires: # redis-cli @@ -23,6 +24,7 @@ import pprint import urllib2 from random import randint +print("redis manager version: " + version) # positional : REDIS_PATH, REDIS_NODES, ENV, HTTP_PORT (in this order, all mandatory, ENV : "DEV" or "PROD") # optional : time (-t), dry_run (-n) @@ -130,6 +132,8 @@ def api_help(): # 'CANNOT PROCEED: passive manager' # example : /prepare_for_reboot/10.166.20.120&duration=300 +# /version : redis manager version + """ # TODO: Remove global variables. @@ -201,7 +205,7 @@ def main(): elif num_manager_active == 1 and manager_status == 'starting': print("Manager election finished, we are passive!") manager_status = 'passive' - elif num_manager_active > 1 and manager_status == 'active': + elif num_manager_active >= 1 and manager_status == 'active': print("Becoming passive!") manager_status = 'passive' @@ -923,6 +927,11 @@ class MyHandler(BaseHTTPRequestHandler): elif self.path == '/debug/disable': self.send_response(200) debug = False + elif self.path == '/version': + self.send_response(200) + self.send_header('Content-type', 'text/plain') + self.end_headers() + self.wfile.write(version+'\n') elif self.path == '/help': self.send_response(200) self.send_header('Content-type', 'text/plain') @@ -932,7 +941,7 @@ class MyHandler(BaseHTTPRequestHandler): self.send_response(200) self.send_header('Content-type', 'text/plain') self.end_headers() - self.wfile.write(cluster_state) + self.wfile.write(cluster_state+'\n') elif self.path == '/manager_status': self.send_response(200) self.send_header('Content-type', 'text/plain')