blob: 4d589c954fde731d32dbd754c2aeacd1882b13e8 [file] [log] [blame]
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -04001#!/bin/bash
2
Sergio Slobodrian7c483622017-06-13 15:51:34 -04003uId=`id -u`
4vmName="voltha_voltha${uId}"
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -04005
6# Voltha directory
7cd ..
8
Sergio Slobodrian36e16552017-06-19 11:00:45 -04009# Blow away the settings file, we're going to set all the settings below
10rm -f settings.vagrant.yaml
11
Sergio Slobodrian7c483622017-06-13 15:51:34 -040012# Rename voltha for multi-user support
Sergio Slobodrian36e16552017-06-19 11:00:45 -040013echo "---" > settings.vagrant.yaml
14echo "# The name to use for the server" >> settings.vagrant.yaml
15echo 'server_name: "voltha'${uId}'"' >> settings.vagrant.yaml
16# Make sure that we're using KVM and not virtualbox
17echo '# Use KVM as the VM provider' >> settings.vagrant.yaml
18echo 'vProvider: "KVM"' >> settings.vagrant.yaml
19echo '# Use virtualbox as the VM provider' >> settings.vagrant.yaml
20echo '#vProvider: "virtualbox"' >> settings.vagrant.yaml
21# Build voltha in the specified mode if any
Sergio Slobodrian7c483622017-06-13 15:51:34 -040022if [ $# -eq 1 -a "$1" == "test" ]; then
Sergio Slobodrian36e16552017-06-19 11:00:45 -040023 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
27elif [ $# -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
32else
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 Slobodrian7c483622017-06-13 15:51:34 -040037fi
38
khenaidoo50b286d2018-03-02 17:44:30 -050039# 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 Slobodrian92136d02017-08-22 21:48:42 -040047
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040048# Destroy the VM if it's running
Sergio Slobodrian7c483622017-06-13 15:51:34 -040049vagrant destroy voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040050
51# Bring up the VM.
Sergio Slobodrian7c483622017-06-13 15:51:34 -040052vagrant up voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040053
54# Get the VM's ip address
55ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'`
56
Sergio Slobodrian7c483622017-06-13 15:51:34 -040057
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040058# Run all the build commands
Sergio Slobodrian61287792017-06-27 12:14:05 -040059if [ $# -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=$?
64else
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 Slobodrianba9cbd82017-06-22 11:45:49 -040069fi
70
Sergio Slobodrian61287792017-06-27 12:14:05 -040071echo "Build return code: $rtrn"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040072
Sergio Slobodrian61287792017-06-27 12:14:05 -040073exit $rtrn
74