modfified to change the model default after bootstrap.
[joid.git] / ci / 02-deploybundle.sh
1 #!/bin/bash
2 #placeholder for deployment script.
3 set -ex
4
5 #    ./02-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro
6
7 opnfvtype=$1
8 openstack=$2
9 opnfvlab=$3
10 opnfvsdn=$4
11 opnfvfeature=$5
12 opnfvdistro=$6
13
14 #copy and download charms
15 cp $opnfvsdn/fetch-charms.sh ./fetch-charms.sh
16
17 jujuver=`juju --version`
18
19 #modify the ubuntu series wants to deploy
20 sed -i -- "s|distro=trusty|distro=$opnfvdistro|g" ./fetch-charms.sh
21
22 ./fetch-charms.sh $opnfvdistro
23
24 tar xvf common/scaleio.tar -C ./$opnfvdistro/ --strip=2 juju-scaleio/trusty/
25
26 osdomname=''
27
28 #check whether charms are still executing the code even juju-deployer says installed.
29 check_status() {
30     retval=0
31     timeoutiter=0
32     while [ $retval -eq 0 ]; do
33        sleep 30
34        juju status > status.txt
35        if [ "$(grep -c "waiting" status.txt )" -ge 4 ]; then
36            echo " still waiting for machines ..."
37            if [ $timeoutiter -ge 240 ]; then
38                retval=1
39            fi
40            timeoutiter=$((timeoutiter+1))
41        else
42            retval=1
43        fi
44     done
45     echo "...... deployment finishing ......."
46 }
47
48 #read the value from deployment.yaml
49
50 if [ -e ./deployment.yaml ]; then
51    if [ -e ./deployconfig.yaml ]; then
52       extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
53       datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
54       admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
55       cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
56       osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
57    fi
58
59     workmutiple=`maas maas nodes list | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
60     max=0
61     for v in ${workmutiple[@]}; do
62         if (( $v > $max )); then max=$v; fi;
63     done
64     echo $max
65
66     if [ "$max" -lt 4 ];then
67         workmutiple=1.0
68     elif [ "$max" -lt 33 ]; then
69         workmutiple=0.25
70     elif [ "$max" -lt 73 ]; then
71         workmutiple=0.1
72     else
73         workmutiple=0.05
74     fi
75     sed -i "s/worker_multiplier: 1.0/worker_multiplier: ${workmutiple}/g" default_deployment_config.yaml
76 fi
77
78 case "$opnfvlab" in
79      'juniperpod1' )
80          sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml
81          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
82          ;;
83      'ravellodemopod' )
84          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml
85         ;;
86 esac
87
88 # lets put the if seperateor as "," as this will save me from world.
89 fea=""
90 IFS=","
91 for feature in $opnfvfeature; do
92     if [ "$fea" == "" ]; then
93         fea=$feature
94     else
95         fea=$fea"_"$feature
96     fi
97 done
98
99 #update source if trusty is target distribution
100 var=os-$opnfvsdn-$fea-$opnfvtype"-"$opnfvdistro"_"$openstack
101
102 if [ "$osdomname" != "None" ]; then
103     var=$var"_"publicapi
104 fi
105
106 #lets generate the bundle for all target using genBundle.py
107 python genBundle.py  -l deployconfig.yaml  -s $var > bundles.yaml
108 #keep the back in cloud for later debugging.
109 pastebinit bundles.yaml || true
110
111 if [[ "$jujuver" < "2" ]]; then
112     echo "... Deployment Started ...."
113     juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack"-nodes
114     count=`juju status nodes --format=short | grep nodes | wc -l`
115     c=0
116     while [ $c -lt $count ]; do
117         juju ssh nodes/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
118         juju ssh nodes-compute/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
119         juju ssh nodes/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
120         juju ssh nodes-compute/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
121         let c+=1
122     done
123
124     juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack" || true
125 else
126     # with JUJU 2.0 bundles has to be deployed only once.
127     juju deploy bundles.yaml --debug
128     sleep 120
129     check_status
130     # seeing issue related to number of open files.
131     count=`juju status nodes --format=short | grep nodes | wc -l`
132     c=0
133     while [ $c -lt $count ]; do
134         juju ssh nodes/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
135         juju ssh nodes-compute/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
136         juju ssh nodes/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
137         juju ssh nodes-compute/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
138         let c+=1
139     done
140 fi
141
142 #lets gather the status of deployment once juju-deployer completed.
143 juju status --format=tabular