Pass scope, the cluster name, instead of the name, which is the instance name, to the callback.

This commit is contained in:
Oleksii Kliukin
2015-07-23 16:16:22 +02:00
parent f1d76611b6
commit c9c678fb5b
2 changed files with 8 additions and 5 deletions
+2 -1
View File
@@ -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])
Executable → Regular
+6 -4
View File
@@ -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)