From a11d94aff53d00595e0e8c6c598a5af84a48d0e5 Mon Sep 17 00:00:00 2001 From: Oleksii Kliukin Date: Fri, 17 Jul 2015 15:39:34 +0200 Subject: [PATCH] Pass text names of cluster roles to the script. Seems better than passing a bool flag and converting it from/to string. --- helpers/postgresql.py | 2 +- scripts/aws.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/postgresql.py b/helpers/postgresql.py index 3fcb44da..371c187a 100644 --- a/helpers/postgresql.py +++ b/helpers/postgresql.py @@ -251,7 +251,7 @@ class Postgresql: logger.warning("unable to perform {0} action, cannot obtain the cluster role: {1}".format(cb_name, e)) return False name = self.name - subprocess.Popen(shlex.split(os.path.abspath(cmd))+[cb_name, is_leader, name]) + subprocess.Popen(shlex.split(os.path.abspath(cmd))+[cb_name, "master" if is_leader else "replica", name]) return True def start(self): diff --git a/scripts/aws.py b/scripts/aws.py index 7930323e..6a04da92 100644 --- a/scripts/aws.py +++ b/scripts/aws.py @@ -74,9 +74,9 @@ if __name__ == '__main__': if len(sys.argv) != 3: print ("Usage: {0} action role name".format(sys.argv[0])) return 1 - action, is_master, name = sys.argv[1:] + action, role, name = sys.argv[1:] if action in ('on_start', 'on_stop', 'on_role_change'): aws = AWSConnection({'cluster_name': name}) - aws.on_role_change('master' if is_master else 'replica') + aws.on_role_change(role) return 0 return 2