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