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 | |
khenaidoo | 50b286d | 2018-03-02 17:44:30 -0500 | [diff] [blame] | 39 | # This was required before as logging was different in production vs development. The |
| 40 | # logging decision was made at compile time. |
| 41 | # By using the docker logging option (docker swarm mode only) in the deployment |
| 42 | # files, now the logging decision is made at deployment time, hence the same voltha, |
| 43 | # netconf and ofagent images can be used both in development and production. |
| 44 | #cp voltha/voltha.production.yml voltha/voltha.yml |
| 45 | #cp ofagent/ofagent.production.yml ofagent/ofagent.yml |
| 46 | #cp netconf/netconf.production.yml netconf/netconf.yml |
Sergio Slobodrian | 92136d0 | 2017-08-22 21:48:42 -0400 | [diff] [blame] | 47 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 48 | # Destroy the VM if it's running |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 49 | vagrant destroy voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 50 | |
| 51 | # Bring up the VM. |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 52 | vagrant up voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 53 | |
| 54 | # Get the VM's ip address |
| 55 | ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'` |
| 56 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 57 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 58 | # Run all the build commands |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 59 | if [ $# -eq 1 -a "$1" == "test" ]; then |
| 60 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 61 | .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
| 62 | "cd /cord/incubator/voltha && . env.sh && make fetch && make build" |
| 63 | rtrn=$? |
| 64 | else |
| 65 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 66 | .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
| 67 | "cd /cord/incubator/voltha && . env.sh && make fetch && make production" |
| 68 | rtrn=$? |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 69 | fi |
| 70 | |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 71 | echo "Build return code: $rtrn" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 72 | |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 73 | exit $rtrn |
| 74 | |