Pass text names of cluster roles to the script.

Seems better than passing a bool flag and
converting it from/to string.
This commit is contained in:
Oleksii Kliukin
2015-07-17 15:39:34 +02:00
parent 33b5e1b22e
commit a11d94aff5
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -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):
+2 -2
View File
@@ -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