6c8e9b80fc81cc6396993083ae04941cd757c375
[joid.git] / ci / 01-deploybundle.sh
1 #!/bin/bash
2 #placeholder for deployment script.
3 set -ex
4
5 #    ./01-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro
6
7     #copy and download charms
8     cp $4/fetch-charms.sh ./fetch-charms.sh
9     #modify the ubuntu series wants to deploy
10     sed -i -- "s|distro=trusty|distro=$6|g" ./fetch-charms.sh
11     ./fetch-charms.sh $6
12
13 osdomname=''
14
15 #check whether charms are still executing the code even juju-deployer says installed.
16 check_status() {
17     retval=0
18     timeoutiter=0
19     while [ $retval -eq 0 ]; do
20        sleep 30
21        juju status > status.txt
22        if [ "$(grep -c "executing" status.txt )" -ge 2 ]; then
23            echo " still executing the reltionship within charms ..."
24            if [ $timeoutiter -ge 60 ]; then
25                retval=1
26            fi
27            timeoutiter=$((timeoutiter+1))
28        else
29            retval=1
30        fi
31     done
32     echo "...... deployment finishing ......."
33 }
34
35 #read the value from deployment.yaml
36 if [ -e ~/.juju/deployment.yaml ]; then
37    cp ~/.juju/deployment.yaml ./deployment.yaml
38    if [ -e ~/.juju/deployconfig.yaml ]; then
39       cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
40       extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
41       datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
42       admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
43       cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
44       osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
45    fi
46 fi
47
48 case "$3" in
49      'juniperpod1' )
50          sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml
51          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
52          ;;
53      'ravellodemopod' )
54          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml
55         ;;
56 esac
57
58 # lets put the if seperateor as "," as this will save me from world.
59 fea=""
60 IFS=","
61 for feature in $5; do
62     if [ "$fea" == "" ]; then
63         fea=$feature
64     else
65         fea=$fea"_"$feature
66     fi
67 done
68
69 #update source if trusty is target distribution
70 var=os-$4-$fea-$1"-"$6"_"$2
71
72 if [ "$osdomname" != "''" ]; then
73     var=$var"_"publicapi
74 fi
75
76 #lets generate the bundle for all target using genBundle.py
77 python genBundle.py  -l deployconfig.yaml  -s $var > bundles.yaml
78
79 echo "... Deployment Started ...."
80 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $6-"$2"-nodes
81 juju ssh nodes/0 "echo 512 | sudo tee /proc/sys/fs/inotify/max_user_instances"
82 juju ssh nodes/1 "echo 512 | sudo tee /proc/sys/fs/inotify/max_user_instances"
83 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $6-"$2"