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