Elan instance cache cleanup delay
[netvirt.git] / resources / robot / Vagrantfile
1 # -*- mode: ruby -*-
2 # # vi: set ft=ruby :
3
4 # Specify minimum Vagrant version and Vagrant API version
5 Vagrant.require_version ">= 1.6.0"
6 VAGRANTFILE_API_VERSION = "2"
7
8 # Create boxes
9 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
10
11 # Get the number of OVS VMs to create
12 num_ovs_vms = (ENV['OVS_NODES'] || 2).to_i
13
14 base_name = "ovs"
15 base_ip = "192.168.100."
16 controller_ip = "192.168.100.1"
17 os = "puppetlabs/centos-7.0-64-puppet"
18 ram = "512"
19 ovsversion = "2.3.1"
20 vagrant_pwd="vagrant"
21 ovs_node_ips = num_ovs_vms.times.collect { |n| base_ip + "#{n+21}" }
22
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]
29
30           srv.vm.hostname = hostname
31           srv.vm.box = os
32           srv.vm.network "private_network", ip: local_ip
33           srv.vm.provider :virtualbox do |vb|
34         vb.name = hostname
35         vb.memory = ram
36      end # vb
37
38           # Set guest environment variables
39           command1 = 'export CONTROLLER=\"' + controller_ip + '\"'
40           srv.vm.provision :shell, privileged: true, inline: 'echo ' + command1 + ' >> /etc/profile'
41
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'
47           end
48
49           srv.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
50
51           ## SSH config
52           srv.ssh.forward_x11 = false
53
54           ## puppet
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"
60             puppet.facter = {
61               "ovsversion" => ovsversion,
62             }
63           end # puppet
64
65           # process setup commands for ovs
66           #srv.vm.provision "shell", path: "puppet/scripts/setup_defaults.sh"
67
68           if n==0
69              # setup robot framework
70              srv.vm.provision "shell", path: "scripts/setup_robot_framework.sh", privileged: false
71
72              # create the ssh key
73              srv.vm.provision "shell", path: "scripts/create_ssh_key.sh", privileged: false
74           else
75              # run special configurations on the mininet
76              srv.vm.provision "shell", path: "scripts/setup_other_mininets.sh", privileged: false
77           end
78
79           # perform special configuration - requires root permission
80           srv.vm.provision "shell", path: "scripts/special_robot_configuration.sh"
81
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
85
86           time_zone = ""
87
88           begin
89             time_zone = `sudo cat /etc/timezone`
90           rescue Exception => e
91             srv.vm.provision "shell", inline: "failed to get host OS time-zone, default to EST"
92
93             # default to EST
94             time_zone = "America/New_York"
95           end
96
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
99
100         end # srv
101     end #end num_ovs_vms
102 end # config