blob: 0247409fb1166c071289b01740075f83d936f014 [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
40mv voltha/voltha.production.yml voltha/voltha.yml
41
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040042# Destroy the VM if it's running
Sergio Slobodrian7c483622017-06-13 15:51:34 -040043vagrant destroy voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040044
45# Bring up the VM.
Sergio Slobodrian7c483622017-06-13 15:51:34 -040046vagrant up voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040047
48# Get the VM's ip address
49ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'`
50
Sergio Slobodrian7c483622017-06-13 15:51:34 -040051
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040052# Run all the build commands
Sergio Slobodrian61287792017-06-27 12:14:05 -040053if [ $# -eq 1 -a "$1" == "test" ]; then
54 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \
55 .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \
56 "cd /cord/incubator/voltha && . env.sh && make fetch && make build"
57 rtrn=$?
58else
59 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i \
60 .vagrant/machines/voltha${uId}/libvirt/private_key vagrant@$ipAddr \
61 "cd /cord/incubator/voltha && . env.sh && make fetch && make production"
62 rtrn=$?
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040063fi
64
Sergio Slobodrian61287792017-06-27 12:14:05 -040065echo "Build return code: $rtrn"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040066
Sergio Slobodrian61287792017-06-27 12:14:05 -040067exit $rtrn
68