apply checkstyle check during build for neutron-mapper
[groupbasedpolicy.git] / demos / vpp-demo / Vagrantfile
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5
6 #     http://www.apache.org/licenses/LICENSE-2.0
7
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 # -*- mode: ruby -*-
15 # vi: set ts=2 sw=2 sts=2 et ft=ruby :
16
17 def add_compute(config, name, mgmt_ip, port1, port2)
18   config.vm.box_check_update = false
19   config.vbguest.auto_update = true
20   config.vm.define name do |node|
21     if Vagrant.has_plugin?("vagrant-proxyconf")
22       if ENV["http_proxy"]
23         config.proxy.http     = ENV["http_proxy"]
24       end
25       if ENV["https_proxy"]
26         config.proxy.https    = ENV["https_proxy"]
27       end
28       if ENV["no_proxy"]
29         config.proxy.no_proxy = ENV["no_proxy"]
30       end
31     end
32     node.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
33     node.vm.hostname = name
34     node.vm.provision "shell", path: "vagrant_scripts/fix-perms.sh"
35     node.vm.provision "shell", path: "vagrant_scripts/add-user.sh"
36     node.vm.provision "shell", path: "vagrant_scripts/install-prereqs.sh"
37     node.vm.provision "shell", path: "vagrant_scripts/install-java8.sh"
38     node.vm.provision "shell", path: "vagrant_scripts/install-vpp.sh"
39     node.vm.provision "shell", path: "vagrant_scripts/configure-vpp.sh"
40     node.vm.provision "shell", path: "vagrant_scripts/install-hc.sh"
41
42     node.vm.network "private_network", ip: mgmt_ip
43     node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port1
44     node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port2
45     node.vm.provider "virtualbox" do |vb|
46       vb.memory = "3072"
47       vb.cpus = 2
48       vb.customize ["modifyvm", :id, "--ioapic", "on"]
49       vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
50       vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
51       vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
52       vb.customize ["modifyvm", :id, "--nicpromisc4", "allow-all"]
53     end
54   end
55 end
56
57 def add_controller(config, name, mgmt_ip, port1, port2)
58   config.vm.box_check_update = false
59   config.vbguest.auto_update = true
60   config.vm.define name do |node|
61     if Vagrant.has_plugin?("vagrant-proxyconf")
62       if ENV["http_proxy"]
63         config.proxy.http     = ENV["http_proxy"]
64       end
65       if ENV["https_proxy"]
66         config.proxy.https    = ENV["https_proxy"]
67       end
68       if ENV["no_proxy"]
69         config.proxy.no_proxy = ENV["no_proxy"]
70       end
71     end
72     node.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
73     node.vm.hostname = name
74     node.vm.provision "shell", path: "vagrant_scripts/fix-perms.sh"
75     node.vm.provision "shell", path: "vagrant_scripts/add-user.sh"
76     node.vm.provision "shell", path: "vagrant_scripts/install-prereqs.sh"
77     node.vm.provision "shell", path: "vagrant_scripts/install-java8.sh"
78     node.vm.provision "shell", path: "vagrant_scripts/install-vpp.sh"
79     node.vm.provision "shell", path: "vagrant_scripts/configure-vpp.sh"
80     node.vm.provision "shell", path: "vagrant_scripts/install-hc.sh"
81     node.vm.provision "shell", path: "vagrant_scripts/install-odl.sh"
82
83     node.vm.network "private_network", ip: mgmt_ip
84     node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port1
85     node.vm.network "private_network", type: "dhcp", auto_config: false, virtualbox__intnet: port2
86     node.vm.provider "virtualbox" do |vb|
87       vb.memory = "3584"
88       vb.cpus = 3
89       vb.customize ["modifyvm", :id, "--ioapic", "on"]
90       vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
91       vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
92       vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
93       vb.customize ["modifyvm", :id, "--nicpromisc4", "allow-all"]
94       vb.customize ["modifyvm", :id, "--nicpromisc5", "allow-all"]
95     end
96   end
97 end
98
99 # install required plugins if necessary
100 if ARGV[0] == 'up'
101     # add required plugins here
102     required_plugins = %w( vagrant-vbguest vagrant-cachier)
103     missing_plugins = []
104     required_plugins.each do |plugin|
105         missing_plugins.push(plugin) unless Vagrant.has_plugin? plugin
106     end
107
108     if ! missing_plugins.empty?
109         install_these = missing_plugins.join(' ')
110         puts "Found missing plugins: #{install_these}.  Installing..."
111         cmd = "vagrant plugin install #{install_these}"
112         updateResult = system( cmd )
113         if updateResult
114             puts "Plugins #{install_these} installed."
115             #restart vagrant up process
116             exec "vagrant up"
117         else
118             abort("Failed to install plugins: #{install_these}.")
119         end
120     else
121         puts "No missing plugins. Ok to continue with vagrant setup."
122     end
123 end
124
125 Vagrant.configure(2) do |config|
126   # vagrant-cachier caches apt/yum etc to speed subsequent
127   # vagrant up
128   # to enable, run
129   # vagrant plugin install vagrant-cachier
130   #
131   if Vagrant.has_plugin?("vagrant-cachier")
132     config.cache.scope = :box
133   end
134
135   add_controller(config, "controller", "192.168.255.100/24", "public_net", "tenant_net",)
136   add_compute(config, "compute0", "192.168.255.101/24", "public_net", "tenant_net")
137   add_compute(config, "compute1", "192.168.255.102/24", "public_net", "tenant_net")
138 end