Merge "Added support to update flows for induvidual security rule add/remove , after...
[netvirt.git] / resources / robot / Vagrantfile
index 3bedd1772764dc6b9efaf5768ab17b39526b6098..e7c327ab59638f7ffd8a069c0a3d47eb63d6dadb 100644 (file)
@@ -8,36 +8,44 @@ VAGRANTFILE_API_VERSION = "2"
 # Create boxes
 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 
-    # Get the number of OVS VMs to create
-    num_ovs_vms = (ENV['OVS_NODES'] || 2).to_i
-
-    base_name = "ovs"
-    base_ip = "192.168.100."
-    controller_ip = "192.168.100.10"
-    os = "puppetlabs/centos-7.0-64-puppet"
-    ram = "512"
-    ovsversion = "2.3.1"
-    ovs_node_ips = num_ovs_vms.times.collect { |n| base_ip + "#{n+21}" }
-
-    num_ovs_vms.times do |n|
+# Get the number of OVS VMs to create
+num_ovs_vms = (ENV['OVS_NODES'] || 2).to_i
+
+base_name = "ovs"
+base_ip = "192.168.100."
+controller_ip = "192.168.100.1"
+os = "puppetlabs/centos-7.0-64-puppet"
+ram = "512"
+ovsversion = "2.3.1"
+vagrant_pwd="vagrant"
+ovs_node_ips = num_ovs_vms.times.collect { |n| base_ip + "#{n+21}" }
+
+num_ovs_vms.times do |n|
+    #config.ssh.password = vagrant_pwd
     config.vm.define base_name + "#{n+1}", autostart: true do |srv|
           ## Extract yaml variables
           hostname = base_name + "#{n+1}"
           local_ip = ovs_node_ips[n]
 
-              srv.vm.hostname = hostname
+          srv.vm.hostname = hostname
           srv.vm.box = os
           srv.vm.network "private_network", ip: local_ip
           srv.vm.provider :virtualbox do |vb|
         vb.name = hostname
         vb.memory = ram
-          end # vb
+     end # vb
 
           # Set guest environment variables
           command1 = 'export CONTROLLER=\"' + controller_ip + '\"'
-          command2 = 'export LOCAL_IP=\"' + local_ip + '\"'
           srv.vm.provision :shell, privileged: true, inline: 'echo ' + command1 + ' >> /etc/profile'
-          srv.vm.provision :shell, privileged: true, inline: 'echo ' + command2 + ' >> /etc/profile'
+
+          # Create the mininet vm ips
+          num_ovs_vms.times do |m|
+             mininet_ip = ovs_node_ips[m]
+             command = 'export MININET' + "#{m}" + '=\"' + mininet_ip + '\"'
+             srv.vm.provision :shell, privileged: true, inline: 'echo ' + command + ' >> /etc/profile'
+          end
+
           srv.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
 
           ## SSH config
@@ -45,18 +53,49 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 
           ## puppet
           srv.vm.provision "puppet" do |puppet|
-        puppet.working_directory = "/vagrant/puppet"
-        puppet.manifests_path = "puppet/manifests"
-        puppet.manifest_file  = "ovsnode.pp"
-        puppet.options = "--verbose --debug"
-        puppet.facter = {
-          "ovsversion" => ovsversion,
-        }
+            puppet.working_directory = "/vagrant/puppet"
+            puppet.manifests_path = "puppet/manifests"
+            puppet.manifest_file  = "ovsnode.pp"
+            puppet.options = "--verbose --debug"
+            puppet.facter = {
+              "ovsversion" => ovsversion,
+            }
           end # puppet
 
+          # process setup commands for ovs
+          #srv.vm.provision "shell", path: "puppet/scripts/setup_defaults.sh"
+
+          if n==0
+             # setup robot framework
+             srv.vm.provision "shell", path: "scripts/setup_robot_framework.sh", privileged: false
+
+             # create the ssh key
+             srv.vm.provision "shell", path: "scripts/create_ssh_key.sh", privileged: false
+          else
+             # run special configurations on the mininet
+             srv.vm.provision "shell", path: "scripts/setup_other_mininets.sh", privileged: false
+          end
+
+          # perform special configuration - requires root permission
+          srv.vm.provision "shell", path: "scripts/special_robot_configuration.sh"
+
+          # set the guest vm date and time from the host machine
+          # this only works for debian based linux
+          # hopefully we can add other OS compatible commands in the future
+
+          time_zone = ""
+
+          begin
+            time_zone = `sudo cat /etc/timezone`
+          rescue Exception => e
+            srv.vm.provision "shell", inline: "failed to get host OS time-zone, default to EST"
+
+            # default to EST
+            time_zone = "America/New_York"
+          end
 
-          #process setup commands for ovs
-          srv.vm.provision "shell", path: "puppet/scripts/setup_defaults.sh"
+          # set the time zone in the guest OS
+          srv.vm.provision "shell", path: "scripts/ovs_vm_host_timezone_map.sh", args:time_zone
 
         end # srv
     end #end num_ovs_vms