@@ -114,6 +114,7 @@ Vagrant.configure("2") do |config|
114
114
gem install jsonlint --no-rdoc --no-ri
115
115
EOM
116
116
117
+ if ENV [ 'ENABLE_AUTH' ] == 'true'
117
118
#
118
119
# VM definition for lightwave
119
120
#
@@ -189,33 +190,33 @@ Vagrant.configure("2") do |config|
189
190
dynamic_params = %Q(
190
191
{)
191
192
192
- if ENV [ 'ENABLE_AUTH' ] == 'true'
193
- if ENV [ 'LW_DOMAIN_NAME' ]
194
- dynamic_params += %Q(\n "LIGHTWAVE_DOMAIN" : "#{ ENV [ 'LW_DOMAIN_NAME' ] } ")
195
- else
196
- abort ( "auth is enabled for devbox lightwave, but domain is not set" )
197
- end
198
193
199
- if ENV [ 'LW_PASSWORD ' ]
200
- dynamic_params += %Q(, \n "LIGHTWAVE_PASSWORD " : "#{ ENV [ 'LW_PASSWORD ' ] } ")
201
- else
202
- abort ( "auth is enabled for devbox lightwave, but password is not set" )
203
- end
194
+ if ENV [ 'LW_DOMAIN_NAME ' ]
195
+ dynamic_params += %Q(\n "LIGHTWAVE_DOMAIN " : "#{ ENV [ 'LW_DOMAIN_NAME ' ] } ")
196
+ else
197
+ abort ( "auth is enabled for devbox lightwave, but domain is not set" )
198
+ end
204
199
205
- if ENV [ "PUBLIC_NETWORK_IP" ]
206
- if ENV [ "PUBLIC_LW_NETWORK_IP" ]
207
- # The hostname is set to the IP since Photon Controller does not have DNS set
208
- # to Lightwave yet, but Photon Controller during auth enabled needs to
209
- # verify the hostname matches the Lightwave server certificate.
210
- dynamic_params += %Q(,\n "LIGHTWAVE_HOSTNAME" : "#{ ENV [ 'PUBLIC_LW_NETWORK_IP' ] } ")
211
- else
212
- abort ( "auth is enabled for devbox lightwave, but hostname is not set" )
213
- end
200
+ if ENV [ 'LW_PASSWORD' ]
201
+ dynamic_params += %Q(,\n "LIGHTWAVE_PASSWORD" : "#{ ENV [ 'LW_PASSWORD' ] } ")
202
+ else
203
+ abort ( "auth is enabled for devbox lightwave, but password is not set" )
204
+ end
205
+
206
+ if ENV [ "PUBLIC_NETWORK_IP" ]
207
+ if ENV [ "PUBLIC_LW_NETWORK_IP" ]
208
+ # The hostname is set to the IP since Photon Controller does not have DNS set
209
+ # to Lightwave yet, but Photon Controller during auth enabled needs to
210
+ # verify the hostname matches the Lightwave server certificate.
211
+ dynamic_params += %Q(,\n "LIGHTWAVE_HOSTNAME" : "#{ ENV [ 'PUBLIC_LW_NETWORK_IP' ] } ")
214
212
else
215
- private_network_lw_ip = ENV [ "PRIVATE_NETWORK_LW_IP" ] || "172.31.253.67"
216
- dynamic_params += %Q(,\n "LIGHTWAVE_HOSTNAME" : "#{ private_network_lw_ip } ")
213
+ abort ( "auth is enabled for devbox lightwave, but hostname is not set" )
217
214
end
215
+ else
216
+ private_network_lw_ip = ENV [ "PRIVATE_NETWORK_LW_IP" ] || "172.31.253.67"
217
+ dynamic_params += %Q(,\n "LIGHTWAVE_HOSTNAME" : "#{ private_network_lw_ip } ")
218
218
end
219
+
219
220
dynamic_params += "\n }"
220
221
221
222
# Write dynamic_params file
@@ -313,11 +314,12 @@ cat >> $out <<-'EOM'
313
314
echo "Checking to connect to Lightwave REST client to start"
314
315
attempts=1
315
316
reachable="false"
316
- while [ $attempts -lt 30 ] && [ $reachable != "true" ]; do
317
+ total_attempts=50
318
+ while [ $attempts -lt $total_attempts ] && [ $reachable != "true" ]; do
317
319
http_code=$(curl -w "%{http_code}" -s -X GET --insecure https://lightwave.#{ ENV [ 'LW_DOMAIN_NAME' ] } )
318
320
# The curl returns 000 when it fails to connect to the lightwave server
319
321
if [ $http_code -eq 000 ]; then
320
- echo "Lightwave REST server not reachable (attempt $attempts/30 ), will try again."
322
+ echo "Lightwave REST server not reachable (attempt $attempts/$total_attempts ), will try again."
321
323
attempts=$[$attempts+1]
322
324
sleep 5
323
325
else
@@ -329,15 +331,16 @@ cat >> $out <<-'EOM'
329
331
break
330
332
fi
331
333
done
332
- if [ $attempts -eq 30 ]; then
333
- echo "Could not connect to Lightwave REST client after 30 attempts, users not added and token expiration not updated."
334
+ if [ $attempts -eq $total_attempts ]; then
335
+ echo "Could not connect to Lightwave REST client after $total_attempts attempts, users not added and token expiration not updated."
336
+ exit 1
334
337
fi
335
338
EOM
336
339
chmod +x $out
337
340
$out
338
341
EOS
339
342
end
340
-
343
+ end
341
344
342
345
#
343
346
# VM definition for photon
0 commit comments