modfied to fix it for onos.
[joid.git] / ci / 02-maasdeploy.sh
index 4d3fdb0..62e57da 100755 (executable)
@@ -9,10 +9,10 @@ labname=$1
 sudo apt-add-repository ppa:maas-deployers/stable -y
 sudo apt-add-repository ppa:juju/stable -y
 sudo apt-add-repository ppa:maas/stable -y
-sudo apt-add-repository cloud-archive:liberty -y
+sudo apt-add-repository cloud-archive:mitaka -y
 sudo apt-get update -y
 sudo apt-get dist-upgrade -y
-sudo apt-get install openssh-server git maas-deployer juju juju-deployer maas-cli python-pip python-openstackclient gsutil -y
+sudo apt-get install openssh-server git maas-deployer juju juju-deployer maas-cli python-pip python-openstackclient python-congressclient gsutil -y
 
 #first parameter should be custom and second should be either 
 # absolute location of file (including file name) or url of the 
@@ -67,7 +67,9 @@ else
             python deploy.py
             ;;
         'attvirpod1' )
-            cp maas/att/virpod1/deployment.yaml ./deployment.yaml
+            cp ../labconfig/att/virpod1/labconfig.yaml ./
+            #to be removed later once converted for all labs.
+            python deploy.py
             ;;
         'juniperpod1' )
             cp maas/juniper/pod1/deployment.yaml ./deployment.yaml
@@ -75,11 +77,17 @@ else
         'cengnlynxpod1' )
             cp maas/cengn_lynx/pod1/deployment.yaml ./deployment.yaml
             ;;
+        'cengnpod1' )
+            cp ../labconfig/cengn/pod1/labconfig.yaml ./
+            #to be removed later once converted for all labs.
+            python deploy.py
+            ;;
         * )
             virtinstall=1
             labname="default"
             ./cleanvm.sh
             cp ../labconfig/default/deployment.yaml ./
+            cp ../labconfig/default/deployconfig.yaml ./
             ;;
     esac
 fi
@@ -183,7 +191,10 @@ sed --i "s@/home/ubuntu@$HOME@g" ./deployment.yaml
 sed --i "s@qemu+ssh://ubuntu@qemu+ssh://$USER@g" ./deployment.yaml
 
 cp ./deployment.yaml ~/.juju/
-cp ./deployconfig.yaml ~/.juju/
+
+if [ -e ./deployconfig.yaml ]; then
+    cp ./deployconfig.yaml ~/.juju/
+fi
 
 sudo maas-deployer -c deployment.yaml -d --force
 
@@ -232,16 +243,50 @@ if [ "$virtinstall" -eq 1 ]; then
     maas maas tag update-nodes compute add=$computenodeid
 fi
 
+#read interface needed in Auto mode and enable it. Will be rmeoved once auto enablement will be implemented in the maas-deployer.
+enable_if(){
+   if [ -e ~/.juju/deployconfig.yaml ]; then
+      cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
+
+      enableiflist=`grep "interface-enable" deployconfig.yaml | cut -d ' ' -f 4 `
+      datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
+      stornet=`grep "storageNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
+      pubnet=`grep "publicNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
+
+      # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
+
+      if [ "$datanet" != "''" ]; then
+          EXTNET=(${enableiflist//,/ })
+          i="0"
+          while [ ! -z "${EXTNET[i]}" ];
+          do
+              enableautomode ${EXTNET[i]} AUTO $datanet || true
+              i=$[$i+1]
+          done
+      fi
+      if [ "$stornet" != "''" ]; then
+          EXTNET=(${enableiflist//,/ })
+          i="0"
+          while [ ! -z "${EXTNET[i]}" ];
+          do
+              enableautomode ${EXTNET[i]} AUTO $stornet || true
+              i=$[$i+1]
+          done
+      fi
+      if [ "$pubnet" != "''" ]; then
+          EXTNET=(${enableiflist//,/ })
+          i="0"
+          while [ ! -z "${EXTNET[i]}" ];
+          do
+              enableautomode ${EXTNET[i]} AUTO $pubnet || true
+              i=$[$i+1]
+          done
+      fi
+   fi
+}
+
 # Enable vlan interfaces with maas
 case "$labname" in
-    'intelpod5' )
-        maas refresh
-        enableautomode eth4 AUTO "10.5.12.0/24" || true
-        ;;
-    'intelpod6' )
-        maas refresh
-        enableautomode eth4 AUTO "10.6.12.0/24" || true
-        ;;
     'intelpod9' )
         maas refresh
         crvlanupdsubnet vlan902 1 "DataNetwork" 902 2 || true
@@ -253,21 +298,6 @@ case "$labname" in
         enableautomodebyname eth0.902 AUTO "10.9.12.0/24" control || true
         enableautomodebyname eth1.905 AUTO "10.9.15.0/24" control || true
         ;;
-    'orangepod1' )
-        maas refresh
-        enableautomode eth2 DHCP "192.168.21.0/24" || true
-        enableautomode eth3 AUTO "192.168.11.0/24" || true
-        ;;
-    'orangepod2' )
-        maas refresh
-        enableautomode eth4 DHCP "192.168.22.0/24" || true
-        enableautomode eth2 DHCP "192.168.22.0/24" || true
-        enableautomode eth5 AUTO "192.168.12.0/24" || true
-        enableautomode eth3 AUTO "192.168.12.0/24" || true
-        ;;
-    'attvirpod1' )
-        enableautomodebyname eth1 AUTO "192.168.10.0/24" control || true
-        ;;
     'juniperpod1' )
         ;;
     'cengnlynxpod1' )
@@ -281,7 +311,6 @@ case "$labname" in
         ;;
 esac
 
-echo " .... MAAS deployment finished successfully ...."
+enable_if
 
-#echo "... Deployment of opnfv release Started ...."
-#python deploy.py $maas_ip
+echo " .... MAAS deployment finished successfully ...."