2 #placeholder for deployment script.
8 #install the packages needed
9 sudo apt-add-repository ppa:maas-deployers/stable -y
10 sudo apt-add-repository ppa:juju/stable -y
11 sudo apt-add-repository ppa:maas/stable -y
12 sudo apt-add-repository cloud-archive:mitaka -y
13 sudo apt-get update -y
14 sudo apt-get dist-upgrade -y
15 sudo apt-get install openssh-server bzr git maas-deployer juju juju-deployer \
16 maas-cli python-pip python-psutil python-openstackclient \
17 python-congressclient gsutil charm-tools -y
19 #first parameter should be custom and second should be either
20 # absolute location of file (including file name) or url of the
30 # Get labconfig and generate deployment.yaml for MAAS and deployconfig.yaml
32 intelpod[569]|orangepod[12]|cengnpod[12] )
33 array=(${labname//pod/ })
34 cp ../labconfig/${array[0]}/pod${array[1]}/labconfig.yaml .
35 python genMAASConfig.py -l labconfig.yaml > deployment.yaml
36 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
39 cp ../labconfig/att/virpod1/labconfig.yaml .
40 python genMAASConfig.py -l labconfig.yaml > deployment.yaml
41 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
44 cp maas/juniper/pod1/deployment.yaml ./deployment.yaml
47 if [ -e $labfile ]; then
48 cp $labfile ./labconfig.yaml || true
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
56 if [ ! -e ./labconfig.yaml ]; then
59 python genMAASConfig.py -l labconfig.yaml > deployment.yaml
60 python genDeploymentConfig.py -l labconfig.yaml > deployconfig.yaml
61 labname=`grep "maas_name" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
69 # In the case of a virtual deployment get deployment.yaml and deployconfig.yaml
70 if [ "$virtinstall" -eq 1 ]; then
73 cp ../labconfig/default/deployment.yaml ./
74 cp ../labconfig/default/labconfig.yaml ./
75 cp ../labconfig/default/deployconfig.yaml ./
79 # Prepare local environment to avoid password asking
82 # make sure no password asked during the deployment.
83 echo "$USER ALL=(ALL) NOPASSWD:ALL" > 90-joid-init
85 if [ -e /etc/sudoers.d/90-joid-init ]; then
86 sudo cp /etc/sudoers.d/90-joid-init 91-joid-init
87 sudo chown $USER:$USER 91-joid-init
88 sudo chmod 660 91-joid-init
89 sudo cat 90-joid-init >> 91-joid-init
90 sudo chown root:root 91-joid-init
91 sudo mv 91-joid-init /etc/sudoers.d/
93 sudo chown root:root 90-joid-init
94 sudo mv 90-joid-init /etc/sudoers.d/
97 if [ ! -e $HOME/.ssh/id_rsa ]; then
98 ssh-keygen -N '' -f $HOME/.ssh/id_rsa
101 echo "... Deployment of maas Started ...."
107 # define the pool and try to start even though its already exist.
108 # For fresh install this may or may not there.
109 sudo apt-get install libvirt-bin -y
110 sudo adduser $USER libvirtd
111 sudo virsh pool-define-as default --type dir --target /var/lib/libvirt/images/ || true
112 sudo virsh pool-start default || true
113 sudo virsh pool-autostart default || true
115 # In case of virtual install set network
116 if [ "$virtinstall" -eq 1 ]; then
117 sudo virsh net-dumpxml default > default-net-org.xml
118 sudo sed -i '/dhcp/d' default-net-org.xml
119 sudo sed -i '/range/d' default-net-org.xml
120 sudo virsh net-define default-net-org.xml
121 sudo virsh net-destroy default
122 sudo virsh net-start default
125 # Ensure virsh can connect without ssh auth
126 cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
130 # Cleanup, juju init and config backup
133 # To avoid problem between apiclient/maas_client and apiclient from google
134 # we remove the package google-api-python-client from yardstick installer
135 if [ $(pip list |grep google-api-python-client |wc -l) == 1 ]; then
136 sudo pip uninstall google-api-python-client
146 sudo maas-deployer -c deployment.yaml -d --force
148 sudo chown $USER:$USER environments.yaml
150 echo "... Deployment of maas finish ...."
152 # Backup deployment.yaml and deployconfig.yaml in .juju folder
154 cp ./environments.yaml ~/.juju/
156 if [ -e ./deployconfig.yaml ]; then
157 cp ./deployconfig.yaml ~/.juju/
158 cp ./labconfig.yaml ~/.juju/
165 maas_ip=`grep " ip_address" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
166 apikey=`grep maas-oauth: environments.yaml | cut -d "'" -f 2`
167 maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey}
168 maas maas sshkeys new key="`cat $HOME/.ssh/id_rsa.pub`"
170 #Added the Qtip public to run the Qtip test after install on bare metal nodes.
171 maas maas sshkeys new key="`cat ./maas/sshkeys/QtipKey.pub`"
172 maas maas sshkeys new key="`cat ./maas/sshkeys/DominoKey.pub`"
174 #adding compute and control nodes VM to MAAS for virtual deployment purpose.
175 if [ "$virtinstall" -eq 1 ]; then
176 # create two more VMs to do the deployment.
177 sudo virt-install --connect qemu:///system --name node1-control --ram 8192 --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
179 sudo virt-install --connect qemu:///system --name node2-compute --ram 8192 --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
181 sudo virt-install --connect qemu:///system --name node5-compute --ram 8192 --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
183 node1controlmac=`grep "mac address" node1-control | head -1 | cut -d "'" -f 2`
184 node2computemac=`grep "mac address" node2-compute | head -1 | cut -d "'" -f 2`
185 node5computemac=`grep "mac address" node5-compute | head -1 | cut -d "'" -f 2`
187 sudo virsh -c qemu:///system define --file node1-control
188 sudo virsh -c qemu:///system define --file node2-compute
189 sudo virsh -c qemu:///system define --file node5-compute
191 maas maas tags new name='control'
192 maas maas tags new name='compute'
194 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 `
196 maas maas tag update-nodes control add=$controlnodeid
198 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 `
200 maas maas tag update-nodes compute add=$computenodeid
202 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 `
204 maas maas tag update-nodes compute add=$computenodeid
208 # Functions for MAAS network customization
211 #Below function will mark the interfaces in Auto mode to enbled by MAAS
213 listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
214 for nodes in $listofnodes
216 maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3
220 #Below function will mark the interfaces in Auto mode to enbled by MAAS
221 # using hostname of the node added into MAAS
222 enableautomodebyname() {
223 if [ ! -z "$4" ]; then
226 nodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
227 if [ ! -z "$nodes" ]; then
228 maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3
234 #Below function will create vlan and update interface with the new vlan
235 # will return the vlan id created
237 newvlanid=`maas maas vlans create $2 name=$3 vid=$4 | grep resource | cut -d '/' -f 6 `
238 maas maas subnet update $5 vlan=$newvlanid
239 eval "$1"="'$newvlanid'"
242 #Below function will create interface with new vlan and bind to physical interface
244 listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
246 for nodes in $listofnodes
248 parentid=`maas maas interface read $nodes $2 | grep interfaces | cut -d '/' -f 8`
249 maas maas interfaces create-vlan $nodes vlan=$1 parent=$parentid
260 crvlanupdsubnet vlan904 fabric-1 "MgmtNetwork" 904 2 || true
261 crvlanupdsubnet vlan905 fabric-2 "PublicNetwork" 905 3 || true
262 crnodevlanint $vlan905 eth1 || true
263 crnodevlanint $vlan905 eth3 || true
264 enableautomodebyname eth1.905 AUTO "10.9.15.0/24" || true
265 enableautomodebyname eth3.905 AUTO "10.9.15.0/24" || true
266 enableautomodebyname eth0 AUTO "10.9.12.0/24" || true
267 enableautomodebyname eth2 AUTO "10.9.12.0/24" || true
272 # Enable MAAS nodes interfaces
275 #read interface needed in Auto mode and enable it. Will be rmeoved once auto enablement will be implemented in the maas-deployer.
276 if [ -e ~/.juju/deployconfig.yaml ]; then
277 cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
279 enableiflist=`grep "interface-enable" deployconfig.yaml | cut -d ' ' -f 4 `
280 datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
281 stornet=`grep "storageNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
282 pubnet=`grep "publicNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
284 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
286 if [ "$datanet" != "''" ]; then
287 EXTNET=(${enableiflist//,/ })
289 while [ ! -z "${EXTNET[i]}" ];
291 enableautomode ${EXTNET[i]} AUTO $datanet || true
295 if [ "$stornet" != "''" ]; then
296 EXTNET=(${enableiflist//,/ })
298 while [ ! -z "${EXTNET[i]}" ];
300 enableautomode ${EXTNET[i]} AUTO $stornet || true
304 if [ "$pubnet" != "''" ]; then
305 EXTNET=(${enableiflist//,/ })
307 while [ ! -z "${EXTNET[i]}" ];
309 enableautomode ${EXTNET[i]} AUTO $pubnet || true
318 echo " .... MAAS deployment finished successfully ...."