@@ -107,14 +107,28 @@ def finish_cluster(names):
107
107
# http://docs.couchdb.org/en/stable/cluster/setup.html
108
108
109
109
# 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 ))
113
122
114
123
# 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 ))
118
132
119
133
print ('CouchDB cluster peer {} added to "setup coordination node"' .format (name ))
120
134
# At this point ALL peers have _nodes populated. Finish the cluster setup!
0 commit comments