diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index 3ddda36e..2b0b36c6 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -32,6 +32,12 @@ PROVIDER_DEFAULTS ||= { }, } +# Whether the host network adapter is Wi-Fi. +# On VirtualBox, the user must first manually create a NAT-Network +# named "OSNetwork". The default network CIDR must be changed. +# The Neutron external interface will be connected to this Network. +WIFI = false unless self.class.const_defined?(:WIFI) + MULTINODE = false unless self.class.const_defined?(:MULTINODE) NUMBER_OF_MASTER_NODES ||= 3 @@ -82,11 +88,49 @@ rescue "Missing configuration for NODE_SETTINGS[#{node}][#{setting}]" end +def configure_wifi_vbox_networking(vm) + # Even if adapters 1 & 2 don't need to be modified, if the order is to be + # maintained, some modification has to be done to them. This will maintain + # the association inside the guest OS: NIC1 -> eth0, NIC2 -> eth1, NIC3 -> + # eht2. The modifications for adapters 1 & 2 only change optional properties. + # Adapter 3 is enabled and connected to the NAT-Network named "OSNetwork", + # while also changing its optional properties. Since adapter 3 is used by + # Neutron for the external network, promiscuous mode is set to "allow-all". + # Also, use virtio as the adapter type, for better performance. + vm.customize ["modifyvm", :id, "--nictype1", "virtio"] + vm.customize ["modifyvm", :id, "--cableconnected1", "on"] + vm.customize ["modifyvm", :id, "--nicpromisc2", "deny"] + vm.customize ["modifyvm", :id, "--nictype2", "virtio"] + vm.customize ["modifyvm", :id, "--cableconnected2", "on"] + vm.customize ["modifyvm", :id, "--nic3", "natnetwork"] + vm.customize ["modifyvm", :id, "--nat-network3", "OSNetwork"] + vm.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"] + vm.customize ["modifyvm", :id, "--nictype3", "virtio"] + vm.customize ["modifyvm", :id, "--cableconnected3", "on"] +end + +def configure_wifi_if_enabled(vm) + if WIFI + case PROVIDER + when "virtualbox" + configure_wifi_vbox_networking(vm) +# TODO(lucian-serb): Configure networking on Wi-Fi for other hypervisors. +# when "libvirt" +# configure_wifi_libvirt_networking(vm) + end + end +end + Vagrant.configure(2) do |config| config.vm.box = get_default(:base_image) config.vm.network "private_network", type: "dhcp" - config.vm.network "public_network", dev: get_default(:bridge_interface), bridge: get_default(:bridge_interface), mode: 'bridge', type: 'bridge' + # On VirtualBox hosts with Wi-Fi, do not create a public bridged interface. + # A NAT-Network will be used instead. + # TODO(lucian-serb): Do the same for other hypervisors as well? + unless PROVIDER == "virtualbox" && WIFI + config.vm.network "public_network", dev: get_default(:bridge_interface), bridge: get_default(:bridge_interface), mode: 'bridge', type: 'bridge' + end my_privatekey = File.read(File.join(vagrant_dir, "vagrantkey")) my_publickey = File.read(File.join(vagrant_dir, "vagrantkey.pub")) @@ -129,6 +173,7 @@ Vagrant.configure(2) do |config| admin.vm.provider PROVIDER do |vm| vm.cpus = get_setting(:aio, :cpus) vm.memory = get_setting(:aio, :memory) + configure_wifi_if_enabled(vm) end admin.vm.provision :hostmanager admin.vm.provision :shell, path: "provision.sh", args: "operator #{MULTINODE ? 'multinode' : 'aio'}" @@ -146,6 +191,7 @@ Vagrant.configure(2) do |config| node.vm.provider PROVIDER do |vm| vm.memory = get_setting(node_type.to_sym, :memory) vm.cpus = get_setting(node_type.to_sym, :cpus) + configure_wifi_if_enabled(vm) end node.hostmanager.aliases = hostname end diff --git a/vagrant/Vagrantfile.custom.example b/vagrant/Vagrantfile.custom.example index 28c2e1fd..96e705b7 100644 --- a/vagrant/Vagrantfile.custom.example +++ b/vagrant/Vagrantfile.custom.example @@ -15,6 +15,12 @@ # }, # } +# Whether the host network adapter is Wi-Fi. +# On VirtualBox, the user must first manually create a NAT-Network +# named OSNetwork. The default network CIDR must be changed. +# The Neutron external interface will be connected to this Network. +# WIFI = false + # MULTINODE = false # NUMBER_OF_MASTER_NODES = 3