2 #placeholder for deployment script.
5 # ./02-deploybundle.sh $opnfvtype $openstack $opnfvlab $opnfvsdn $opnfvfeature $opnfvdistro
15 jujuver=`juju --version`
16 maasver=`apt-cache policy maas | grep Installed | cut -d ':' -f 2 | sed -e 's/ //'`
18 if [[ "$opnfvmodel" = "openstack" ]]; then
19 #copy and download charms
20 ./$opnfvsdn/fetch-charms.sh $opnfvdistro
21 tar xvf common/scaleio.tar -C ./$opnfvdistro/ --strip=2 juju-scaleio/trusty/
24 ./kubernetes/fetch-charms.sh $opnfvdistro
27 #check whether charms are still executing the code even juju-deployer says installed.
31 while [ $retval -eq 0 ]; do
33 juju status > status.txt
34 if [ "$(grep -c "waiting" status.txt )" -ge 4 ]; then
35 echo " still waiting for machines ..."
36 if [ $timeoutiter -ge 240 ]; then
39 timeoutiter=$((timeoutiter+1))
44 echo "...... deployment finishing ......."
47 #read the value from deployconfig.yaml
50 MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
51 API_SERVERMAAS="http://$MAAS_IP/MAAS/"
52 if [[ "$maasver" > "2" ]]; then
53 API_KEY=`sudo maas-region apikey --username=ubuntu || true`
55 API_KEY=`sudo maas-region-admin apikey --username=ubuntu || true`
59 if [[ "$API_KEY" = "" ]]; then
60 if [[ "$maasver" > "2" ]]; then
61 API_KEY=`sshpass -p ubuntu ssh ubuntu@$MAAS_IP 'sudo maas-region apikey --username=ubuntu'`
63 API_KEY=`sshpass -p ubuntu ssh ubuntu@$MAAS_IP 'sudo maas-region-admin apikey --username=ubuntu'`
67 maas login $PROFILE $API_SERVERMAAS $API_KEY
69 if [[ "$opnfvmodel" = "openstack" ]]; then
70 if [ -e ./deployconfig.yaml ]; then
71 extport=`grep "ext-port" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //' | tr ',' ' '`
72 datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
73 admnet=`grep "admNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
74 cephdisk=`grep "ceph-disk" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
75 osdomname=`grep "os-domain-name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
78 if [[ "$maasver" > "2" ]]; then
79 workmutiple=`maas maas nodes read | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
81 workmutiple=`maas maas nodes list | grep "cpu_count" | cut -d ':' -f 2 | sed -e 's/ //' | tr ',' ' '`
84 for v in ${workmutiple[@]}; do
85 if (( $v > $max )); then max=$v; fi;
89 if [ "$max" -lt 4 ];then
91 elif [ "$max" -lt 33 ]; then
93 elif [ "$max" -lt 73 ]; then
98 sed -i "s/worker_multiplier: 1.0/worker_multiplier: ${workmutiple}/g" default_deployment_config.yaml
103 sed -i -- 's/10.4.1.1/172.16.50.1/g' ./bundles.yaml
104 sed -i -- 's/#ext-port: "eth1"/ext-port: "eth1"/g' ./bundles.yaml
107 sed -i -- 's/#ext-port: "eth1"/ext-port: "eth2"/g' ./bundles.yaml
111 # lets put the if seperateor as "," as this will save me from world.
114 for feature in $opnfvfeature; do
115 if [ "$fea" == "" ]; then
122 if [[ "$opnfvmodel" = "openstack" ]]; then
123 #update source if trusty is target distribution
124 var=os-$opnfvsdn-$fea-$opnfvtype"-"$opnfvdistro"_"$openstack
126 if [ "$osdomname" != "None" ]; then
130 var=k8-$opnfvsdn-$fea-baremetal-core
133 if [[ "$opnfvmodel" = "openstack" ]]; then
134 #lets generate the bundle for all target using genBundle.py
135 python genBundle.py -l deployconfig.yaml -s $var > bundles.yaml
137 #lets generate the bundle for k8 target using genK8Bundle.py
138 python genK8Bundle.py -l deployconfig.yaml -s $var > bundles.yaml
141 #keep the back in cloud for later debugging.
142 pastebinit bundles.yaml || true
144 if [[ "$jujuver" < "2" ]]; then
145 echo "... Deployment Started ...."
146 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack"-nodes
147 count=`juju status nodes --format=short | grep nodes | wc -l`
149 while [ $c -lt $count ]; do
150 juju ssh nodes/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
151 juju ssh nodes-compute/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
152 juju ssh nodes/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
153 juju ssh nodes-compute/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
157 juju-deployer -vW -d -t 7200 -r 5 -c bundles.yaml $opnfvdistro-"$openstack" || true
159 # with JUJU 2.0 bundles has to be deployed only once.
160 juju deploy bundles.yaml --debug
163 # seeing issue related to number of open files.
164 count=`juju status nodes --format=short | grep nodes | wc -l`
166 while [ $c -lt $count ]; do
167 juju ssh nodes/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
168 juju ssh nodes-compute/$c 'echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p' || true
169 juju ssh nodes/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
170 juju ssh nodes-compute/$c 'echo 2048 | sudo tee /proc/sys/fs/inotify/max_user_instances' || true
175 #lets gather the status of deployment once juju-deployer completed.
176 juju status --format=tabular