CI/Jenkins stage 2 integration of vim-emu
[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, Paderborn University
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/xenial64"
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/ubuntu/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
112      sudo echo "localhost ansible_connection=local" >> /etc/ansible/hosts
113      # install containernet
114      git clone https://github.com/containernet/containernet.git
115      echo "Installing containernet (will take some time ~30 minutes) ..."
116      cd /home/ubuntu/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/ubuntu/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/ubuntu/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 python3.4 python3-dev python3-pip libyaml-dev build-essential
132      sudo pip install virtualenv 
133      sudo pip install numpy
134      sudo pip install scipy
135
136      # place motd
137      cd /home/ubuntu/son-emu
138      sudo cp utils/vagrant/motd /etc/motd
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
148      sudo docker pull sonatanfv/son-emu-sap
149   SHELL
150
151 end