blob: a3bec025a5e362e448f12d00e43db42759a19fb9 [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
Sergio Slobodrian92136d02017-08-22 21:48:42 -040039# Special actions that differentiate a cluster build from a singel instance build
Sergio Slobodrianff15bef2017-08-24 16:15:08 -040040cp voltha/voltha.production.yml voltha/voltha.yml
41cp ofagent/ofagent.production.yml ofagent/ofagent.yml
42cp netconf/netconf.production.yml netconf/netconf.yml
Sergio Slobodrian92136d02017-08-22 21:48:42 -040043
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040044# Destroy the VM if it's running
Sergio Slobodrian7c483622017-06-13 15:51:34 -040045vagrant destroy voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040046
47# Bring up the VM.
Sergio Slobodrian7c483622017-06-13 15:51:34 -040048vagrant up voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040049
50# Get the VM's ip address
51ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'`
52
Sergio Slobodrian7c483622017-06-13 15:51:34 -040053
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040054# Run all the build commands
Sergio Slobodrian61287792017-06-27 12:14:05 -040055if [ $# -eq 1 -a "$1" == "test" ]; then
56 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \
57 .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \
58 "cd /cord/incubator/voltha && . env.sh && make fetch && make build"
59 rtrn=$?
60else
61 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \
62 .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \
63 "cd /cord/incubator/voltha && . env.sh && make fetch && make production"
64 rtrn=$?
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040065fi
66
Sergio Slobodrian61287792017-06-27 12:14:05 -040067echo "Build return code: $rtrn"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040068
Sergio Slobodrian61287792017-06-27 12:14:05 -040069exit $rtrn
70