Skip to content

Commit 50de50f

Browse files
author
Robert Gartman
committed
Automate _cluster_setup
1 parent a83865b commit 50de50f

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

mem3_helper.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,28 @@ def finish_cluster(names):
107107
# http://docs.couchdb.org/en/stable/cluster/setup.html
108108

109109
# action: enable_cluster
110-
payload = '"action": "enable_cluster", "bind_address":"0.0.0.0", "username":"{0}", "password":"{1}", "port": 5984, "node_count":"{2}" "remote_node": "{3}", "remote_current_user": "{0}", "remote_current_password": "{1}"'.format(creds[0],creds[1],nr_of_peers,name)
111-
setup_resp=requests.post("http://127.0.0.1:5984/_cluster_setup", json={payload}, auth=creds)
112-
print ("POST to http://127.0.0.1:5984/_cluster_setup returned",setup_resp.status_code,"payload=",payload)
110+
payload = {}
111+
payload['action'] = 'enable_cluster'
112+
payload['bind_address'] = '0.0.0.0'
113+
payload['username'] = creds[0]
114+
payload['password'] = creds[1]
115+
payload['port'] = 5984
116+
payload['node_count'] = len(names)
117+
payload['remote_node'] = name
118+
payload['remote_current_user'] = creds[0]
119+
payload['remote_current_password'] = creds[1]
120+
setup_resp=requests.post("http://127.0.0.1:5984/_cluster_setup", json.dumps(payload), auth=creds)
121+
print ("POST to http://127.0.0.1:5984/_cluster_setup returned",setup_resp.status_code,"payload=",json.dumps(payload))
113122

114123
# action: add_node
115-
payload = '"action": "add_node", "host":"{0}", "port": 5984, "username": "{1}", "password":"{2}"'.format(name, creds[0],creds[1])
116-
setup_resp=requests.post("http://127.0.0.1:5984/_cluster_setup", json={payload}, auth=creds)
117-
print ("POST to http://127.0.0.1:5984/_cluster_setup returned",setup_resp.status_code,"payload=",payload)
124+
payload = {}
125+
payload['action'] = 'add_node'
126+
payload['username'] = creds[0]
127+
payload['password'] = creds[1]
128+
payload['port'] = 5984
129+
payload['host'] = name
130+
setup_resp=requests.post("http://127.0.0.1:5984/_cluster_setup", json.dumps(payload), auth=creds)
131+
print ("POST to http://127.0.0.1:5984/_cluster_setup returned",setup_resp.status_code,"payload=",json.dumps(payload))
118132

119133
print('CouchDB cluster peer {} added to "setup coordination node"'.format(name))
120134
# At this point ALL peers have _nodes populated. Finish the cluster setup!

0 commit comments

Comments
 (0)