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 |
Sergio Slobodrian | ff15bef | 2017-08-24 16:15:08 -0400 | [diff] [blame] | 40 | cp voltha/voltha.production.yml voltha/voltha.yml |
| 41 | cp ofagent/ofagent.production.yml ofagent/ofagent.yml |
| 42 | cp netconf/netconf.production.yml netconf/netconf.yml |
Sergio Slobodrian | 3775a26 | 2017-08-30 10:43:40 -0400 | [diff] [blame] | 43 | cp chameleon/chameleon.production.yml chameleon/chameleon.yml |
Sergio Slobodrian | 92136d0 | 2017-08-22 21:48:42 -0400 | [diff] [blame] | 44 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 45 | # Destroy the VM if it's running |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 46 | vagrant destroy voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 47 | |
| 48 | # Bring up the VM. |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 49 | vagrant up voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 50 | |
| 51 | # Get the VM's ip address |
| 52 | ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'` |
| 53 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 54 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 55 | # Run all the build commands |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 56 | if [ $# -eq 1 -a "$1" == "test" ]; then |
| 57 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 58 | .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
| 59 | "cd /cord/incubator/voltha && . env.sh && make fetch && make build" |
| 60 | rtrn=$? |
| 61 | else |
| 62 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 63 | .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
| 64 | "cd /cord/incubator/voltha && . env.sh && make fetch && make production" |
| 65 | rtrn=$? |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 66 | fi |
| 67 | |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 68 | echo "Build return code: $rtrn" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 69 | |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 70 | exit $rtrn |
| 71 | |