Fix Vagrant config for multi-user environment 26/1426/2
authorAurélien Degeorges <aurelien.degeorges@6wind.com>
Mon, 6 Jun 2016 11:49:52 +0000 (13:49 +0200)
committerDave Wallace <dwallacelf@gmail.com>
Thu, 9 Jun 2016 02:13:03 +0000 (02:13 +0000)
Add support for an environment variable "VPP_VAGRANT_NET_PREFIX" to add a prefix
before the name of vbox internal networks.
Otherwise two users trying to do "vargrant up" on the same server will face
conflicts with the name of vbox internal networks.

Change-Id: I5ba7c06fe111944fcac3da25276d018d281aef4f
Signed-off-by: Aurélien Degeorges <aurelien.degeorges@6wind.com>
resources/tools/vagrant/Vagrantfile

index f73ca5b..46e2146 100644 (file)
@@ -63,6 +63,11 @@ def add_dut(config, name, mgmt_ip, net1, net2)
 
 end
 
+net_prefix = ''
+if ENV.key?('VPP_VAGRANT_NET_PREFIX')
+  net_prefix = ENV['VPP_VAGRANT_NET_PREFIX'] + '_'
+end
+
 Vagrant.configure(2) do |config|
   config.vm.box_check_update = false
   config.vm.define "tg" do |tg|
@@ -84,9 +89,9 @@ Vagrant.configure(2) do |config|
     tg.vm.provision "shell", inline: $install_prereqs
     tg.vm.network "private_network", ip: '192.168.255.100/24'
     tg.vm.network "private_network", type: "dhcp", auto_config: false,
-        virtualbox__intnet: "tg_dut1"
+        virtualbox__intnet: net_prefix + "tg_dut1"
     tg.vm.network "private_network", type: "dhcp", auto_config: false,
-        virtualbox__intnet: "tg_dut2"
+        virtualbox__intnet: net_prefix + "tg_dut2"
     tg.vm.provider "virtualbox" do |vb|
       vb.memory = "2048"
       vb.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
@@ -95,7 +100,7 @@ Vagrant.configure(2) do |config|
 
   end
 
-  add_dut(config, "dut1", "192.168.255.101/24", "tg_dut1", "dut1_dut2")
-  add_dut(config, "dut2", "192.168.255.102/24", "tg_dut2", "dut1_dut2")
+  add_dut(config, "dut1", "192.168.255.101/24", net_prefix + "tg_dut1", net_prefix + "dut1_dut2")
+  add_dut(config, "dut2", "192.168.255.102/24", net_prefix + "tg_dut2", net_prefix + "dut1_dut2")
 end