update to use latest docker api version
[osm/vim-emu.git] / Vagrantfile
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
27 # -*- mode: ruby -*-
28 # vi: set ft=ruby :
29
30 #
31 # This Vagrant file create a son-emu VM.
32 #
33 #
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
50   config.vm.box = "ubuntu/trusty64"
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.
61   config.vm.network "forwarded_port", guest: 5000, host: 5000 # dummy gatekeeper
62   config.vm.network "forwarded_port", guest: 5001, host: 5001 # REST API
63   config.vm.network "forwarded_port", guest: 8081, host: 8081 # cAdvisor
64   config.vm.network "forwarded_port", guest: 9091, host: 9091 # push gateway
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
80   config.vm.synced_folder ".", "/home/vagrant/son-emu"
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
110      sudo apt-get update
111      sudo apt-get install -y git ansible aptitude
112      sudo echo "localhost ansible_connection=local" >> /etc/ansible/hosts
113      # install containernet
114      git clone https://github.com/mpeuster/containernet.git
115      echo "Installing containernet (will take some time ~30 minutes) ..."
116      cd /home/vagrant/containernet/ansible
117      sudo ansible-playbook install.yml
118
119      # install son-emu
120      echo "Installing son-emu (will take some time) ..."
121      cd /home/vagrant/son-emu/ansible
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"
126      cd /home/vagrant/son-emu
127      sudo python setup.py develop
128      sudo py.test -v src/emuvim/test/unittests
129
130      # install son-cli
131      sudo apt-get install -y python-pip python-dev
132      sudo apt-get install -y python3.4 python3-dev libffi-dev libssl-dev libyaml-dev build-essential
133      sudo pip install virtualenv 
134      cd /home/vagrant
135      git clone https://github.com/sonata-nfv/son-cli.git
136      cd son-cli
137      virtualenv -p /usr/bin/python3.4 venv
138      source venv/bin/activate
139      python bootstrap.py
140      bin/buildout
141
142      # clone son-examples (disabled until repo goes public)
143      cd /home/vagrant
144      git clone https://github.com/sonata-nfv/son-examples.git
145
146      # prepare VM for some special containers (PF_RING)
147      cd /home/vagrant/son-examples/vnfs/sonata-vtc-vnf-docker/
148      chmod +x prepare_host.sh
149      sudo ./prepare_host.sh
150
151      # place motd
152      cd /home/vagrant/son-emu
153      sudo cp utils/vagrant/motd /etc/motd
154
155      # pre-fetch sonata example vnfs from DockerHub
156      echo "Fetching SONATA example VNF container from DockerHub/sonatanfv"
157      sudo docker pull sonatanfv/sonata-empty-vnf 
158      sudo docker pull sonatanfv/sonata-iperf3-vnf 
159      sudo docker pull sonatanfv/sonata-snort-ids-vnf
160      sudo docker pull sonatanfv/sonata-ovs1-vnf
161      sudo docker pull sonatanfv/sonata-ryu-vnf
162      sudo docker pull sonatanfv/sonata-vtc-vnf
163      sudo docker pull sonatanfv/son-emu-sap
164   SHELL
165
166   # TODO the native ansible provisioner does not work so we directly call the shell commands
167   # install containernet using its ansible script
168   #config.vm.provision "ansible_local" do |ansible|
169   #  ansible.provisioning_path = "/home/vagrant/containernet/ansible"
170   #  ansible.playbook = "install.yml"
171   #  ansible.sudo = true
172   #  ansible.verbose = "v"
173   #  ansible.limit = "all"
174   #end
175 end