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