2 #placeholder for deployment script.
9 cp maas/intel/pod5/deployment.yaml ./deployment.yaml
12 cp maas/intel/pod6/deployment.yaml ./deployment.yaml
15 cp maas/orange/pod2/deployment.yaml ./deployment.yaml
18 cp maas/att/virpod1/deployment.yaml ./deployment.yaml
21 cp maas/juniper/pod1/deployment.yaml ./deployment.yaml
26 cp maas/default/deployment.yaml ./deployment.yaml
30 #just make sure the ssh keys added into maas for the current user
31 sed --i "s@/home/ubuntu@$HOME@g" ./deployment.yaml
32 sed --i "s@qemu+ssh://ubuntu@qemu+ssh://$USER@g" ./deployment.yaml
34 #make sure no password asked during the deployment.
36 echo "$USER ALL=(ALL) NOPASSWD:ALL" > 90-joid-init
38 if [ -e /etc/sudoers.d/90-joid-init ]; then
39 sudo cp /etc/sudoers.d/90-joid-init 91-joid-init
40 sudo chown $USER:$USER 91-joid-init
41 sudo chmod 660 91-joid-init
42 sudo cat 90-joid-init >> 91-joid-init
43 sudo chown root:root 91-joid-init
44 sudo mv 91-joid-init /etc/sudoers.d/
46 sudo chown root:root 90-joid-init
47 sudo mv 90-joid-init /etc/sudoers.d/
50 echo "... Deployment of maas Started ...."
52 if [ ! -e $HOME/.ssh/id_rsa ]; then
53 ssh-keygen -N '' -f $HOME/.ssh/id_rsa
56 #define the pool and try to start even though its already exist.
57 # For fresh install this may or may not there.
59 sudo apt-get install libvirt-bin -y
60 sudo adduser $USER libvirtd
61 sudo virsh pool-define-as default --type dir --target /var/lib/libvirt/images/ || true
62 sudo virsh pool-start default || true
63 sudo virsh pool-autostart default || true
65 sudo apt-add-repository ppa:maas-deployers/stable -y
66 sudo apt-add-repository ppa:juju/stable -y
67 sudo apt-add-repository ppa:maas/stable -y
68 sudo apt-get update -y
69 sudo apt-get install openssh-server git maas-deployer juju juju-deployer maas-cli python-pip -y
70 sudo pip install shyaml
73 cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
75 if [ "$virtinstall" -eq 1 ]; then
76 sudo virsh net-dumpxml default > default-net-org.xml
77 sudo sed -i '/dhcp/d' default-net-org.xml
78 sudo sed -i '/range/d' default-net-org.xml
79 sudo virsh net-define default-net-org.xml
80 sudo virsh net-destroy default
81 sudo virsh net-start default
84 #Below function will mark the interfaces in Auto mode to enbled by MAAS
86 listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
87 for nodes in $listofnodes
89 maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3
93 #Below function will mark the interfaces in Auto mode to enbled by MAAS
94 # using hostname of the node added into MAAS
96 enableautomodebyname() {
97 if [ ! -z "$4" ]; then
100 nodes=`maas maas nodes list hostname=node$i-$4 | grep system_id | cut -d '"' -f 4`
101 if [ ! -z "$nodes" ]; then
102 maas maas interface link-subnet $nodes $1 mode=$2 subnet=$3
108 #Below function will create vlan and update interface with the new vlan
109 # will return the vlan id created
111 newvlanid=`maas maas vlans create $2 name=$3 vid=$4 | grep resource | cut -d '/' -f 6 `
112 maas maas subnet update $5 vlan=$newvlanid
113 eval "$1"="'$newvlanid'"
116 #Below function will create interface with new vlan and bind to physical interface
118 listofnodes=`maas maas nodes list | grep system_id | cut -d '"' -f 4`
120 for nodes in $listofnodes
122 parentid=`maas maas interface read $nodes eth2 | grep interfaces | cut -d '/' -f 8`
123 maas maas interfaces create-vlan $nodes vlan=$1 parent=$parentid
127 sudo maas-deployer -c deployment.yaml -d --force
129 sudo chown $USER:$USER environments.yaml
131 echo "... Deployment of maas finish ...."
133 maas_ip=`grep " ip_address" deployment.yaml | cut -d " " -f 10`
134 apikey=`grep maas-oauth: environments.yaml | cut -d "'" -f 2`
135 maas login maas http://${maas_ip}/MAAS/api/1.0 ${apikey}
136 maas maas boot-source update 1 url="http://maas.ubuntu.com/images/ephemeral-v2/daily/"
137 #maas maas boot-source-selections create 1 os="ubuntu" release="precise" arches="amd64" subarches="*" labels="*"
138 maas maas node-groups import-boot-images
139 maas maas sshkeys new key="`cat $HOME/.ssh/id_rsa.pub`"
141 #Added the Qtip public to run the Qtip test after install on bare metal nodes.
142 maas maas sshkeys new key="`cat ./maas/sshkeys/QtipKey.pub`"
144 #adding compute and control nodes VM to MAAS for deployment purpose.
145 if [ "$virtinstall" -eq 1 ]; then
146 # create two more VMs to do the deployment.
147 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
149 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
151 node1controlmac=`grep "mac address" node1-control | head -1 | cut -d "'" -f 2`
152 node2computemac=`grep "mac address" node2-compute | head -1 | cut -d "'" -f 2`
154 sudo virsh -c qemu:///system define --file node1-control
155 sudo virsh -c qemu:///system define --file node2-compute
157 maas maas tags new name='control'
158 maas maas tags new name='compute'
160 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 `
162 maas maas tag update-nodes control add=$controlnodeid
164 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 `
166 maas maas tag update-nodes compute add=$computenodeid
170 # Enable vlan interfaces with maas
174 crvlanupdsubnet vlan721 1 "DataNetwork" 721 2 || true
175 crvlanupdsubnet vlan724 2 "PublicNetwork" 724 3 || true
176 crnodevlanint $vlan721 || true
177 crnodevlanint $vlan724 || true
178 enableautomodebyname eth2.721 AUTO "10.4.9.0/24" compute || true
179 enableautomodebyname eth2.721 AUTO "10.4.9.0/24" control || true
183 enableautomodebyname eth1 AUTO "10.4.9.0/24" compute || true
184 enableautomodebyname eth1 AUTO "10.4.9.0/24" control || true
188 enableautomodebyname eth4 AUTO "192.168.22.0/24" compute || true
189 enableautomodebyname eth5 AUTO "192.168.12.0/24" compute || true
190 enableautomodebyname eth2 AUTO "192.168.22.0/24" control || true
191 enableautomodebyname eth3 AUTO "192.168.12.0/24" control || true
199 echo " .... MAAS deployment finished successfully ...."
201 #echo "... Deployment of opnfv release Started ...."
202 #python deploy.py $maas_ip