Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 3 | uId=`id -u` |
| 4 | vmName="voltha_voltha${uId}" |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 5 | |
| 6 | # Voltha directory |
| 7 | cd .. |
| 8 | |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 9 | # Blow away the settings file, we're going to set all the settings below |
| 10 | rm -f settings.vagrant.yaml |
| 11 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 12 | # Rename voltha for multi-user support |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 13 | echo "---" > settings.vagrant.yaml |
| 14 | echo "# The name to use for the server" >> settings.vagrant.yaml |
| 15 | echo 'server_name: "voltha'${uId}'"' >> settings.vagrant.yaml |
| 16 | # Make sure that we're using KVM and not virtualbox |
| 17 | echo '# Use KVM as the VM provider' >> settings.vagrant.yaml |
| 18 | echo 'vProvider: "KVM"' >> settings.vagrant.yaml |
| 19 | echo '# Use virtualbox as the VM provider' >> settings.vagrant.yaml |
| 20 | echo '#vProvider: "virtualbox"' >> settings.vagrant.yaml |
| 21 | # Build voltha in the specified mode if any |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 22 | if [ $# -eq 1 -a "$1" == "test" ]; then |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 23 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 24 | echo 'testMode: "true"' >> settings.vagrant.yaml |
| 25 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 26 | echo 'installMode: "false"' >> settings.vagrant.yaml |
| 27 | elif [ $# -eq 1 -a "$1" == "install" ]; then |
| 28 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 29 | echo 'installMode: "true"' >> settings.vagrant.yaml |
| 30 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 31 | echo 'testMode: "false"' >> settings.vagrant.yaml |
| 32 | else |
| 33 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 34 | echo 'installMode: "false"' >> settings.vagrant.yaml |
| 35 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 36 | echo 'testMode: "false"' >> settings.vagrant.yaml |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 37 | fi |
| 38 | |
Sergio Slobodrian | 92136d0 | 2017-08-22 21:48:42 -0400 | [diff] [blame] | 39 | # Special actions that differentiate a cluster build from a singel instance build |
| 40 | mv voltha/voltha.production.yml voltha/voltha.yml |
| 41 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 42 | # Destroy the VM if it's running |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 43 | vagrant destroy voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 44 | |
| 45 | # Bring up the VM. |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 46 | vagrant up voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 47 | |
| 48 | # Get the VM's ip address |
| 49 | ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'` |
| 50 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 51 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 52 | # Run all the build commands |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 53 | if [ $# -eq 1 -a "$1" == "test" ]; then |
| 54 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 55 | .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
| 56 | "cd /cord/incubator/voltha && . env.sh && make fetch && make build" |
| 57 | rtrn=$? |
| 58 | else |
| 59 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 60 | .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
| 61 | "cd /cord/incubator/voltha && . env.sh && make fetch && make production" |
| 62 | rtrn=$? |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 63 | fi |
| 64 | |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 65 | echo "Build return code: $rtrn" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 66 | |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 67 | exit $rtrn |
| 68 | |