-echo "Waiting for controller to come up..."
-COUNT="0"
-while true; do
- RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
- echo \$RESP
- if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
- SHARD="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/jolokia/read/org.opendaylight.controller:Category=Shards,name=\member-\$1-shard-inventory-config,type=DistributedConfigDatastore)"
- echo \$SHARD
+if [ "${DISTROSTREAM}" == "carbon" ] || [ "${DISTROSTREAM}" == "nitrogen" ];
+then
+ echo "only oxygen and above have the infrautils.ready feature, so using REST API to /modules or /shards to determine if the controller is ready.";
+
+ COUNT="0"
+
+ while true; do
+ RESP="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/restconf/modules -o /dev/null )"
+ echo \$RESP
+
+ if [ "${ENABLE_HAPROXY_FOR_NEUTRON}" == "yes" ]; then
+ SHARD="\$( curl --user admin:admin -sL -w "%{http_code} %{url_effective}\\n" http://localhost:8181/jolokia/read/org.opendaylight.controller:Category=Shards,name=\member-\$1-shard-inventory-config,type=DistributedConfigDatastore)"
+ echo \$SHARD
+ fi
+
+ if ([[ \$RESP == *"200"* ]] && ([[ "${ENABLE_HAPROXY_FOR_NEUTRON}" != "yes" ]] || [[ \$SHARD == *'"status":200'* ]])); then
+ echo "Controller is UP"
+ break
+
+ elif (( "\$COUNT" > "600" )); then
+ echo Timeout Controller DOWN
+ echo "Dumping first 500K bytes of karaf log..."
+ head --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
+ echo "Dumping last 500K bytes of karaf log..."
+ tail --bytes=500K "/tmp/${BUNDLEFOLDER}/data/log/karaf.log"
+ echo "Listing all open ports on controller system"
+ netstat -pnatu
+ exit 1
+ else
+
+ COUNT=\$(( \${COUNT} + 1 ))
+ sleep 1
+
+ if [[ \$((\$COUNT % 5)) == 0 ]]; then
+ echo already waited \${COUNT} seconds...
+ fi