@@ -28,22 +28,14 @@ get_node_id()
28
28
echo " NODE: $NODE_ID "
29
29
}
30
30
31
- get_tokens_db ()
31
+ get_tokens ()
32
32
{
33
33
echo " Get MANAGER IP from Azure Table"
34
- export MANAGER_IP=$( python azuretokens .py get-ip)
34
+ export MANAGER_IP=$( python azureleader .py get-ip)
35
35
get_manager_token
36
36
get_worker_token
37
37
}
38
38
39
- get_tokens_local ()
40
- {
41
- export MANAGER_TOKEN=$( docker swarm join-token manager -q)
42
- export WORKER_TOKEN=$( docker swarm join-token worker -q)
43
- echo " MANAGER_TOKEN=$MANAGER_TOKEN "
44
- echo " WORKER_TOKEN=$WORKER_TOKEN "
45
- }
46
-
47
39
get_manager_token ()
48
40
{
49
41
if [ -n " $MANAGER_IP " ]; then
@@ -69,7 +61,7 @@ confirm_primary_ready()
69
61
n=0
70
62
until [ $n -ge 5 ]
71
63
do
72
- get_tokens_db
64
+ get_tokens
73
65
echo " PRIMARY_MANAGER_IP=$MANAGER_IP "
74
66
# if Manager IP or manager_token is empty or manager_token is null, not ready yet.
75
67
# token would be null for a short time between swarm init, and the time the
@@ -113,7 +105,7 @@ join_as_secondary_manager()
113
105
n=$[$n +1]
114
106
115
107
# query azure table again, incase the manager changed
116
- get_tokens_db
108
+ get_tokens
117
109
else
118
110
echo " Connected to primary manager, NODE_ID=$NODE_ID , SWARM_ID=$SWARM_ID "
119
111
break
@@ -134,21 +126,20 @@ setup_manager()
134
126
# try to create the azure table that will store tokens, if it succeeds then it is the first
135
127
# and it is the primary manager. If it fails, then it isn't first, and treat the record
136
128
# that is there, as the primary manager, and join that swarm.
137
- python azuretokens .py create-table
129
+ python azureleader .py create-table
138
130
PRIMARY_RESULT=$?
139
131
echo " PRIMARY_RESULT=$PRIMARY_RESULT "
140
132
141
133
if [ $PRIMARY_RESULT -eq 0 ]; then
142
134
echo " Primary Manager init"
143
135
# we are the primary, so init the cluster
144
136
docker swarm init --listen-addr $PRIVATE_IP :2377 --advertise-addr $PRIVATE_IP :2377
145
- # we can now get the tokens.
146
- get_tokens_local
137
+ # we can now get the swarm id and node id.
147
138
get_swarm_id
148
139
get_node_id
149
140
150
- # update azure table with the tokens
151
- python azuretokens .py insert-ip $PRIVATE_IP
141
+ # update azure table with the ip
142
+ python azureleader .py insert-ip $PRIVATE_IP
152
143
153
144
echo " Primary Manager init complete"
154
145
# send identify message
@@ -193,7 +184,7 @@ setup_worker()
193
184
n=$[$n +1]
194
185
195
186
# query azure table again, incase the manager changed
196
- get_tokens_db
187
+ get_tokens
197
188
else
198
189
echo " Connected to manager, NODE_ID=$NODE_ID , SWARM_ID=$SWARM_ID "
199
190
break
@@ -203,7 +194,7 @@ setup_worker()
203
194
}
204
195
205
196
# init variables based on azure token table contents (if populated)
206
- get_tokens_db
197
+ get_tokens
207
198
208
199
# if it is a manager, setup as manager, if not, setup as worker node.
209
200
if [ " $ROLE " == " MANAGER" ] ; then
0 commit comments