to adjust the worker mutiplier for api service so that not too many
[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 if [ -e ~/.juju/deployment.yaml ]; then
46    cp ~/.juju/deployment.yaml ./deployment.yaml
47    if [ -e ~/.juju/deployconfig.yaml ]; then
48       cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
49       extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
50       datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
51       admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
52       cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
53       osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
54    fi
55
56     workmutiple=`maas maas nodes list | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
57     max=0
58     for v in ${workmutiple[@]}; do
59         if (( $v > $max )); then max=$v; fi;
60     done
61     echo $max
62
63     if [ "$max" -lt 8 ];then
64         workmutiple=1
65     elif [ "$max" -lt 32 ]; then
66         workmutiple=0.25
67     elif [ "$max" -lt 72 ]; then
68         workmutiple=0.1
69     else
70         workmutiple=0.05
71     fi
72     sed -i "s/worker-multiplier: 2/worker-multiplier: ${workmutiple}/g" default_deployment_config.yaml
73 fi
74
75 case "$opnfvlab" in
76      'juniperpod1' )
77          sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml
78          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
79          ;;
80      'ravellodemopod' )
81          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml
82         ;;
83 esac
84
85 # lets put the if seperateor as "," as this will save me from world.
86 fea=""
87 IFS=","
88 for feature in $opnfvfeature; do
89     if [ "$fea" == "" ]; then
90         fea=$feature
91     else
92         fea=$fea"_"$feature
93     fi
94 done
95
96 #update source if trusty is target distribution
97 var=os-$opnfvsdn-$fea-$opnfvtype"-"$opnfvdistro"_"$openstack
98
99 if [ "$osdomname" != "None" ]; then
100     var=$var"_"publicapi
101 fi
102
103 #lets generate the bundle for all target using genBundle.py
104 python genBundle.py  -l deployconfig.yaml  -s $var > bundles.yaml
105
106 echo "... Deployment Started ...."
107 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack"-nodes
108
109 # seeing issue related to number of open files.
110 # juju run --service nodes 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances'
111
112 count=`juju status nodes --format=short | grep nodes | wc -l`
113
114 c=0
115 while [ $c -lt $count ]; do
116     juju ssh nodes/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances'
117     let c+=1
118 done
119
120 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack" || true