blob: 383e2460d3672cff328fe9738492fe6165f034cb [file] [log] [blame]
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -04001#!/bin/bash
Zack Williams41513bf2018-07-07 20:08:35 -07002# 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 Slobodrianee4b2bc2017-06-05 10:08:59 -040015
Sergio Slobodrian7c483622017-06-13 15:51:34 -040016uId=`id -u`
17vmName="voltha_voltha${uId}"
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040018
19# Voltha directory
20cd ..
21
Sergio Slobodrian36e16552017-06-19 11:00:45 -040022# Blow away the settings file, we're going to set all the settings below
23rm -f settings.vagrant.yaml
24
Sergio Slobodrian7c483622017-06-13 15:51:34 -040025# Rename voltha for multi-user support
Sergio Slobodrian36e16552017-06-19 11:00:45 -040026echo "---" > settings.vagrant.yaml
27echo "# The name to use for the server" >> settings.vagrant.yaml
28echo 'server_name: "voltha'${uId}'"' >> settings.vagrant.yaml
29# Make sure that we're using KVM and not virtualbox
30echo '# Use KVM as the VM provider' >> settings.vagrant.yaml
31echo 'vProvider: "KVM"' >> settings.vagrant.yaml
32echo '# Use virtualbox as the VM provider' >> settings.vagrant.yaml
33echo '#vProvider: "virtualbox"' >> settings.vagrant.yaml
34# Build voltha in the specified mode if any
Sergio Slobodrian7c483622017-06-13 15:51:34 -040035if [ $# -eq 1 -a "$1" == "test" ]; then
Sergio Slobodrian36e16552017-06-19 11:00:45 -040036 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
40elif [ $# -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
45else
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 Slobodrian7c483622017-06-13 15:51:34 -040050fi
51
khenaidoo50b286d2018-03-02 17:44:30 -050052# 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 Slobodrian92136d02017-08-22 21:48:42 -040060
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040061# Destroy the VM if it's running
Sergio Slobodrian7c483622017-06-13 15:51:34 -040062vagrant destroy voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040063
64# Bring up the VM.
Sergio Slobodrian7c483622017-06-13 15:51:34 -040065vagrant up voltha${uId}
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040066
67# Get the VM's ip address
68ipAddr=`virsh domifaddr $vmName | tail -n +3 | awk '{ print $4 }' | sed -e 's~/.*~~'`
69
Sergio Slobodrian7c483622017-06-13 15:51:34 -040070
Sergio Slobodrianee4b2bc2017-06-05 10:08:59 -040071# Run all the build commands
Sergio Slobodrian61287792017-06-27 12:14:05 -040072if [ $# -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=$?
77else
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 Slobodrianba9cbd82017-06-22 11:45:49 -040082fi
83
Sergio Slobodrian61287792017-06-27 12:14:05 -040084echo "Build return code: $rtrn"
Sergio Slobodrianba9cbd82017-06-22 11:45:49 -040085
Sergio Slobodrian61287792017-06-27 12:14:05 -040086exit $rtrn
87