modfied to include the os qualified domain name for public API.
[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
31 #read the value from deployment.yaml
32 if [ -e ~/.juju/deployment.yaml ]; then
33    cp ~/.juju/deployment.yaml ./deployment.yaml
34    if [ -e ~/.juju/deployconfig.yaml ]; then
35       cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
36       extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
37       sed --i "s@#ext-port: \"eth1\"@ext-port: \"$extport\"@g" ./bundles.yaml
38       datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
39       if [ "$datanet" != "''" ]; then
40           sed -i -- "s@#os-data-network: 10.4.8.0/21@os-data-network: $datanet@g" ./bundles.yaml
41       fi
42       admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
43       sed --i "s@10.4.1.1@$admnet@g" ./bundles.yaml
44       cephdisk=`grep "disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
45       sed --i "s@osd-devices: /srv@osd-devices: $cephdisk@g" ./bundles.yaml
46       osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
47       if [ "$osdomname" != "''" ]; then
48           sed --i "s@#os-public-hostname: pod.maas@os-public-hostname: api.$osdomname@g" ./bundles.yaml
49           sed --i "s@#console-proxy-ip: pod.maas@console-proxy-ip: $osdomname@g" ./bundles.yaml
50       fi
51    fi
52 fi
53
54 case "$3" in
55      'juniperpod1' )
56          sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml
57          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
58          ;;
59      'ravellodemopod' )
60          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml
61         ;;
62      'default' )
63          sed -i -- 's/10.4.1.1/192.168.122.1/g' ./bundles.yaml
64          sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
65         ;;
66 esac
67
68 # lets put the if seperateor as "," as this will save me from world.
69 IFS=","
70
71 for feature in $5; do
72     case "$feature" in
73         'ipv6' )
74              sed -i -- 's/#prefer-ipv6: true/prefer-ipv6: true/g' ./bundles.yaml
75             ;;
76         'dvr' )
77              sed -i -- 's/#enable-dvr: true/enable-dvr: true/g' ./bundles.yaml
78              sed -i -- 's/#l2-population: true/l2-population: true/g' ./bundles.yaml
79             ;;
80         'sfc' )
81              sed -i -- 's/profile: "openvswitch-odl-Be"/profile: "openvswitch-odl-beryllium-sfc"/g' ./bundles.yaml
82             ;;
83         'vpn' )
84              sed -i -- 's/profile: "openvswitch-odl-Be"/profile: "openvswitch-odl-beryllium-vpn"/g' ./bundles.yaml
85             ;;
86         'odl_l3' )
87              sed -i -- 's/profile: "openvswitch-odl-Be"/profile: "openvswitch-odl-beryllium-l3"/g' ./bundles.yaml
88             ;;
89         'dpdk' )
90              sed -i -- 's/#enable-dpdk: true/enable-dpdk: true/g' ./bundles.yaml
91              sed -i -- 's/#hugepages: "50%"/hugepages: "50%"/g' ./bundles.yaml
92             ;;
93         'lxd' )
94              sed -i -- 's/#- - nova-compute:lxd/- - nova-compute:lxd/g' ./bundles.yaml
95              sed -i -- 's/#- lxd:lxd/- lxd:lxd/g' ./bundles.yaml
96              sed -i -- 's/#virt-type: lxd/virt-type: lxd/g' ./bundles.yaml
97              # adding the lxd subordinate charm
98              echo "    lxd:" >> ./bundles.yaml
99              echo "      charm: local:xenial/lxd" >> ./bundles.yaml
100             ;;
101     esac
102 done
103
104 #changing the target to the openstack release we want to deploy.
105 sed -i -- "s|mitaka|$2|g" ./bundles.yaml
106
107 #update source if trusty is target distribution
108 case "$6" in
109     'trusty' )
110         sed -i -- "s|#source|source|g" ./bundles.yaml
111         sed -i -- "s|#source-branch:|source-branch:|g" ./bundles.yaml
112         ;;
113     'xenial' )
114         #changing the target to the ubuntu distro we want to deploy.
115         sed -i -- "s|trusty|$6|g" ./bundles.yaml
116         ;;
117 esac
118
119 echo "... Deployment Started ...."
120     juju-deployer -vW -d -t 3600 -c bundles.yaml $6-"$2"-nodes
121
122     juju ssh nodes/0 "echo 512 | sudo tee /proc/sys/fs/inotify/max_user_instances"
123
124     juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $6-"$2"