Skip to content

Commit efa95bf

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

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mem3_helper.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,14 @@ def enable_cluster(nr_of_peers):
146146
creds = (os.getenv("COUCHDB_USER"), os.getenv("COUCHDB_PASSWORD"))
147147
if creds[0] and creds[1]:
148148
# http://docs.couchdb.org/en/stable/cluster/setup.html
149-
payload = '"action": "enable_cluster", "bind_address":"0.0.0.0", "{0}": "admin", "{1}":"password", "node_count":"{2}"'.format(creds[0],creds[1],nr_of_peers)
150-
setup_resp=requests.post("http://127.0.0.1:5984/_cluster_setup", json={payload}, auth=creds)
151-
print ("POST to http://127.0.0.1:5984/_cluster_setup returned",setup_resp.status_code,"payload=",payload)
149+
payload = {}
150+
payload['action'] = 'enable_cluster'
151+
payload['bind_address'] = '0.0.0.0'
152+
payload['username'] = creds[0]
153+
payload['password'] = creds[1]
154+
payload['node_count'] = len(names)
155+
setup_resp=requests.post("http://127.0.0.1:5984/_cluster_setup", json.dumps(payload), auth=creds)
156+
print ("POST to http://127.0.0.1:5984/_cluster_setup returned",setup_resp.status_code,"payload=",json.dumps(payload))
152157

153158
def sleep_forever():
154159
while True:

0 commit comments

Comments
 (0)