4 # Specify minimum Vagrant version and Vagrant API version
5 Vagrant.require_version ">= 1.6.0"
6 VAGRANTFILE_API_VERSION = "2"
9 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
11 # Get the number of OVS VMs to create
12 num_ovs_vms = (ENV['OVS_NODES'] || 2).to_i
15 base_ip = "192.168.100."
16 controller_ip = "192.168.100.1"
17 os = "puppetlabs/centos-7.0-64-puppet"
21 ovs_node_ips = num_ovs_vms.times.collect { |n| base_ip + "#{n+21}" }
23 num_ovs_vms.times do |n|
24 #config.ssh.password = vagrant_pwd
25 config.vm.define base_name + "#{n+1}", autostart: true do |srv|
26 ## Extract yaml variables
27 hostname = base_name + "#{n+1}"
28 local_ip = ovs_node_ips[n]
30 srv.vm.hostname = hostname
32 srv.vm.network "private_network", ip: local_ip
33 srv.vm.provider :virtualbox do |vb|
38 # Set guest environment variables
39 command1 = 'export CONTROLLER=\"' + controller_ip + '\"'
40 srv.vm.provision :shell, privileged: true, inline: 'echo ' + command1 + ' >> /etc/profile'
42 # Create the mininet vm ips
43 num_ovs_vms.times do |m|
44 mininet_ip = ovs_node_ips[m]
45 command = 'export MININET' + "#{m}" + '=\"' + mininet_ip + '\"'
46 srv.vm.provision :shell, privileged: true, inline: 'echo ' + command + ' >> /etc/profile'
49 srv.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
52 srv.ssh.forward_x11 = false
55 srv.vm.provision "puppet" do |puppet|
56 puppet.working_directory = "/vagrant/puppet"
57 puppet.manifests_path = "puppet/manifests"
58 puppet.manifest_file = "ovsnode.pp"
59 puppet.options = "--verbose --debug"
61 "ovsversion" => ovsversion,
65 # process setup commands for ovs
66 #srv.vm.provision "shell", path: "puppet/scripts/setup_defaults.sh"
69 # setup robot framework
70 srv.vm.provision "shell", path: "scripts/setup_robot_framework.sh", privileged: false
73 srv.vm.provision "shell", path: "scripts/create_ssh_key.sh", privileged: false
75 # run special configurations on the mininet
76 srv.vm.provision "shell", path: "scripts/setup_other_mininets.sh", privileged: false
79 # perform special configuration - requires root permission
80 srv.vm.provision "shell", path: "scripts/special_robot_configuration.sh"
82 # set the guest vm date and time from the host machine
83 # this only works for debian based linux
84 # hopefully we can add other OS compatible commands in the future
89 time_zone = `sudo cat /etc/timezone`
91 srv.vm.provision "shell", inline: "failed to get host OS time-zone, default to EST"
94 time_zone = "America/New_York"
97 # set the time zone in the guest OS
98 srv.vm.provision "shell", path: "scripts/ovs_vm_host_timezone_map.sh", args:time_zone