blob: 5e1f6af8be3a68a9248a033c0a45df9fae06b92a [file] [log] [blame]
peustermc89ba382016-07-08 13:46:32 +02001# Copyright (c) 2015 SONATA-NFV and Paderborn University
2# ALL RIGHTS RESERVED.
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.
15#
16# Neither the name of the SONATA-NFV [, ANY ADDITIONAL AFFILIATION]
17# nor the names of its contributors may be used to endorse or promote
18# products derived from this software without specific prior written
19# permission.
20#
21# This work has been performed in the framework of the SONATA project,
22# funded by the European Commission under Grant number 671517 through
23# the Horizon 2020 and 5G-PPP programmes. The authors would like to
24# acknowledge the contributions of their colleagues of the SONATA
25# partner consortium (www.sonata-nfv.eu).
26
peusterm0f52fc12016-06-08 17:55:04 +090027# -*- mode: ruby -*-
28# vi: set ft=ruby :
29
30#
31# This Vagrant file create a son-emu VM.
32#
peusterm1f291592016-06-08 18:23:45 +090033#
peusterm0f52fc12016-06-08 17:55:04 +090034# All Vagrant configuration is done below. The "2" in Vagrant.configure
35# configures the configuration version (we support older styles for
36# backwards compatibility). Please don't change it unless you know what
37# you're doing.
38Vagrant.configure(2) do |config|
39 # The most common configuration options are documented and commented below.
40 # For a complete reference, please see the online documentation at
41 # https://docs.vagrantup.com.
42
43 # Every Vagrant development environment requires a box. You can search for
44 # boxes at https://atlas.hashicorp.com/search.
45
46 # there is a bug in the /etc/hosts of 16.04: https://bugs.launchpad.net/ubuntu/+source/livecd-rootfs/+bug/1561250
47 #config.vm.box = "ubuntu/xenial64"
48
49 # so we use 14.04 for now
peustermc5109ad2017-03-09 15:38:51 +010050 config.vm.box = "ubuntu/xenial64"
peusterm0f52fc12016-06-08 17:55:04 +090051
52
53 # Disable automatic box update checking. If you disable this, then
54 # boxes will only be checked for updates when the user runs
55 # `vagrant box outdated`. This is not recommended.
56 # config.vm.box_check_update = false
57
58 # Create a forwarded port mapping which allows access to a specific port
59 # within the machine from a port on the host machine. In the example below,
60 # accessing "localhost:8080" will access port 80 on the guest machine.
peustermfe950832016-08-18 16:03:32 +020061 config.vm.network "forwarded_port", guest: 5000, host: 5000 # dummy gatekeeper
62 config.vm.network "forwarded_port", guest: 5001, host: 5001 # REST API
stevenvanrosseme50b0a72016-08-18 17:42:50 +020063 config.vm.network "forwarded_port", guest: 8081, host: 8081 # cAdvisor
peustermfe950832016-08-18 16:03:32 +020064 config.vm.network "forwarded_port", guest: 9091, host: 9091 # push gateway
peusterm0f52fc12016-06-08 17:55:04 +090065
66 # Create a private network, which allows host-only access to the machine
67 # using a specific IP.
68 # config.vm.network "private_network", ip: "192.168.33.10"
69
70 # Create a public network, which generally matched to bridged network.
71 # Bridged networks make the machine appear as another physical device on
72 # your network.
73 # config.vm.network "public_network"
74
75 # Share an additional folder to the guest VM. The first argument is
76 # the path on the host to the actual folder. The second argument is
77 # the path on the guest to mount the folder. And the optional third
78 # argument is a set of non-required options.
79 config.vm.synced_folder ".", "/vagrant", disabled: true
peustermc5109ad2017-03-09 15:38:51 +010080 config.vm.synced_folder ".", "/home/ubuntu/son-emu"
peusterm0f52fc12016-06-08 17:55:04 +090081
82
83 # Provider-specific configuration so you can fine-tune various
84 # backing providers for Vagrant. These expose provider-specific options.
85 # Example for VirtualBox:
86 #
87 config.vm.provider "virtualbox" do |vb|
88 vb.name = "son-emu"
89 # # Display the VirtualBox GUI when booting the machine
90 # vb.gui = true
91 #
92 # # Customize the amount of memory on the VM:
93 vb.memory = "1024"
94 end
95 #
96 # View the documentation for the provider you are using for more
97 # information on available options.
98
99 # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
100 # such as FTP and Heroku are also available. See the documentation at
101 # https://docs.vagrantup.com/v2/push/atlas.html for more information.
102 # config.push.define "atlas" do |push|
103 # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
104 # end
105
106 # Enable provisioning with a shell script. Additional provisioners such as
107 # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
108 # documentation for more information about their specific syntax and use.
109 config.vm.provision "shell", inline: <<-SHELL
peustermcdda1f62016-06-09 09:58:09 +0900110 sudo apt-get update
peustermc5109ad2017-03-09 15:38:51 +0100111 sudo apt-get install -y git ansible
peusterm0f52fc12016-06-08 17:55:04 +0900112 sudo echo "localhost ansible_connection=local" >> /etc/ansible/hosts
113 # install containernet
peusterm9cdb3f72017-01-04 09:55:26 +0100114 git clone https://github.com/containernet/containernet.git
peusterm0f52fc12016-06-08 17:55:04 +0900115 echo "Installing containernet (will take some time ~30 minutes) ..."
peustermc5109ad2017-03-09 15:38:51 +0100116 cd /home/ubuntu/containernet/ansible
peusterm0f52fc12016-06-08 17:55:04 +0900117 sudo ansible-playbook install.yml
118
119 # install son-emu
120 echo "Installing son-emu (will take some time) ..."
peustermc5109ad2017-03-09 15:38:51 +0100121 cd /home/ubuntu/son-emu/ansible
peusterm0f52fc12016-06-08 17:55:04 +0900122 sudo ansible-playbook install.yml
123
124 # execute son-emu tests at the end to validate installation
125 echo "Running son-emu unit tests to validate installation"
peustermc5109ad2017-03-09 15:38:51 +0100126 cd /home/ubuntu/son-emu
peustermcdda1f62016-06-09 09:58:09 +0900127 sudo python setup.py develop
peustermdedcaf72016-08-19 15:07:18 +0200128 sudo py.test -v src/emuvim/test/unittests
129
130 # install son-cli
peustermc5109ad2017-03-09 15:38:51 +0100131 sudo apt-get install -y python3.4 python3-dev python3-pip libyaml-dev build-essential
peustermdedcaf72016-08-19 15:07:18 +0200132 sudo pip install virtualenv
peustermc5109ad2017-03-09 15:38:51 +0100133 sudo pip install numpy
134 sudo pip install scipy
peustermc888c122016-08-23 15:04:39 +0200135
136 # place motd
peustermc5109ad2017-03-09 15:38:51 +0100137 cd /home/ubuntu/son-emu
peustermc888c122016-08-23 15:04:39 +0200138 sudo cp utils/vagrant/motd /etc/motd
peustermdedcaf72016-08-19 15:07:18 +0200139
140 # pre-fetch sonata example vnfs from DockerHub
141 echo "Fetching SONATA example VNF container from DockerHub/sonatanfv"
142 sudo docker pull sonatanfv/sonata-empty-vnf
143 sudo docker pull sonatanfv/sonata-iperf3-vnf
144 sudo docker pull sonatanfv/sonata-snort-ids-vnf
145 sudo docker pull sonatanfv/sonata-ovs1-vnf
146 sudo docker pull sonatanfv/sonata-ryu-vnf
147 sudo docker pull sonatanfv/sonata-vtc-vnf
peusterm9984dba2016-08-23 15:23:23 +0200148 sudo docker pull sonatanfv/son-emu-sap
peusterm0f52fc12016-06-08 17:55:04 +0900149 SHELL
150
peusterm0f52fc12016-06-08 17:55:04 +0900151end