diff --git a/helpers/postgresql.py b/helpers/postgresql.py index 0c31ddac..6348c3ff 100644 --- a/helpers/postgresql.py +++ b/helpers/postgresql.py @@ -38,6 +38,7 @@ class Postgresql: def __init__(self, config): self.config = config self.name = config['name'] + self.scope = config['scope'] self.listen_addresses, self.port = config['listen'].split(':') self.data_dir = config['data_dir'] self.replication = config['replication'] @@ -250,7 +251,7 @@ class Postgresql: except psycopg2.OperationalError as e: logger.warning("unable to perform {0} action, cannot obtain the cluster role: {1}".format(cb_name, e)) return False - name = self.name + name = self.scope try: role = "master" if is_leader else "replica" subprocess.Popen(shlex.split(os.path.abspath(cmd))+[cb_name, role, name]) diff --git a/scripts/aws.py b/scripts/aws.py old mode 100755 new mode 100644 index 6a04da92..0025e44e --- a/scripts/aws.py +++ b/scripts/aws.py @@ -1,3 +1,5 @@ +#!/usr/bin/python + import logging import requests from requests.exceptions import RequestException @@ -71,12 +73,12 @@ class AWSConnection: if __name__ == '__main__': - if len(sys.argv) != 3: + if len(sys.argv) != 4: print ("Usage: {0} action role name".format(sys.argv[0])) - return 1 + sys.exit(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(role) - return 0 - return 2 + sys.exit(0) + sys.exit(2)