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 -y
19 #first parameter should be custom and second should be either
20 # absolute location of file (including file name) or url of the
23 if [ "$1" == "custom" ]; then
25 cp $2 ./labconfig.yaml || true
28 wget $2 -t 3 -T 10 -O ./labconfig.yaml || true
29 count=`wc -l labconfig.yaml | cut -d " " -f 1`
31 if [ $count -lt 10 ]; then
38 if [ ! -e ./labconfig.yaml ]; then
40 cp ../labconfig/default/deployment.yaml ./
41 cp ../labconfig/default/labconfig.yaml ./
43 labname=`grep "maas_name" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
47 cp ../labconfig/intel/pod5/labconfig.yaml ./
48 #to be removed later once converted for all labs.
52 cp ../labconfig/intel/pod6/labconfig.yaml ./
53 #to be removed later once converted for all labs.
57 cp ../labconfig/intel/pod6/labconfig.yaml ./
58 #to be removed later once converted for all labs.
62 cp ../labconfig/orange/pod1/labconfig.yaml ./
63 #to be removed later once converted for all labs.
67 cp ../labconfig/orange/pod1/labconfig.yaml ./
68 #to be removed later once converted for all labs.
72 cp ../labconfig/att/virpod1/labconfig.yaml ./
73 #to be removed later once converted for all labs.
77 cp maas/juniper/pod1/deployment.yaml ./deployment.yaml
80 cp ../labconfig/cengn/pod1/labconfig.yaml ./
81 #to be removed later once converted for all labs.
85 cp ../labconfig/cengn/pod2/labconfig.yaml ./
86 #to be removed later once converted for all labs.
93 cp ../labconfig/default/deployment.yaml ./
94 cp ../labconfig/default/deployconfig.yaml ./
99 #make sure no password asked during the deployment.
101 echo "$USER ALL=(ALL) NOPASSWD:ALL" > 90-joid-init
103 if [ -e /etc/sudoers.d/90-joid-init ]; then
104 sudo cp /etc/sudoers.d/90-joid-init 91-joid-init
105 sudo chown $USER:$USER 91-joid-init
106 sudo chmod 660 91-joid-init
107 sudo cat 90-joid-init >> 91-joid-init
108 sudo chown root:root 91-joid-init
109 sudo mv 91-joid-init /etc/sudoers.d/
111 sudo chown root:root 90-joid-init
112 sudo mv 90-joid-init /etc/sudoers.d/
115 echo "... Deployment of maas Started ...."
117 if [ ! -e $HOME/.ssh/id_rsa ]; then
118 ssh-keygen -N '' -f $HOME/.ssh/id_rsa
121 #define the pool and try to start even though its already exist.
122 # For fresh install this may or may not there.
124 sudo apt-get install libvirt-bin -y
125 sudo adduser $USER libvirtd
126 sudo virsh pool-define-as default --type dir --target /var/lib/libvirt/images/ || true
127 sudo virsh pool-start default || true
128 sudo virsh pool-autostart default || true
130 # To avoid problem between apiclient/maas_client and apiclient from google
131 # we remove the package google-api-python-client from yardstick installer
132 if [ $(pip list |grep google-api-python-client |wc -l) == 1 ]; then
133 sudo pip uninstall google-api-python-client
136 sudo pip install shyaml
139 cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
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
150 #Below function will mark the interfaces in Auto mode to enbled by MAAS
152 listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
153 for nodes in $listofnodes
155 maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3
159 #Below function will mark the interfaces in Auto mode to enbled by MAAS
160 # using hostname of the node added into MAAS
162 enableautomodebyname() {
163 if [ ! -z "$4" ]; then
166 nodes=`maas maas nodes list hostname=node$i-$4 | grep system_id | cut -d '"' -f 4`
167 if [ ! -z "$nodes" ]; then
168 maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3
174 #Below function will create vlan and update interface with the new vlan
175 # will return the vlan id created
177 newvlanid=`maas maas vlans create $2 name=$3 vid=$4 | grep resource | cut -d '/' -f 6 `
178 maas maas subnet update $5 vlan=$newvlanid
179 eval "$1"="'$newvlanid'"
182 #Below function will create interface with new vlan and bind to physical interface
184 listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
186 for nodes in $listofnodes
188 parentid=`maas maas interface read $nodes $2 | grep interfaces | cut -d '/' -f 8`
189 maas maas interfaces create-vlan $nodes vlan=$1 parent=$parentid
193 #just make sure the ssh keys added into maas for the current user
194 sed --i "s@/home/ubuntu@$HOME@g" ./deployment.yaml
195 sed --i "s@qemu+ssh://ubuntu@qemu+ssh://$USER@g" ./deployment.yaml
197 cp ./deployment.yaml ~/.juju/
199 if [ -e ./deployconfig.yaml ]; then
200 cp ./deployconfig.yaml ~/.juju/
203 sudo maas-deployer -c deployment.yaml -d --force
205 sudo chown $USER:$USER environments.yaml
207 echo "... Deployment of maas finish ...."
209 maas_ip=`grep " ip_address" deployment.yaml | cut -d ':' -f 2 | sed -e 's/ //'`
210 apikey=`grep maas-oauth: environments.yaml | cut -d "'" -f 2`
211 maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey}
212 maas maas sshkeys new key="`cat $HOME/.ssh/id_rsa.pub`"
214 #Added the Qtip public to run the Qtip test after install on bare metal nodes.
215 maas maas sshkeys new key="`cat ./maas/sshkeys/QtipKey.pub`"
217 #adding compute and control nodes VM to MAAS for deployment purpose.
218 if [ "$virtinstall" -eq 1 ]; then
219 # create two more VMs to do the deployment.
220 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
222 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
224 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
226 node1controlmac=`grep "mac address" node1-control | head -1 | cut -d "'" -f 2`
227 node2computemac=`grep "mac address" node2-compute | head -1 | cut -d "'" -f 2`
228 node5computemac=`grep "mac address" node5-compute | head -1 | cut -d "'" -f 2`
230 sudo virsh -c qemu:///system define --file node1-control
231 sudo virsh -c qemu:///system define --file node2-compute
232 sudo virsh -c qemu:///system define --file node5-compute
234 maas maas tags new name='control'
235 maas maas tags new name='compute'
237 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 `
239 maas maas tag update-nodes control add=$controlnodeid
241 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 `
243 maas maas tag update-nodes compute add=$computenodeid
245 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 `
247 maas maas tag update-nodes compute add=$computenodeid
250 #read interface needed in Auto mode and enable it. Will be rmeoved once auto enablement will be implemented in the maas-deployer.
252 if [ -e ~/.juju/deployconfig.yaml ]; then
253 cp ~/.juju/deployconfig.yaml ./deployconfig.yaml
255 enableiflist=`grep "interface-enable" deployconfig.yaml | cut -d ' ' -f 4 `
256 datanet=`grep "dataNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
257 stornet=`grep "storageNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
258 pubnet=`grep "publicNetwork" deployconfig.yaml | cut -d ' ' -f 4 | sed -e 's/ //'`
260 # split EXTERNAL_NETWORK=first ip;last ip; gateway;network
262 if [ "$datanet" != "''" ]; then
263 EXTNET=(${enableiflist//,/ })
265 while [ ! -z "${EXTNET[i]}" ];
267 enableautomode ${EXTNET[i]} AUTO $datanet || true
271 if [ "$stornet" != "''" ]; then
272 EXTNET=(${enableiflist//,/ })
274 while [ ! -z "${EXTNET[i]}" ];
276 enableautomode ${EXTNET[i]} AUTO $stornet || true
280 if [ "$pubnet" != "''" ]; then
281 EXTNET=(${enableiflist//,/ })
283 while [ ! -z "${EXTNET[i]}" ];
285 enableautomode ${EXTNET[i]} AUTO $pubnet || true
292 # Enable vlan interfaces with maas
296 crvlanupdsubnet vlan902 1 "DataNetwork" 902 2 || true
297 crvlanupdsubnet vlan905 2 "PublicNetwork" 905 3 || true
298 crnodevlanint $vlan902 eth0 || true
299 crnodevlanint $vlan905 eth1 || true
300 enableautomodebyname eth0.902 AUTO "10.9.12.0/24" compute || true
301 enableautomodebyname eth1.905 AUTO "10.9.15.0/24" compute || true
302 enableautomodebyname eth0.902 AUTO "10.9.12.0/24" control || true
303 enableautomodebyname eth1.905 AUTO "10.9.15.0/24" control || true
311 echo " .... MAAS deployment finished successfully ...."