78f3cf508c397cd38d8035c3329fd983e6d8b939
[joid.git] / ci / 01-deploybundle.sh
1 #!/bin/bash
2 #placeholder for deployment script.
3 set -ex
4
5 #    ./01-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro
6
7     #copy and download charms
8     cp $4/fetch-charms.sh ./fetch-charms.sh
9     #modify the ubuntu series wants to deploy
10     sed -i -- "s|distro=trusty|distro=$6|g" ./fetch-charms.sh
11     ./fetch-charms.sh $6
12
13 osdomname=''
14
15 case "$1" in
16     'nonha' )
17         cp $4/juju-deployer/ovs-$4-nonha.yaml ./bundles.yaml
18         ;;
19     'ha' )
20         cp $4/juju-deployer/ovs-$4-ha.yaml ./bundles.yaml
21         ;;
22     'tip' )
23         cp $4/juju-deployer/ovs-$4-tip.yaml ./bundles.yaml
24         cp common/source/* ./
25         sed -i -- "s|branch: master|branch: stable/$2|g" ./*.yaml
26         ;;
27     * )
28         cp $4/juju-deployer/ovs-$4-nonha.yaml ./bundles.yaml
29         ;;
30 esac
31
32 #check whether charms are still executing the code even juju-deployer says installed.
33 check_status() {
34     retval=0
35     timeoutiter=0
36     while [ $retval -eq 0 ]; do
37        sleep 30
38        juju status > status.txt
39        if [ "$(grep -c "executing" status.txt )" -ge 2 ]; then
40            echo " still executing the reltionship within charms ..."
41            if [ $timeoutiter -ge 60 ]; then
42                retval=1
43            fi
44            timeoutiter=$((timeoutiter+1))
45        else
46            retval=1
47        fi
48     done
49     status=`juju action do heat/0 domain-setup`
50     echo $status
51     echo "...... deployment finishing ......."
52 }
53
54 #read the value from deployment.yaml
55 if [ -e ~/.juju/deployment.yaml ]; then
56    cp ~/.juju/deployment.yaml ./deployment.yaml
57    if [ -e ~/.juju/deployconfig.yaml ]; then
58       cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
59       extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
60       sed --i "s@#ext-port: \"eth1\"@ext-port: \"$extport\"@g" ./bundles.yaml
61       datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
62       if [ "$datanet" != "''" ]; then
63           sed -i -- "s@#os-data-network: 10.4.8.0/21@os-data-network: $datanet@g" ./bundles.yaml
64       fi
65       admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
66       sed --i "s@10.4.1.1@$admnet@g" ./bundles.yaml
67       cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
68       sed --i "s@osd-devices: /srv@osd-devices: $cephdisk@g" ./bundles.yaml
69       osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
70       if [ "$osdomname" != "''" ]; then
71           sed --i "s@#use-internal-endpoints: true@use-internal-endpoints: true@g" ./bundles.yaml
72           sed --i "s@#endpoint-type: internalURL@endpoint-type: internalURL@g" ./bundles.yaml
73           sed --i "s@#os-public-hostname: pod.maas@os-public-hostname: api.$osdomname@g" ./bundles.yaml
74           sed --i "s@#console-proxy-ip: pod.maas@console-proxy-ip: $osdomname@g" ./bundles.yaml
75       fi
76    fi
77 fi
78
79 case "$3" in
80      'juniperpod1' )
81          sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml
82          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
83          ;;
84      'ravellodemopod' )
85          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml
86         ;;
87      'default' )
88          sed -i -- 's/10.4.1.1/192.168.122.1/g' ./bundles.yaml
89          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
90         ;;
91 esac
92
93 # lets put the if seperateor as "," as this will save me from world.
94 fea=""
95 IFS=","
96 for feature in $5; do
97     if [ "$fea" == "" ]; then
98         fea=$feature
99     else
100         fea=$fea"_"$feature
101     fi
102     case "$feature" in
103         'ipv6' )
104              sed -i -- 's/#prefer-ipv6: true/prefer-ipv6: true/g' ./bundles.yaml
105             ;;
106         'dvr' )
107              sed -i -- 's/#enable-dvr: true/enable-dvr: true/g' ./bundles.yaml
108              sed -i -- 's/#l2-population: true/l2-population: true/g' ./bundles.yaml
109             ;;
110         'sfc' )
111              sed -i -- 's/profile: "openvswitch-odl-Be"/profile: "openvswitch-odl-beryllium-sfc"/g' ./bundles.yaml
112             ;;
113         'vpn' )
114              sed -i -- 's/profile: "openvswitch-odl-Be"/profile: "openvswitch-odl-beryllium-vpn"/g' ./bundles.yaml
115             ;;
116         'odl_l3' )
117              sed -i -- 's/profile: "openvswitch-odl-Be"/profile: "openvswitch-odl-beryllium-l3"/g' ./bundles.yaml
118             ;;
119         'dpdk' )
120              sed -i -- 's/#enable-dpdk: true/enable-dpdk: true/g' ./bundles.yaml
121              sed -i -- 's/#hugepages: "50%"/hugepages: "50%"/g' ./bundles.yaml
122             ;;
123         'lxd' )
124              sed -i -- 's/#- - nova-compute:lxd/- - nova-compute:lxd/g' ./bundles.yaml
125              sed -i -- 's/#- lxd:lxd/- lxd:lxd/g' ./bundles.yaml
126              sed -i -- 's/#virt-type: lxd/virt-type: lxd/g' ./bundles.yaml
127              # adding the lxd subordinate charm
128              echo "    lxd:" >> ./bundles.yaml
129              echo "      charm: local:xenial/lxd" >> ./bundles.yaml
130             ;;
131     esac
132 done
133
134 #changing the target to the openstack release we want to deploy.
135 sed -i -- "s|mitaka|$2|g" ./bundles.yaml
136
137 #update source if trusty is target distribution
138 case "$6" in
139     'trusty' )
140         sed -i -- "s|#source|source|g" ./bundles.yaml
141         sed -i -- "s|#source-branch:|source-branch:|g" ./bundles.yaml
142         ;;
143     'xenial' )
144         #changing the target to the ubuntu distro we want to deploy.
145         sed -i -- "s|trusty|$6|g" ./bundles.yaml
146         ;;
147 esac
148
149 if [ "$osdomname" != "''" ]; then
150     var=os-$4-$fea-$1-publicapi
151 else
152     var=os-$4-$fea-$1
153 fi
154
155 if [ "$4" != "nosdn" ]; then
156     python genBundle.py  -l deployconfig.yaml  -s $var > bundles.yaml
157 elif [ "$4" == "odl" ]; then
158     python genBundle.py  -l deployconfig.yaml  -s $var > bundles.yaml
159 elif [ "$4" == "onos" ]; then
160     python genBundle.py  -l deployconfig.yaml  -s $var > bundles.yaml
161 fi
162
163 echo "... Deployment Started ...."
164     juju-deployer -vW -d -t 3600 -c bundles.yaml $6-"$2"-nodes
165     check_status
166
167     juju ssh nodes/0 "echo 512 | sudo tee /proc/sys/fs/inotify/max_user_instances"
168
169     juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $6-"$2"