| peusterm | c89ba38 | 2016-07-08 13:46:32 +0200 | [diff] [blame] | 1 | # 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 | |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 27 | # -*- mode: ruby -*- |
| 28 | # vi: set ft=ruby : |
| 29 | |
| 30 | # |
| 31 | # This Vagrant file create a son-emu VM. |
| 32 | # |
| peusterm | 1f29159 | 2016-06-08 18:23:45 +0900 | [diff] [blame] | 33 | # |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 34 | # 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. |
| 38 | Vagrant.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 |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 50 | config.vm.box = "ubuntu/xenial64" |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 51 | |
| 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. |
| peusterm | fe95083 | 2016-08-18 16:03:32 +0200 | [diff] [blame] | 61 | config.vm.network "forwarded_port", guest: 5000, host: 5000 # dummy gatekeeper |
| 62 | config.vm.network "forwarded_port", guest: 5001, host: 5001 # REST API |
| stevenvanrossem | e50b0a7 | 2016-08-18 17:42:50 +0200 | [diff] [blame] | 63 | config.vm.network "forwarded_port", guest: 8081, host: 8081 # cAdvisor |
| peusterm | fe95083 | 2016-08-18 16:03:32 +0200 | [diff] [blame] | 64 | config.vm.network "forwarded_port", guest: 9091, host: 9091 # push gateway |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 65 | |
| 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 |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 80 | config.vm.synced_folder ".", "/home/ubuntu/son-emu" |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 81 | |
| 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 |
| peusterm | cdda1f6 | 2016-06-09 09:58:09 +0900 | [diff] [blame] | 110 | sudo apt-get update |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 111 | sudo apt-get install -y git ansible |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 112 | sudo echo "localhost ansible_connection=local" >> /etc/ansible/hosts |
| 113 | # install containernet |
| peusterm | 9cdb3f7 | 2017-01-04 09:55:26 +0100 | [diff] [blame] | 114 | git clone https://github.com/containernet/containernet.git |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 115 | echo "Installing containernet (will take some time ~30 minutes) ..." |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 116 | cd /home/ubuntu/containernet/ansible |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 117 | sudo ansible-playbook install.yml |
| 118 | |
| 119 | # install son-emu |
| 120 | echo "Installing son-emu (will take some time) ..." |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 121 | cd /home/ubuntu/son-emu/ansible |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 122 | 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" |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 126 | cd /home/ubuntu/son-emu |
| peusterm | cdda1f6 | 2016-06-09 09:58:09 +0900 | [diff] [blame] | 127 | sudo python setup.py develop |
| peusterm | dedcaf7 | 2016-08-19 15:07:18 +0200 | [diff] [blame] | 128 | sudo py.test -v src/emuvim/test/unittests |
| 129 | |
| 130 | # install son-cli |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 131 | sudo apt-get install -y python3.4 python3-dev python3-pip libyaml-dev build-essential |
| peusterm | dedcaf7 | 2016-08-19 15:07:18 +0200 | [diff] [blame] | 132 | sudo pip install virtualenv |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 133 | sudo pip install numpy |
| 134 | sudo pip install scipy |
| peusterm | c888c12 | 2016-08-23 15:04:39 +0200 | [diff] [blame] | 135 | |
| 136 | # place motd |
| peusterm | c5109ad | 2017-03-09 15:38:51 +0100 | [diff] [blame] | 137 | cd /home/ubuntu/son-emu |
| peusterm | c888c12 | 2016-08-23 15:04:39 +0200 | [diff] [blame] | 138 | sudo cp utils/vagrant/motd /etc/motd |
| peusterm | dedcaf7 | 2016-08-19 15:07:18 +0200 | [diff] [blame] | 139 | |
| 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 |
| peusterm | 9984dba | 2016-08-23 15:23:23 +0200 | [diff] [blame] | 148 | sudo docker pull sonatanfv/son-emu-sap |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 149 | SHELL |
| 150 | |
| peusterm | 0f52fc1 | 2016-06-08 17:55:04 +0900 | [diff] [blame] | 151 | end |