Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Zack Williams | 41513bf | 2018-07-07 20:08:35 -0700 | [diff] [blame] | 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 15 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 16 | uId=`id -u` |
| 17 | vmName="voltha_voltha${uId}" |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 18 | |
| 19 | # Voltha directory |
| 20 | cd .. |
| 21 | |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 22 | # Blow away the settings file, we're going to set all the settings below |
| 23 | rm -f settings.vagrant.yaml |
| 24 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 25 | # Rename voltha for multi-user support |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 26 | echo "---" > settings.vagrant.yaml |
| 27 | echo "# The name to use for the server" >> settings.vagrant.yaml |
| 28 | echo 'server_name: "voltha'${uId}'"' >> settings.vagrant.yaml |
| 29 | # Make sure that we're using KVM and not virtualbox |
| 30 | echo '# Use KVM as the VM provider' >> settings.vagrant.yaml |
| 31 | echo 'vProvider: "KVM"' >> settings.vagrant.yaml |
| 32 | echo '# Use virtualbox as the VM provider' >> settings.vagrant.yaml |
| 33 | echo '#vProvider: "virtualbox"' >> settings.vagrant.yaml |
| 34 | # Build voltha in the specified mode if any |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 35 | if [ $# -eq 1 -a "$1" == "test" ]; then |
Sergio Slobodrian | 36e1655 | 2017-06-19 11:00:45 -0400 | [diff] [blame] | 36 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 37 | echo 'testMode: "true"' >> settings.vagrant.yaml |
| 38 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 39 | echo 'installMode: "false"' >> settings.vagrant.yaml |
| 40 | elif [ $# -eq 1 -a "$1" == "install" ]; then |
| 41 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 42 | echo 'installMode: "true"' >> settings.vagrant.yaml |
| 43 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 44 | echo 'testMode: "false"' >> settings.vagrant.yaml |
| 45 | else |
| 46 | echo '# This determines if installer mode is active' >> settings.vagrant.yaml |
| 47 | echo 'installMode: "false"' >> settings.vagrant.yaml |
| 48 | echo '# This determines if test mode is active' >> settings.vagrant.yaml |
| 49 | echo 'testMode: "false"' >> settings.vagrant.yaml |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 50 | fi |
| 51 | |
khenaidoo | 50b286d | 2018-03-02 17:44:30 -0500 | [diff] [blame] | 52 | # This was required before as logging was different in production vs development. The |
| 53 | # logging decision was made at compile time. |
| 54 | # By using the docker logging option (docker swarm mode only) in the deployment |
| 55 | # files, now the logging decision is made at deployment time, hence the same voltha, |
| 56 | # netconf and ofagent images can be used both in development and production. |
| 57 | #cp voltha/voltha.production.yml voltha/voltha.yml |
| 58 | #cp ofagent/ofagent.production.yml ofagent/ofagent.yml |
| 59 | #cp netconf/netconf.production.yml netconf/netconf.yml |
Sergio Slobodrian | 92136d0 | 2017-08-22 21:48:42 -0400 | [diff] [blame] | 60 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 61 | # Destroy the VM if it's running |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 62 | vagrant destroy voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 63 | |
| 64 | # Bring up the VM. |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 65 | vagrant up voltha${uId} |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 66 | |
| 67 | # Get the VM's ip address |
| 68 | ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'` |
| 69 | |
Sergio Slobodrian | 7c48362 | 2017-06-13 15:51:34 -0400 | [diff] [blame] | 70 | |
Sergio Slobodrian | ee4b2bc | 2017-06-05 10:08:59 -0400 | [diff] [blame] | 71 | # Run all the build commands |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 72 | if [ $# -eq 1 -a "$1" == "test" ]; then |
| 73 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 74 | .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
| 75 | "cd /cord/incubator/voltha && . env.sh && make fetch && make build" |
| 76 | rtrn=$? |
| 77 | else |
| 78 | ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \ |
| 79 | .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \ |
| 80 | "cd /cord/incubator/voltha && . env.sh && make fetch && make production" |
| 81 | rtrn=$? |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 82 | fi |
| 83 | |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 84 | echo "Build return code: $rtrn" |
Sergio Slobodrian | ba9cbd8 | 2017-06-22 11:45:49 -0400 | [diff] [blame] | 85 | |
Sergio Slobodrian | 6128779 | 2017-06-27 12:14:05 -0400 | [diff] [blame] | 86 | exit $rtrn |
| 87 | |