2 #placeholder for deployment script.
5 echo "Note: This script is deprecated. Use 03-maasdeploy.sh instead."
6 echo "Are you sure you want to execute this script? [y/N] "
8 [[ "$a" = "y" ]] || exit
14 #install the packages needed
15 sudo apt-add-repository ppa:opnfv-team/proposed -y
16 sudo apt-add-repository ppa:maas-deployers/stable -y
17 sudo apt-add-repository ppa:juju/stable -y
18 sudo apt-add-repository ppa:maas/stable -y
19 sudo apt-add-repository cloud-archive:mitaka -y
20 sudo apt-get update -y
21 sudo apt-get dist-upgrade -y
22 sudo pip install --upgrade pip
23 sudo apt-get install openssh-server bzr git maas-deployer juju juju-deployer \
24 maas-cli python-pip python-psutil python-openstackclient \
25 python-congressclient gsutil charm-tools pastebinit -y
27 sudo apt-get purge juju -y
28 wget https://launchpad.net/~juju/+archive/ubuntu/stable/+files/juju-core_1.25.5-0ubuntu1~14.04.2~juju1_amd64.deb
29 sudo dpkg -i juju-core_1.25.5-0ubuntu1~14.04.2~juju1_amd64.deb
31 #first parameter should be custom and second should be either
32 # absolute location of file (including file name) or url of the
42 # Get labconfig and generate deployment.yaml for MAAS and deployconfig.yaml
44 intelpod[569]|orangepod[12]|cengnpod[12] )
45 array=(${labname//pod/ })
46 cp ../labconfig/${array[0]}/pod${array[1]}/labconfig.yaml .
47 python genMAASConfig.py -l labconfig.yaml > deployment.yaml
48 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
51 cp ../labconfig/att/virpod1/labconfig.yaml .
52 python genMAASConfig.py -l labconfig.yaml > deployment.yaml
53 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
56 cp maas/juniper/pod1/deployment.yaml ./deployment.yaml
59 if [ -e $labfile ]; then
60 cp $labfile ./labconfig.yaml || true
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
68 if [ ! -e ./labconfig.yaml ]; then
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/ //'`
81 # In the case of a virtual deployment get deployment.yaml and deployconfig.yaml
82 if [ "$virtinstall" -eq 1 ]; then
85 cp ../labconfig/default/deployment.yaml ./
86 cp ../labconfig/default/labconfig.yaml ./
87 cp ../labconfig/default/deployconfig.yaml ./
91 # Prepare local environment to avoid password asking
94 # make sure no password asked during the deployment.
95 echo "$USER ALL=(ALL) NOPASSWD:ALL" > 90-joid-init
97 if [ -e /etc/sudoers.d/90-joid-init ]; then
98 sudo cp /etc/sudoers.d/90-joid-init 91-joid-init
99 sudo chown $USER:$USER 91-joid-init
100 sudo chmod 660 91-joid-init
101 sudo cat 90-joid-init >> 91-joid-init
102 sudo chown root:root 91-joid-init
103 sudo mv 91-joid-init /etc/sudoers.d/
105 sudo chown root:root 90-joid-init
106 sudo mv 90-joid-init /etc/sudoers.d/
109 if [ ! -e $HOME/.ssh/id_rsa ]; then
110 ssh-keygen -N '' -f $HOME/.ssh/id_rsa
113 echo "... Deployment of maas Started ...."
119 # define the pool and try to start even though its already exist.
120 # For fresh install this may or may not there.
121 sudo apt-get install libvirt-bin -y
122 sudo adduser $USER libvirtd
123 sudo virsh pool-define-as default --type dir --target /var/lib/libvirt/images/ || true
124 sudo virsh pool-start default || true
125 sudo virsh pool-autostart default || true
127 # In case of virtual install set network
128 if [ "$virtinstall" -eq 1 ]; then
129 sudo virsh net-dumpxml default > default-net-org.xml
130 sudo sed -i '/dhcp/d' default-net-org.xml
131 sudo sed -i '/range/d' default-net-org.xml
132 sudo virsh net-define default-net-org.xml
133 sudo virsh net-destroy default
134 sudo virsh net-start default
137 # Ensure virsh can connect without ssh auth
138 cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
142 # Cleanup, juju init and config backup
145 # To avoid problem between apiclient/maas_client and apiclient from google
146 # we remove the package google-api-python-client from yardstick installer
147 if [ $(pip list |grep google-api-python-client |wc -l) == 1 ]; then
148 sudo pip uninstall google-api-python-client
151 #create backup directory
152 mkdir ~/joid_config/ || true
153 mkdir ~/.juju/ || true
162 sudo maas-deployer -c deployment.yaml -d --force
164 sudo chown $USER:$USER environments.yaml
166 echo "... Deployment of maas finish ...."
168 # Backup deployment.yaml and deployconfig.yaml in .juju folder
170 cp ./environments.yaml ~/.juju/
171 cp ./environments.yaml ~/joid_config/
173 if [ -e ./deployconfig.yaml ]; then
174 cp ./deployconfig.yaml ~/.juju/
175 cp ./labconfig.yaml ~/.juju/
176 cp ./deployconfig.yaml ~/joid_config/
177 cp ./labconfig.yaml ~/joid_config/
180 if [ -e ./deployment.yaml ]; then
181 cp ./deployment.yaml ~/.juju/
182 cp ./deployment.yaml ~/joid_config/
189 maas_ip=`grep " ip_address" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
190 apikey=`grep maas-oauth: environments.yaml | cut -d "'" -f 2`
191 maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey}
192 maas maas sshkeys new key="`cat $HOME/.ssh/id_rsa.pub`"
194 #Added the Qtip public to run the Qtip test after install on bare metal nodes.
195 #maas maas sshkeys new key="`cat ./maas/sshkeys/QtipKey.pub`"
196 #maas maas sshkeys new key="`cat ./maas/sshkeys/DominoKey.pub`"
198 #adding compute and control nodes VM to MAAS for virtual deployment purpose.
199 if [ "$virtinstall" -eq 1 ]; then
200 # create two more VMs to do the deployment.
201 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
203 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
205 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
207 node1controlmac=`grep "mac address" node1-control | head -1 | cut -d "'" -f 2`
208 node2computemac=`grep "mac address" node2-compute | head -1 | cut -d "'" -f 2`
209 node5computemac=`grep "mac address" node5-compute | head -1 | cut -d "'" -f 2`
211 sudo virsh -c qemu:///system define --file node1-control
212 sudo virsh -c qemu:///system define --file node2-compute
213 sudo virsh -c qemu:///system define --file node5-compute
215 maas maas tags new name='control'
216 maas maas tags new name='compute'
218 controlnodeid=`maas maas nodes new 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 `
220 maas maas tag update-nodes control add=$controlnodeid
222 computenodeid=`maas maas nodes new 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 `
224 maas maas tag update-nodes compute add=$computenodeid
226 computenodeid=`maas maas nodes new 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 `
228 maas maas tag update-nodes compute add=$computenodeid
232 # Functions for MAAS network customization
235 #Below function will mark the interfaces in Auto mode to enbled by MAAS
237 listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
238 for nodes in $listofnodes
240 maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3
244 #Below function will mark the interfaces in Auto mode to enbled by MAAS
245 # using hostname of the node added into MAAS
246 enableautomodebyname() {
247 if [ ! -z "$4" ]; then
250 nodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
251 if [ ! -z "$nodes" ]; then
252 maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3
258 #Below function will create vlan and update interface with the new vlan
259 # will return the vlan id created
261 newvlanid=`maas maas vlans create $2 name=$3 vid=$4 | grep resource | cut -d '/' -f 6 `
262 maas maas subnet update $5 vlan=$newvlanid
263 eval "$1"="'$newvlanid'"
266 #Below function will create interface with new vlan and bind to physical interface
268 listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
270 for nodes in $listofnodes
272 parentid=`maas maas interface read $nodes $2 | grep interfaces | cut -d '/' -f 8`
273 maas maas interfaces create-vlan $nodes vlan=$1 parent=$parentid
277 #function for JUJU envronment
280 controllername=`awk 'NR==1{print $2}' environments.yaml`
281 cloudname=`awk 'NR==1{print $2}' environments.yaml`
283 echo "credentials:" > credential.yaml
284 echo " $controllername:" >> credential.yaml
285 echo " opnfv-credentials:" >> credential.yaml
286 echo " auth-type: oauth1" >> credential.yaml
287 echo " maas-oauth: $apikey" >> credential.yaml
289 juju add-credential $controllername -f credential.yaml --replace
293 controllername=`awk 'NR==1{print $2}' environments.yaml`
294 cloudname=`awk 'NR==1{print $2}' environments.yaml`
296 echo "clouds:" > maas-cloud.yaml
297 echo " $cloudname:" >> maas-cloud.yaml
298 echo " type: maas" >> maas-cloud.yaml
299 echo " auth-types: [oauth1]" >> maas-cloud.yaml
300 echo " endpoint: http://$maas_ip/MAAS" >> maas-cloud.yaml
302 juju add-cloud $cloudname maas-cloud.yaml --replace
313 crvlanupdsubnet vlan904 fabric-1 "MgmtNetwork" 904 2 || true
314 crvlanupdsubnet vlan905 fabric-2 "PublicNetwork" 905 3 || true
315 crnodevlanint $vlan905 eth1 || true
316 crnodevlanint $vlan905 eth3 || true
317 enableautomodebyname eth1.905 AUTO "10.9.15.0/24" || true
318 enableautomodebyname eth3.905 AUTO "10.9.15.0/24" || true
319 enableautomodebyname eth0 AUTO "10.9.12.0/24" || true
320 enableautomodebyname eth2 AUTO "10.9.12.0/24" || true
325 # Enable MAAS nodes interfaces
328 #read interface needed in Auto mode and enable it. Will be rmeoved once auto enablement will be implemented in the maas-deployer.
329 if [ -e ~/joid_config/deployconfig.yaml ]; then
330 cp ~/joid_config/deployconfig.yaml ./deployconfig.yaml
331 elif [ -e ~/.juju/deployconfig.yaml ]; then
332 cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
335 if [ -e ./deployconfig.yaml ]; then
336 enableiflist=`grep "interface-enable" deployconfig.yaml | cut -d ' ' -f 4 `
337 datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
338 stornet=`grep "storageNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
339 pubnet=`grep "publicNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
341 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
343 if [ "$datanet" != "''" ]; then
344 EXTNET=(${enableiflist//,/ })
346 while [ ! -z "${EXTNET[i]}" ];
348 enableautomode ${EXTNET[i]} AUTO $datanet || true
352 if [ "$stornet" != "''" ]; then
353 EXTNET=(${enableiflist//,/ })
355 while [ ! -z "${EXTNET[i]}" ];
357 enableautomode ${EXTNET[i]} AUTO $stornet || true
361 if [ "$pubnet" != "''" ]; then
362 EXTNET=(${enableiflist//,/ })
364 while [ ! -z "${EXTNET[i]}" ];
366 enableautomode ${EXTNET[i]} AUTO $pubnet || true
373 # Add the cloud and controller credentials for MAAS for that lab.
374 jujuver=`juju --version`
376 if [[ "$jujuver" > "2" ]]; then
384 echo " .... MAAS deployment finished successfully ...."