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