Merge "add server_option in haproxy configuration"
[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 #modify the ubuntu series wants to deploy
18 sed -i -- "s|distro=trusty|distro=$opnfvdistro|g" ./fetch-charms.sh
19
20 ./fetch-charms.sh $opnfvdistro
21
22 osdomname=''
23
24 #check whether charms are still executing the code even juju-deployer says installed.
25 check_status() {
26     retval=0
27     timeoutiter=0
28     while [ $retval -eq 0 ]; do
29        sleep 30
30        juju status > status.txt
31        if [ "$(grep -c "executing" status.txt )" -ge 2 ]; then
32            echo " still executing the reltionship within charms ..."
33            if [ $timeoutiter -ge 60 ]; then
34                retval=1
35            fi
36            timeoutiter=$((timeoutiter+1))
37        else
38            retval=1
39        fi
40     done
41     echo "...... deployment finishing ......."
42 }
43
44 #read the value from deployment.yaml
45
46 if [ -e ./deployment.yaml ]; then
47    if [ -e ./deployconfig.yaml ]; then
48       extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
49       datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
50       admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
51       cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
52       osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
53    fi
54
55     workmutiple=`maas maas nodes list | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
56     max=0
57     for v in ${workmutiple[@]}; do
58         if (( $v > $max )); then max=$v; fi;
59     done
60     echo $max
61
62     if [ "$max" -lt 4 ];then
63         workmutiple=1.0
64     elif [ "$max" -lt 33 ]; then
65         workmutiple=0.25
66     elif [ "$max" -lt 73 ]; then
67         workmutiple=0.1
68     else
69         workmutiple=0.05
70     fi
71     sed -i "s/worker_multiplier: 1.0/worker_multiplier: ${workmutiple}/g" default_deployment_config.yaml
72 fi
73
74 case "$opnfvlab" in
75      'juniperpod1' )
76          sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml
77          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
78          ;;
79      'ravellodemopod' )
80          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml
81         ;;
82 esac
83
84 # lets put the if seperateor as "," as this will save me from world.
85 fea=""
86 IFS=","
87 for feature in $opnfvfeature; do
88     if [ "$fea" == "" ]; then
89         fea=$feature
90     else
91         fea=$fea"_"$feature
92     fi
93 done
94
95 #update source if trusty is target distribution
96 var=os-$opnfvsdn-$fea-$opnfvtype"-"$opnfvdistro"_"$openstack
97
98 if [ "$osdomname" != "None" ]; then
99     var=$var"_"publicapi
100 fi
101
102 #lets generate the bundle for all target using genBundle.py
103 python genBundle.py  -l deployconfig.yaml  -s $var > bundles.yaml
104
105 echo "... Deployment Started ...."
106 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack"-nodes
107
108 # seeing issue related to number of open files.
109 # juju run --service nodes 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances'
110
111 count=`juju status nodes --format=short | grep nodes | wc -l`
112
113 c=0
114 while [ $c -lt $count ]; do
115     juju ssh nodes/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
116     juju ssh nodes-compute/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
117     juju ssh nodes/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
118     juju ssh nodes-compute/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
119     let c+=1
120 done
121
122 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack" || true