53ff0514fbda564fb5d9f8424a6f0448348665c9
[joid.git] / ci / 03-maasdeploy.sh
1 #!/bin/bash
2 #placeholder for deployment script.
3 set -ex
4
5 virtinstall=0
6 labname=$1
7
8 if [ ! -e $HOME/.ssh/id_rsa ]; then
9     ssh-keygen -N '' -f $HOME/.ssh/id_rsa
10 fi
11
12 #install the packages needed
13 sudo apt-add-repository ppa:juju/devel -y
14 sudo apt-add-repository ppa:maas/stable -y
15 sudo apt-add-repository cloud-archive:newton -y
16 sudo apt-get update -y
17 #sudo apt-get dist-upgrade -y
18 sudo apt-get install openssh-server bzr git virtinst qemu-kvm libvirt-bin juju \
19              maas maas-region-controller python-pip python-psutil python-openstackclient \
20              python-congressclient gsutil charm-tools pastebinit python-jinja2 sshpass \
21              openssh-server vlan ipmitool jq expect -y
22
23 sudo pip install --upgrade pip
24
25 #first parameter should be custom and second should be either
26 # absolute location of file (including file name) or url of the
27 # file to download.
28
29
30 #
31 # Config preparation
32 #
33
34 # Get labconfig and generate deployconfig.yaml
35 case "$labname" in
36     intelpod[569]|orangepod[12]|cengnpod[12] )
37         array=(${labname//pod/ })
38         cp ../labconfig/${array[0]}/pod${array[1]}/labconfig.yaml .
39         python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
40         ;;
41     'attvirpod1' )
42         cp ../labconfig/att/virpod1/labconfig.yaml .
43         python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
44         ;;
45     'custom')
46         labfile=$2
47         if [ -e $labfile ]; then
48             cp $labfile ./labconfig.yaml || true
49         else
50             wget $labconfigfile -t 3 -T 10 -O ./labconfig.yaml || true
51             count=`wc -l labconfig.yaml  | cut -d " " -f 1`
52             if [ $count -lt 10 ]; then
53                 rm -rf labconfig.yaml
54             fi
55         fi
56         if [ ! -e ./labconfig.yaml ]; then
57             virtinstall=1
58             labname="default"
59             cp ../labconfig/default/labconfig.yaml ./
60             cp ../labconfig/default/deployconfig.yaml ./
61         else
62             python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
63             labname=`grep "maas_name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
64         fi
65         ;;
66     * )
67         virtinstall=1
68         labname="default"
69         cp ../labconfig/default/labconfig.yaml ./
70         python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
71         ;;
72 esac
73
74 MAAS_IP=$(grep " ip_address" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //')
75 MAAS_NAME=`grep "maas_name" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
76 API_SERVER="http://$MAAS_IP/MAAS/api/2.0"
77 API_SERVERMAAS="http://$MAAS_IP/MAAS/"
78 PROFILE=ubuntu
79 MY_UPSTREAM_DNS=`grep "upstream_dns" deployconfig.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
80 SSH_KEY=`cat ~/.ssh/id_rsa.pub`
81 MAIN_ARCHIVE=`grep "main_archive" deployconfig.yaml | cut -d ':' -f 2-3 | sed -e 's/ //'`
82 URL=https://images.maas.io/ephemeral-v2/daily/
83 KEYRING_FILE=/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg
84 SOURCE_ID=1
85 FABRIC_ID=1
86 VLAN_TAG=""
87 PRIMARY_RACK_CONTROLLER="$MAAS_IP"
88 SUBNET_CIDR="192.168.122.0/24"
89 VLAN_TAG="untagged"
90
91 # In the case of a virtual deployment get deployconfig.yaml
92 if [ "$virtinstall" -eq 1 ]; then
93     MAAS_IP="192.168.122.1"
94     API_SERVER="http://$MAAS_IP/MAAS/api/2.0"
95     API_SERVERMAAS="http://$MAAS_IP/MAAS/"
96     PRIMARY_RACK_CONTROLLER="$MAAS_IP"
97     ./cleanvm.sh || true
98 fi
99
100 #create backup directory
101 mkdir ~/joid_config/ || true
102
103 # Backup deployconfig.yaml in joid_config folder
104
105 if [ -e ./deployconfig.yaml ]; then
106     cp ./deployconfig.yaml ~/joid_config/
107     cp ./labconfig.yaml ~/joid_config/
108 fi
109
110 #
111 # Prepare local environment to avoid password asking
112 #
113
114 # make sure no password asked during the deployment.
115 sudoer_file=/etc/sudoers.d/90-joid-init
116 sudoer_entry="$USER ALL=(ALL) NOPASSWD:ALL"
117 if [ -e $sudoer_file ]; then
118     if ! sudo grep -q "$sudoer_entry" $sudoer_file; then
119         sudo sed -i -e "1i$sudoer_entry" $sudoer_file
120     fi
121 else
122     echo "$sudoer_entry" > 90-joid-init
123     sudo chown root:root 90-joid-init
124     sudo mv 90-joid-init /etc/sudoers.d/
125 fi
126
127 echo "... Deployment of maas Started ...."
128
129 #
130 # Virsh preparation
131 #
132
133 # define the pool and try to start even though its already exist.
134 # For fresh install this may or may not there.
135 sudo adduser $USER libvirtd
136 sudo virsh pool-define-as default --type dir --target /var/lib/libvirt/images/ || true
137 sudo virsh pool-start default || true
138 sudo virsh pool-autostart default || true
139
140 # In case of virtual install set network
141 if [ "$virtinstall" -eq 1 ]; then
142     sudo virsh net-dumpxml default > default-net-org.xml
143     sudo sed -i '/dhcp/d' default-net-org.xml
144     sudo sed -i '/range/d' default-net-org.xml
145     sudo virsh net-define default-net-org.xml
146     sudo virsh net-destroy default
147     sudo virsh net-start default
148     rm -f default-net-org.xml
149 fi
150
151 #
152 # Cleanup, juju init and config backup
153 #
154
155 # To avoid problem between apiclient/maas_client and apiclient from google
156 # we remove the package google-api-python-client from yardstick installer
157 if [ $(pip list |grep google-api-python-client |wc -l) == 1 ]; then
158     sudo pip uninstall google-api-python-client
159 fi
160
161
162 if [ ! -e ~maas/.ssh/id_rsa.pub ]; then
163     if [ ! -e $HOME/id_rsa_maas.pub ]; then
164         [ -e $HOME/id_rsa_maas ] && rm -f $HOME/id_rsa_maas
165         sudo su - $USER -c "echo |ssh-keygen -t rsa -f $HOME/id_rsa_maas"
166     fi
167     sudo -u maas mkdir ~maas/.ssh/ || true
168     sudo cp $HOME/id_rsa_maas ~maas/.ssh/id_rsa
169     sudo cp $HOME/id_rsa_maas.pub ~maas/.ssh/id_rsa.pub
170     sudo chown maas:maas ~maas/.ssh/id_rsa
171     sudo chown maas:maas ~maas/.ssh/id_rsa.pub
172 fi
173
174 # Ensure virsh can connect without ssh auth
175 sudo cat ~maas/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
176 sudo cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
177
178 #
179 # MAAS deploy
180 #
181
182 installmaas(){
183     sudo apt-get install maas maas-region-controller -y
184 }
185
186 #
187 # MAAS config
188 # https://insights.ubuntu.com/2016/01/23/maas-setup-deploying-openstack-on-maas-1-9-with-juju/
189 # http://blog.naydenov.net/2016/01/nodes-networking-deploying-openstack-on-maas-1-9-with-juju/
190 #
191 configuremaas(){
192     sudo maas createadmin --username=ubuntu --email=ubuntu@ubuntu.com --password=ubuntu || true
193     API_KEY=`sudo maas-region apikey --username=ubuntu`
194     maas login $PROFILE $API_SERVERMAAS $API_KEY
195     maas $PROFILE maas set-config name='main_archive' value=$MAIN_ARCHIVE || true
196     maas $PROFILE maas set-config name=upstream_dns value=$MY_UPSTREAM_DNS || true
197     maas $PROFILE maas set-config name='maas_name' value=$MAAS_NAME || true
198     maas $PROFILE maas set-config name='ntp_server' value='ntp.ubuntu.com' || true
199     maas $PROFILE sshkeys create "key=$SSH_KEY" || true
200
201     maas $PROFILE tags create name='bootstrap' || true
202     maas $PROFILE tags create name='compute' || true
203     maas $PROFILE tags create name='control' || true
204     maas $PROFILE tags create name='storage' || true
205
206     #create the required spaces.
207     maas $PROFILE space update 0 name=default || true
208     maas $PROFILE spaces create name=unused || true
209     maas $PROFILE spaces create name=admin-api || true
210     maas $PROFILE spaces create name=internal-api || true
211     maas $PROFILE spaces create name=public-api || true
212     maas $PROFILE spaces create name=compute-data || true
213     maas $PROFILE spaces create name=compute-external || true
214     maas $PROFILE spaces create name=storage-data || true
215     maas $PROFILE spaces create name=storage-cluster || true
216
217     maas $PROFILE boot-source update $SOURCE_ID \
218          url=$URL keyring_filename=$KEYRING_FILE || true
219
220     maas $PROFILE boot-resources import || true
221     sleep 10
222
223     while [ "$(maas $PROFILE boot-resources is-importing)" == "true" ];
224     do
225         sleep 60
226     done
227
228     #maas $PROFILE subnet update vlan:<vlan id> name=internal-api space=<0> gateway_ip=10.5.1.1
229     #maas $PROFILE subnet update vlan:<vlan id> name=admin-api space=<2> gateway_ip=10.5.12.1
230     #maas $PROFILE subnet update vlan:<vlan id> name=public-api space=<1> gateway_ip=10.5.15.1
231     #maas $PROFILE subnet update vlan:<vlan id> name=compute-data space=<3> gateway_ip=10.5.17.1
232     #maas $PROFILE subnet update vlan:<vlan id> name=compute-external space=<4> gateway_ip=10.5.19.1
233     #maas $PROFILE subnet update vlan:<vlan id> name=storage-data space=<5> gateway_ip=10.5.20.1
234     #maas $PROFILE subnet update vlan:<vlan id> name=storage-cluster space=<6> gateway_ip=10.5.21.1
235
236 }
237
238 enablesubnetanddhcp(){
239
240     SUBNET_PREFIX="192.168.122"
241     SUBNET_CIDR="$SUBNET_PREFIX.0/24"
242
243     IP_STATIC_RANGE_LOW="192.168.122.1"
244     IP_STATIC_RANGE_HIGH="192.168.122.49"
245
246     API_KEY=`sudo maas-region apikey --username=ubuntu`
247     maas login $PROFILE $API_SERVERMAAS $API_KEY
248
249     maas $PROFILE ipranges create type=reserved \
250          start_ip=$IP_STATIC_RANGE_LOW end_ip=$IP_STATIC_RANGE_HIGH \
251          comment='This is a reserved range' || true
252
253     IP_DYNAMIC_RANGE_LOW="192.168.122.50"
254     IP_DYNAMIC_RANGE_HIGH="192.168.122.150"
255     maas $PROFILE ipranges create type=dynamic \
256         start_ip=$IP_DYNAMIC_RANGE_LOW end_ip=$IP_DYNAMIC_RANGE_HIGH \
257         comment='This is a reserved dynamic range' || true
258
259
260     FABRIC_ID=$(maas $PROFILE subnet read $SUBNET_CIDR | jq '.vlan.fabric_id')
261
262     PRIMARY_RACK_CONTROLLER=$(maas $PROFILE rack-controllers read | jq -r '.[0].system_id')
263
264     maas $PROFILE vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True primary_rack=$PRIMARY_RACK_CONTROLLER || true
265
266     MY_GATEWAY="192.168.122.1"
267     MY_NAMESERVER=192.168.122.1
268     maas $PROFILE subnet update $SUBNET_CIDR gateway_ip=$MY_GATEWAY || true
269     maas $PROFILE subnet update $SUBNET_CIDR dns_servers=$MY_NAMESERVER || true
270
271     #below command will enable the interface with internal-api space.
272
273     SPACEID=$(maas $PROFILE space read internal-api | jq '.id')
274     maas $PROFILE subnet update $SUBNET_CIDR space=$SPACEID || true
275
276 }
277
278 addnodes(){
279     API_KEY=`sudo maas-region apikey --username=ubuntu`
280     maas login $PROFILE $API_SERVERMAAS $API_KEY
281
282     # make sure there is no machine entry in maas
283     for m in $(maas $PROFILE machines read | jq -r '.[].system_id')
284     do
285         maas ubuntu machine delete $m
286     done
287
288     if [ "$virtinstall" -eq 1 ]; then
289         netw=" --network bridge=virbr0,model=virtio"
290     else
291         brid=`brctl show | grep 8000 | cut -d "8" -f 1 |  tr "\n" " " | tr "\t" " " | tr -s " "`
292
293         netw=""
294         for feature in $brid; do
295             if [ "$feature" == "" ]; then
296                 netw=$netw
297             elif [ "$feature" == "virbr0" ]; then
298                 netw=$netw
299             else
300                 netw=$netw" --network bridge="$feature",model=virtio"
301             fi
302         done
303     fi
304
305     sudo virt-install --connect qemu:///system --name bootstrap --ram 4098 --cpu host --vcpus 2 --video \
306                  cirrus --arch x86_64 --disk size=20,format=qcow2,bus=virtio,io=native,pool=default \
307                  $netw --boot network,hd,menu=off --noautoconsole \
308                  --vnc --print-xml | tee bootstrap
309
310     if [ "$virtinstall" -eq 1 ]; then
311         bootstrapmac=`grep  "mac address" bootstrap | head -1 | cut -d '"' -f 2`
312     else
313         bootstrapmac=""
314         bootstrapmacs=`grep  "mac address" bootstrap| cut -d '"' -f 2`
315         for mac in $bootstrapmacs; do
316             bootstrapmac=$bootstrapmac" mac_addresses="$mac
317         done
318     fi
319     sudo virsh -c qemu:///system define --file bootstrap
320     rm -f bootstrap
321
322     maas $PROFILE machines create autodetect_nodegroup='yes' name='bootstrap' \
323         tags='bootstrap' hostname='bootstrap' power_type='virsh' mac_addresses=$bootstrapmac \
324         power_parameters_power_address='qemu+ssh://'$USER'@'$MAAS_IP'/system' \
325         architecture='amd64/generic' power_parameters_power_id='bootstrap'
326
327     bootstrapid=$(maas $PROFILE machines read | jq -r 'select(.[].hostname == "bootstrap")[0].system_id')
328
329     maas $PROFILE tag update-nodes bootstrap add=$bootstrapid
330
331     if [ "$virtinstall" -eq 1 ]; then
332
333         sudo virt-install --connect qemu:///system --name node1-control --ram 8192 --cpu host --vcpus 4 \
334                      --disk size=120,format=qcow2,bus=virtio,io=native,pool=default \
335                      $netw $netw --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node1-control
336
337         sudo virt-install --connect qemu:///system --name node2-compute --ram 8192 --cpu host --vcpus 4 \
338                     --disk size=120,format=qcow2,bus=virtio,io=native,pool=default \
339                     $netw $netw --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node2-compute
340
341         sudo virt-install --connect qemu:///system --name node5-compute --ram 8192 --cpu host --vcpus 4 \
342                    --disk size=120,format=qcow2,bus=virtio,io=native,pool=default \
343                    $netw $netw --boot network,hd,menu=off --noautoconsole --vnc --print-xml | tee node5-compute
344
345
346         node1controlmac=`grep  "mac address" node1-control | head -1 | cut -d '"' -f 2`
347         node2computemac=`grep  "mac address" node2-compute | head -1 | cut -d '"' -f 2`
348         node5computemac=`grep  "mac address" node5-compute | head -1 | cut -d '"' -f 2`
349
350         sudo virsh -c qemu:///system define --file node1-control
351         sudo virsh -c qemu:///system define --file node2-compute
352         sudo virsh -c qemu:///system define --file node5-compute
353         rm -f node1-control node2-compute node5-compute
354
355
356         maas $PROFILE machines create autodetect_nodegroup='yes' name='node1-control' \
357             tags='control' hostname='node1-control' power_type='virsh' mac_addresses=$node1controlmac \
358             power_parameters_power_address='qemu+ssh://'$USER'@'$MAAS_IP'/system' \
359             architecture='amd64/generic' power_parameters_power_id='node1-control'
360         controlnodeid=$(maas $PROFILE machines read | jq -r 'select(.[].hostname == "node1-control")[0].system_id')
361         maas $PROFILE machines create autodetect_nodegroup='yes' name='node2-compute' \
362             tags='compute' hostname='node2-compute' power_type='virsh' mac_addresses=$node2computemac \
363             power_parameters_power_address='qemu+ssh://'$USER'@'$MAAS_IP'/system' \
364             architecture='amd64/generic' power_parameters_power_id='node2-compute'
365         compute2nodeid=$(maas $PROFILE machines read | jq -r 'select(.[].hostname == "node2-compute")[0].system_id')
366         maas $PROFILE machines create autodetect_nodegroup='yes' name='node5-compute' \
367             tags='compute' hostname='node5-compute' power_type='virsh' mac_addresses=$node5computemac \
368             power_parameters_power_address='qemu+ssh://'$USER'@'$MAAS_IP'/system' \
369             architecture='amd64/generic' power_parameters_power_id='node5-compute'
370         compute5nodeid=$(maas $PROFILE machines read | jq -r 'select(.[].hostname == "node5-compute")[0].system_id')
371
372         maas $PROFILE tag update-nodes control add=$controlnodeid || true
373         maas $PROFILE tag update-nodes compute add=$compute2nodeid || true
374         maas $PROFILE tag update-nodes compute add=$compute5nodeid || true
375     fi
376
377     # make sure nodes are added into MAAS and none of them is in commisoning state
378     while [ "$(maas $PROFILE nodes read | grep  Commissioning )" ];
379     do
380         sleep 60
381     done
382
383 }
384
385 #configure MAAS with the different options.
386 configuremaas
387
388 if [ "$virtinstall" -eq 1 ]; then
389     enablesubnetanddhcp
390 fi
391
392 #just make sure rack controller has been synced and import only
393 # just whether images have been imported or not.
394 sleep 120
395
396 #reconfigure maas with correct MAAS address.
397 #Below code is needed as MAAS have issue in commisoning without restart.
398 sudo ./maas-reconfigure-rack.sh $MAAS_IP
399 sudo ./maas-reconfigure-region.sh $MAAS_IP
400
401 sleep 30
402 #lets add the nodes now. Currently works only for virtual deploymnet.
403 addnodes
404
405 echo "... Deployment of maas finish ...."
406
407 #Added the Qtip public to run the Qtip test after install on bare metal nodes.
408 #maas $PROFILE sshkeys new key="`cat ./maas/sshkeys/QtipKey.pub`"
409 #maas $PROFILE sshkeys new key="`cat ./maas/sshkeys/DominoKey.pub`"
410
411 #
412 # Functions for MAAS network customization
413 #
414
415 #Below function will mark the interfaces in Auto mode to enbled by MAAS
416 enableautomode() {
417     API_KEY=`sudo maas-region apikey --username=ubuntu`
418     maas login $PROFILE $API_SERVERMAAS $API_KEY
419
420     for node in $(maas $PROFILE nodes read | jq -r '.[].system_id')
421     do
422         maas $PROFILE interface link-subnet $node $1  mode=$2 subnet=$3 || true
423     done
424 }
425
426 #Below function will mark the interfaces in Auto mode to enbled by MAAS
427 # using hostname of the node added into MAAS
428 enableautomodebyname() {
429     API_KEY=`sudo maas-region apikey --username=ubuntu`
430     maas login $PROFILE $API_SERVERMAAS $API_KEY
431
432     if [ ! -z "$4" ]; then
433         for i in `seq 1 7`;
434         do
435             nodes=$(maas $PROFILE nodes read | jq -r '.[].system_id')
436             if [ ! -z "$nodes" ]; then
437                 maas $PROFILE interface link-subnet $nodes $1  mode=$2 subnet=$3 || true
438             fi
439        done
440     fi
441 }
442
443 #Below function will create vlan and update interface with the new vlan
444 # will return the vlan id created
445 crvlanupdsubnet() {
446     API_KEY=`sudo maas-region apikey --username=ubuntu`
447     maas login $PROFILE $API_SERVERMAAS $API_KEY
448
449     # TODO: fix subnet creation and use 'jq'
450     newvlanid=`maas $PROFILE vlans create $2 name=$3 vid=$4 | grep resource | cut -d '/' -f 6 `
451     maas $PROFILE subnet update $5 vlan=$newvlanid
452     eval "$1"="'$newvlanid'"
453 }
454
455 #Below function will create interface with new vlan and bind to physical interface
456 crnodevlanint() {
457     API_KEY=`sudo maas-region apikey --username=ubuntu`
458     maas login $PROFILE $API_SERVERMAAS $API_KEY
459
460     for node in $(maas $PROFILE nodes read | jq -r '.[].system_id')
461     do
462         interface=$(maas $PROFILE interface read $node $2 | jq -r '.id')
463         maas $PROFILE interfaces create-vlan $node vlan=$1 parent=$interface
464      done
465  }
466
467 #function for JUJU envronment
468
469 addcredential() {
470     API_KEY=`sudo maas-region apikey --username=ubuntu`
471     controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
472     cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
473
474     echo  "credentials:" > credential.yaml
475     echo  "  $controllername:" >> credential.yaml
476     echo  "    opnfv-credentials:" >> credential.yaml
477     echo  "      auth-type: oauth1" >> credential.yaml
478     echo  "      maas-oauth: $API_KEY" >> credential.yaml
479
480     juju add-credential $controllername -f credential.yaml --replace
481 }
482
483 addcloud() {
484     controllername=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
485     cloudname=`awk 'NR==1{print substr($1, 1, length($1)-1)}' deployconfig.yaml`
486
487     echo "clouds:" > maas-cloud.yaml
488     echo "   $cloudname:" >> maas-cloud.yaml
489     echo "      type: maas" >> maas-cloud.yaml
490     echo "      auth-types: [oauth1]" >> maas-cloud.yaml
491     echo "      endpoint: $API_SERVERMAAS" >> maas-cloud.yaml
492
493     juju add-cloud $cloudname maas-cloud.yaml --replace
494 }
495
496
497 #
498 # VLAN customization
499 #
500
501 case "$labname" in
502     'intelpod9' )
503         maas refresh
504         crvlanupdsubnet vlan904 fabric-1 "MgmtNetwork" 904 2 || true
505         crvlanupdsubnet vlan905 fabric-2 "PublicNetwork" 905 3 || true
506         crnodevlanint $vlan905 eth1 || true
507         crnodevlanint $vlan905 eth3 || true
508         enableautomodebyname eth1.905 AUTO "10.9.15.0/24" || true
509         enableautomodebyname eth3.905 AUTO "10.9.15.0/24" || true
510         enableautomodebyname eth0 AUTO "10.9.12.0/24" || true
511         enableautomodebyname eth2 AUTO "10.9.12.0/24" || true
512         ;;
513 esac
514
515 #
516 # Enable MAAS nodes interfaces
517 #
518
519 #read interface needed in Auto mode and enable it. Will be rmeoved once auto enablement will be implemented in the maas-deployer.
520
521 if [ -e ./deployconfig.yaml ]; then
522   enableiflist=`grep "interface-enable" deployconfig.yaml | cut -d ' ' -f 4 `
523   datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
524   stornet=`grep "storageNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
525   pubnet=`grep "publicNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
526
527   # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
528
529   if [ "$datanet" != "''" ]; then
530       EXTNET=(${enableiflist//,/ })
531       i="0"
532       while [ ! -z "${EXTNET[i]}" ];
533       do
534           enableautomode ${EXTNET[i]} AUTO $datanet || true
535           i=$[$i+1]
536       done
537
538   fi
539   if [ "$stornet" != "''" ]; then
540       EXTNET=(${enableiflist//,/ })
541       i="0"
542       while [ ! -z "${EXTNET[i]}" ];
543       do
544           enableautomode ${EXTNET[i]} AUTO $stornet || true
545           i=$[$i+1]
546       done
547   fi
548   if [ "$pubnet" != "''" ]; then
549       EXTNET=(${enableiflist//,/ })
550       i="0"
551       while [ ! -z "${EXTNET[i]}" ];
552       do
553           enableautomode ${EXTNET[i]} AUTO $pubnet || true
554           i=$[$i+1]
555       done
556   fi
557 fi
558
559
560 # Add the cloud and controller credentials for MAAS for that lab.
561 jujuver=`juju --version`
562
563 if [[ "$jujuver" > "2" ]]; then
564     addcloud
565     addcredential
566 fi
567
568 #
569 # End of scripts
570 #
571 echo " .... MAAS deployment finished successfully ...."