blob: 6b837860b04cb83167844ee7094f92e7b3918b2f [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 Slobodrian3775a262017-08-30 10:43:40 -040043cp chameleon/chameleon.production.yml chameleon/chameleon.yml
Sergio Slobodrian92136d02017-08-22 21:48:42 -040044
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040045# Destroy the VM if it's running
Sergio Slobodrian7c483622017-06-13 15:51:34 -040046vagrant destroy voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040047
48# Bring up the VM.
Sergio Slobodrian7c483622017-06-13 15:51:34 -040049vagrant up voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040050
51# Get the VM's ip address
52ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'`
53
Sergio Slobodrian7c483622017-06-13 15:51:34 -040054
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040055# Run all the build commands
Sergio Slobodrian61287792017-06-27 12:14:05 -040056if [ $# -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=$?
61else
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 Slobodrianba9cbd82017-06-22 11:45:49 -040066fi
67
Sergio Slobodrian61287792017-06-27 12:14:05 -040068echo "Build return code: $rtrn"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040069
Sergio Slobodrian61287792017-06-27 12:14:05 -040070exit $rtrn
71