modified to autostart the VMs created for bootstrap and virtual
[joid.git] / ci / deploy.sh
index 8a08f57..b722d2a 100755 (executable)
@@ -2,7 +2,7 @@
 
 set -ex
 
-source tools.sh
+source common/tools.sh
 
 #need to put multiple cases here where decide this bundle to deploy by default use the odl bundle.
 # Below parameters are the default and we can according the release
@@ -136,6 +136,17 @@ createresource() {
     API_KEY=`sudo maas-region apikey --username=ubuntu`
     maas login $PROFILE $API_SERVER $API_KEY
 
+   # if we have a virshurl configuration we use it, else we use local
+    VIRSHURL=$(cat labconfig.json | jq -r '.opnfv.virshurl')
+    if ([ $VIRSHURL == "" ] || [ "$VIRSHURL" == "null" ]); then
+        VIRSHIP=$MAAS_IP
+        VIRSHURL="qemu+ssh://$USER@$VIRSHIP/system "
+        VIRSHHOST=""
+    else
+        VIRSHHOST=$(echo $VIRSHURL| cut -d\/ -f 3 | cut -d@ -f2)
+        VIRSHIP=""  # TODO: parse from $VIRSHURL if needed
+    fi
+
     for node in node3-control node4-control
     do
         node_id=$(maas $PROFILE machines read | \
@@ -149,7 +160,7 @@ createresource() {
                 --boot network,hd,menu=off \
                 --noautoconsole --vnc --print-xml | tee _node.xml
             node_mac=$(grep "mac address" _node.xml | head -1 | cut -d "'" -f 2)
-            sudo virsh -c qemu:///system define --file _node.xml
+            sudo virsh -c $VIRSHURL define --file _node.xml
             rm -f _node.xml
 
             maas $PROFILE nodes new autodetect_nodegroup='yes' name=$node \
@@ -157,6 +168,7 @@ createresource() {
                 mac_addresses=$node3controlmac \
                 power_parameters_power_address="qemu+ssh://$USER@192.168.122.1/system" \
                 architecture='amd64/generic' power_parameters_power_id='node3-control'
+            sudo virsh -c $VIRSHURL autostart $node
             node_id=$(maas $PROFILE machines read | \
                   jq -r ".[] | select(.hostname == \"$node\").system_id")
         fi
@@ -298,38 +310,11 @@ deploy
 check_status executing
 
 echo_info "Deployment finished"
-
-echo_info "Configuring public access"
+juju status --format=tabular
 
 # translate bundle.yaml to json
 python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)' < bundles.yaml > bundles.json
 
-public_service() {
-    # get services list having a public interface
-    srv_list=$(cat bundles.json | jq -r ".services | to_entries[] | {\"key\": .key, \"value\": .value[\"bindings\"]} | select (.value!=null) | select(.value[] | contains(\"public-api\"))".key)
-    # get cnt list from service list
-    cnt_list=$(for cnt in $srv_list; do juju status $cnt --format=json | jq -r ".machines[].containers | to_entries[]".key; done)
-    # 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)
-
-    if ([ $admin_gw ] && [ $admin_gw != "null" ]); then
-        # set default gateway to public api gateway
-        for cnt in $cnt_list; do
-            echo_info "Changing default gateway 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 \
-                   ";
-            fi
-        done
-    fi
-}
-
 # Configuring deployment
 if ([ $opnfvmodel == "openstack" ]); then
     echo_info "Configuring OpenStack deployment"
@@ -353,6 +338,9 @@ if ([ $opnfvmodel == "openstack" ]); then
     fi
 
 elif ([ $opnfvmodel == "kubernetes" ]); then
+   #Workarounf for master chanrm as it takes 5 minutes to run properly
+    check_status waiting
+    check_status executing
     echo_info "Configuring Kubernetes deployment"
 
     ./k8.sh