Change the deployment mode from 'nonha' to 'noha'
[joid.git] / ci / deploy.sh
index b0df68b..8491ad4 100755 (executable)
@@ -6,7 +6,7 @@ set -ex
 # Below parameters are the default and we can according the release
 
 opnfvsdn=nosdn
-opnfvtype=nonha
+opnfvtype=noha
 openstack=ocata
 opnfvlab=default
 opnfvrel=e
@@ -26,7 +26,7 @@ read_config() {
 }
 
 usage() { echo "Usage: $0 [-s <nosdn|odl|opencontrail>]
-                         [-t <nonha|ha|tip>]
+                         [-t <noha|ha|tip>]
                          [-o <juno|liberty>]
                          [-l <default|intelpod5>]
                          [-f <ipv6,dpdk,lxd,dvr>]
@@ -175,17 +175,19 @@ deploy() {
 
 #check whether charms are still executing the code even juju-deployer says installed.
 check_status() {
+    waitstatus=$1
     retval=0
     timeoutiter=0
 
     echo -n "executing the reltionship within charms ."
     while [ $retval -eq 0 ]; do
-       sleep 30
-       if juju status | grep -q "executing"; then
+        if juju status | grep -q $waitstatus; then
            echo -n '.'
            if [ $timeoutiter -ge 120 ]; then
                echo 'timed out'
                retval=1
+           else
+               sleep 30
            fi
            timeoutiter=$((timeoutiter+1))
        else
@@ -198,13 +200,14 @@ check_status() {
         juju expose ceph-radosgw || true
         #juju ssh ceph/0 \ 'sudo radosgw-admin user create --uid="ubuntu" --display-name="Ubuntu Ceph"'
     fi
+
     echo "...... deployment finishing ......."
-}
+ }
 
 echo "...... deployment started ......"
 deploy
 
-check_status
+check_status executing
 
 echo "...... deployment finished  ......."
 
@@ -220,25 +223,29 @@ cnt_list=$(for cnt in $srv_list; do juju status $cnt --format=json | jq -r ".mac
 # get public network gateway (supposing it is the first ip of the network)
 public_api_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"public\")".gateway)
 admin_gw=$(cat labconfig.json | jq --raw-output ".opnfv.spaces[] | select(.type==\"admin\")".gateway)
-# set default gateway to public api gateway
-for cnt in $cnt_list; do
-    echo "changing default gw on $cnt"
-    juju ssh $cnt "sudo ip r d default && sudo ip r a default via $public_api_gw";
-    juju ssh $cnt "gw_dev=\$(ip  r l | grep 'via $public_api_gw' | cut -d \  -f5) &&\
+
+if ([ $admin_gw ] && [ $admin_gw != "null" ]); then
+    # set default gateway to public api gateway
+    for cnt in $cnt_list; do
+        echo "changing default gw on $cnt"
+        if ([ $public_api_gw ] && [ $public_api_gw != "null" ]); then
+            juju ssh $cnt "sudo ip r d default && sudo ip r a default via $public_api_gw";
+            juju ssh $cnt "gw_dev=\$(ip  r l | grep 'via $public_api_gw' | cut -d \  -f5) &&\
                    sudo cp /etc/network/interfaces /etc/network/interfaces.bak &&\
                    echo 'removing old default gateway' &&\
                    sudo perl -i -pe 's/^\ *gateway $admin_gw\n$//' /etc/network/interfaces &&\
                    sudo perl -i -pe \"s/iface \$gw_dev inet static/iface \$gw_dev inet static\\n  gateway $public_api_gw/\" /etc/network/interfaces \
                    ";
-done
+        fi
+    done
+fi
 
 echo "...... configure  ......."
 
-if [[ "$opnfvmodel" = "openstack" ]]; then
+if ([ $opnfvmodel == "openstack" ]); then
     ./openstack.sh "$opnfvsdn" "$opnfvlab" "$opnfvdistro" "$openstack" || true
 
     # creating heat domain after puching the public API into /etc/hosts
-
     if [[ "$jujuver" > "2" ]]; then
         status=`juju run-action heat/0 domain-setup`
         echo $status
@@ -247,12 +254,14 @@ if [[ "$opnfvmodel" = "openstack" ]]; then
         echo $status
     fi
 
-
     sudo ../juju/get-cloud-images || true
     ../juju/joid-configure-openstack || true
 
-fi
-if [[ "$opnfvmodel" = "kubernetes" ]]; then
+    if grep -q 'openbaton' bundles.yaml; then
+        juju add-relation openbaton keystone
+    fi
+
+elif ([ $opnfvmodel == "kubernetes" ]); then
     ./k8.sh
 fi