-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster.py
47 lines (40 loc) · 1.15 KB
/
cluster.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from common import cget, cpost, nodes, username, password
def setup_cluster():
print("setting up cluster...")
for node in nodes[1:]:
print(f"joining {node['private_address']} to cluster...")
cpost(
0,
"/_cluster_setup",
{
"action": "enable_cluster",
"bind_address": "0.0.0.0",
"username": username,
"password": password,
"node_count": str(len(nodes)),
"remote_node": node["private_address"],
"remote_current_user": username,
"remote_current_password": password,
},
)
cpost(
0,
"/_cluster_setup",
{
"action": "add_node",
"host": node["private_address"],
"port": 5984,
"username": username,
"password": password,
},
)
print("finishing cluster...")
cpost(
0,
"/_cluster_setup",
{
"action": "finish_cluster",
},
)
cget(0, "/_cluster_setup")
print("done")