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