2015-07-21 21:57:44 +02:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2015-09-14 23:07:46 +09:00
|
|
|
require "ipaddr"
|
|
|
|
|
2016-07-25 17:36:02 -05:00
|
|
|
# Check for required plugin(s)
|
|
|
|
['vagrant-hostmanager'].each do |plugin|
|
|
|
|
unless Vagrant.has_plugin?(plugin)
|
|
|
|
raise "#{plugin} plugin not found. Please install it via 'vagrant plugin install #{plugin}'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-18 17:47:15 +09:00
|
|
|
class VagrantConfigMissing < StandardError
|
|
|
|
end
|
|
|
|
|
|
|
|
vagrant_dir = File.expand_path(File.dirname(__FILE__))
|
|
|
|
|
2018-04-19 12:36:31 -07:00
|
|
|
# get kolla, kolla-ansibe and kolla-cli repos path relative to current directory
|
2017-05-30 11:47:15 +01:00
|
|
|
# they will be used by the bootstrap script to configure the nodes
|
|
|
|
kolla_ansible_repo_path = File.expand_path(File.join(vagrant_dir, '..', '..', '..'))
|
|
|
|
kolla_repo_path = File.expand_path(File.join(vagrant_dir, '..', '..', '..', '..', 'kolla'))
|
2018-04-19 12:36:31 -07:00
|
|
|
kolla_cli_repo_path = File.expand_path(File.join(vagrant_dir, '..', '..', '..', '..', 'kolla-cli'))
|
2017-05-30 11:47:15 +01:00
|
|
|
|
2015-11-18 17:47:15 +09:00
|
|
|
# Vagrantfile.custom contains user customization for the Vagrantfile
|
|
|
|
# You shouldn't have to edit the Vagrantfile, ever.
|
|
|
|
if File.exists?(File.join(vagrant_dir, 'Vagrantfile.custom'))
|
|
|
|
eval(IO.read(File.join(vagrant_dir, 'Vagrantfile.custom')), binding)
|
|
|
|
end
|
|
|
|
|
2015-09-14 23:07:46 +09:00
|
|
|
# Either libvirt or virtualbox
|
2015-11-18 17:47:15 +09:00
|
|
|
PROVIDER ||= "libvirt"
|
2015-11-10 09:53:12 -05:00
|
|
|
# Either centos or ubuntu
|
2015-11-18 17:47:15 +09:00
|
|
|
DISTRO ||= "centos"
|
2015-09-25 18:47:57 +09:00
|
|
|
|
2016-02-23 08:09:45 -08:00
|
|
|
# The libvirt graphics_ip used for each guest. Only applies if PROVIDER
|
|
|
|
# is libvirt.
|
|
|
|
GRAPHICSIP ||= "127.0.0.1"
|
|
|
|
|
2016-03-05 02:01:13 +01:00
|
|
|
# Provisioning other boxes than the default ones may therefore
|
|
|
|
# require changes to bootstrap.sh.
|
|
|
|
PROVISION_SCRIPT ||= "bootstrap.sh"
|
|
|
|
|
2017-06-02 13:51:37 +01:00
|
|
|
# The bootstrap.sh provisioning script requires CentOS or Ubuntu; see below
|
|
|
|
# for the supported versions for each provider.
|
|
|
|
#
|
|
|
|
# kolla and kolla-ansible will be mounted in $HOME and the username depends
|
|
|
|
# on the image.
|
|
|
|
#
|
2015-11-18 17:47:15 +09:00
|
|
|
PROVIDER_DEFAULTS ||= {
|
2015-09-25 18:47:57 +09:00
|
|
|
libvirt: {
|
2015-11-10 09:53:12 -05:00
|
|
|
centos: {
|
|
|
|
base_image: "centos/7",
|
|
|
|
bridge_interface: "virbr0",
|
|
|
|
sync_method: "nfs",
|
2017-06-02 13:51:37 +01:00
|
|
|
username: "vagrant"
|
2015-11-10 09:53:12 -05:00
|
|
|
}
|
2015-09-25 18:47:57 +09:00
|
|
|
},
|
|
|
|
virtualbox: {
|
2015-11-10 09:53:12 -05:00
|
|
|
centos: {
|
2017-06-02 13:51:37 +01:00
|
|
|
base_image: "centos/7",
|
2015-11-10 09:53:12 -05:00
|
|
|
bridge_interface: "wlp3s0b1",
|
|
|
|
sync_method: "virtualbox",
|
2017-06-02 13:51:37 +01:00
|
|
|
username: "vagrant"
|
2015-11-10 09:53:12 -05:00
|
|
|
},
|
|
|
|
ubuntu: {
|
2017-06-02 13:51:37 +01:00
|
|
|
base_image: "ubuntu/xenial64",
|
2015-11-10 09:53:12 -05:00
|
|
|
bridge_interface: "wlp3s0b1",
|
2016-02-19 22:15:56 +01:00
|
|
|
sync_method: "virtualbox",
|
2017-06-02 13:51:37 +01:00
|
|
|
username: "ubuntu"
|
2015-11-10 09:53:12 -05:00
|
|
|
}
|
|
|
|
}
|
2015-09-25 18:47:57 +09:00
|
|
|
}
|
2015-09-14 23:07:46 +09:00
|
|
|
|
Attach external NIC to a NAT-Network if on Wi-Fi
On computers with wi-fi adapters, promiscuous mode on the VirtualBox (or
maybe other hypervisors as well) NICs does not work, which means the
default way of connecting the Neutron external interface to a bridged
adapter, will not allow communication to and from the Nova VMs over
floating IPs with any computer on the external network (except the host
computer) or with the wi-fi router. This means no ability to connect to
the Nova VMs and no internet access inside the Nova VMs.
According to VirtualBox documentation (excerpt): "Bridging to a wireless
interface is done differently from bridging to a wired interface,
because most wireless adapters do not support promiscuous mode. All
traffic has to use the MAC address of the host’s wireless adapter, and
therefore VirtualBox needs to replace the source MAC address in the
Ethernet header of an outgoing packet to make sure the reply will be
sent to the host interface. When VirtualBox sees an incoming packet with
a destination IP address that belongs to one of the virtual machine
adapters it replaces the destination MAC address in the Ethernet header
with the VM adapter’s MAC address and passes it on. VirtualBox examines
ARP and DHCP packets in order to learn the IP addresses of virtual
machines."
To fix this issue, a new flag has been introduced: WIFI. If true, the
default Vagrant public network is not created anymore. Instead, the 3rd
NIC will be connected to a NAT-Network named OSNetwork. The NAT-Network
has a virtual gateway, which will be used to communicate with the
external physical wi-fi router. Since Vagrant does not have a high-level
mechanism to attach an adapter to a NAT-Network, the code uses the
low-level Vagrant construct vm.customize which makes it provider
specific.
Promiscuous mode is now activated by default on the 3rd NIC.
The WIFI flag is false by default.
This commit only addresses VirtualBox, and it is currently unknown if
the problem described and fixed in this commit is present in other
hypervisors.
DocImpact
Closes-Bug: #1558766
Change-Id: I0b4dbbc562d87191b2179f47b634cdd6f6361a5e
Signed-off-by: Andrei-Lucian Șerb <lucian.serb@icloud.com>
2016-03-18 01:30:32 +02:00
|
|
|
# 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)
|
|
|
|
|
2015-09-14 22:51:34 +09:00
|
|
|
# Whether to do Multi-node or All-in-One deployment
|
2015-11-18 17:47:15 +09:00
|
|
|
MULTINODE = false unless self.class.const_defined?(:MULTINODE)
|
2015-09-14 22:51:34 +09:00
|
|
|
|
2015-09-14 23:01:10 +09:00
|
|
|
# The following is only used when deploying in Multi-nodes
|
2015-11-18 17:47:15 +09:00
|
|
|
NUMBER_OF_CONTROL_NODES ||= 3
|
|
|
|
NUMBER_OF_COMPUTE_NODES ||= 1
|
|
|
|
NUMBER_OF_STORAGE_NODES ||= 1
|
|
|
|
NUMBER_OF_NETWORK_NODES ||= 1
|
2018-06-15 03:16:35 +00:00
|
|
|
NUMBER_OF_MONITOR_NODES ||= 1
|
2015-09-14 23:01:10 +09:00
|
|
|
|
2015-11-18 17:47:15 +09:00
|
|
|
NODE_SETTINGS ||= {
|
2015-11-10 09:53:12 -05:00
|
|
|
aio: {
|
|
|
|
cpus: 4,
|
|
|
|
memory: 4096
|
|
|
|
},
|
|
|
|
operator: {
|
|
|
|
cpus: 1,
|
|
|
|
memory: 1024
|
|
|
|
},
|
2015-11-18 16:43:45 +09:00
|
|
|
control: {
|
2015-11-10 09:53:12 -05:00
|
|
|
cpus: 1,
|
|
|
|
memory: 2048
|
|
|
|
},
|
|
|
|
compute: {
|
|
|
|
cpus: 1,
|
|
|
|
memory: 1024
|
|
|
|
},
|
|
|
|
storage: {
|
|
|
|
cpus: 1,
|
|
|
|
memory: 1024
|
|
|
|
},
|
|
|
|
network: {
|
|
|
|
cpus: 1,
|
|
|
|
memory: 1024
|
2018-06-15 03:16:35 +00:00
|
|
|
},
|
|
|
|
monitor: {
|
|
|
|
cpus: 1,
|
|
|
|
memory: 1024
|
2015-11-10 09:53:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 21:57:44 +02:00
|
|
|
# Configure a new SSH key and config so the operator is able to connect with
|
|
|
|
# the other cluster nodes.
|
2015-11-18 17:47:15 +09:00
|
|
|
unless File.file?(File.join(vagrant_dir, 'vagrantkey'))
|
|
|
|
system("ssh-keygen -f #{File.join(vagrant_dir, 'vagrantkey')} -N '' -C this-is-vagrant")
|
2015-07-21 21:57:44 +02:00
|
|
|
end
|
|
|
|
|
2015-09-25 18:47:57 +09:00
|
|
|
def get_default(setting)
|
2015-11-10 09:53:12 -05:00
|
|
|
PROVIDER_DEFAULTS[PROVIDER.to_sym][DISTRO.to_sym][setting]
|
2015-11-18 17:47:15 +09:00
|
|
|
rescue
|
|
|
|
raise VagrantConfigMissing,
|
|
|
|
"Missing configuration for PROVIDER_DEFAULTS[#{PROVIDER}][#{DISTRO}][#{setting}]"
|
2015-11-10 09:53:12 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get_setting(node, setting)
|
|
|
|
NODE_SETTINGS[node][setting]
|
2015-11-18 17:47:15 +09:00
|
|
|
rescue
|
|
|
|
raise VagrantConfigMissing,
|
|
|
|
"Missing configuration for NODE_SETTINGS[#{node}][#{setting}]"
|
2015-09-25 18:47:57 +09:00
|
|
|
end
|
|
|
|
|
Attach external NIC to a NAT-Network if on Wi-Fi
On computers with wi-fi adapters, promiscuous mode on the VirtualBox (or
maybe other hypervisors as well) NICs does not work, which means the
default way of connecting the Neutron external interface to a bridged
adapter, will not allow communication to and from the Nova VMs over
floating IPs with any computer on the external network (except the host
computer) or with the wi-fi router. This means no ability to connect to
the Nova VMs and no internet access inside the Nova VMs.
According to VirtualBox documentation (excerpt): "Bridging to a wireless
interface is done differently from bridging to a wired interface,
because most wireless adapters do not support promiscuous mode. All
traffic has to use the MAC address of the host’s wireless adapter, and
therefore VirtualBox needs to replace the source MAC address in the
Ethernet header of an outgoing packet to make sure the reply will be
sent to the host interface. When VirtualBox sees an incoming packet with
a destination IP address that belongs to one of the virtual machine
adapters it replaces the destination MAC address in the Ethernet header
with the VM adapter’s MAC address and passes it on. VirtualBox examines
ARP and DHCP packets in order to learn the IP addresses of virtual
machines."
To fix this issue, a new flag has been introduced: WIFI. If true, the
default Vagrant public network is not created anymore. Instead, the 3rd
NIC will be connected to a NAT-Network named OSNetwork. The NAT-Network
has a virtual gateway, which will be used to communicate with the
external physical wi-fi router. Since Vagrant does not have a high-level
mechanism to attach an adapter to a NAT-Network, the code uses the
low-level Vagrant construct vm.customize which makes it provider
specific.
Promiscuous mode is now activated by default on the 3rd NIC.
The WIFI flag is false by default.
This commit only addresses VirtualBox, and it is currently unknown if
the problem described and fixed in this commit is present in other
hypervisors.
DocImpact
Closes-Bug: #1558766
Change-Id: I0b4dbbc562d87191b2179f47b634cdd6f6361a5e
Signed-off-by: Andrei-Lucian Șerb <lucian.serb@icloud.com>
2016-03-18 01:30:32 +02:00
|
|
|
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
|
2015-11-18 17:47:15 +09:00
|
|
|
|
2015-07-21 21:57:44 +02:00
|
|
|
Vagrant.configure(2) do |config|
|
2017-05-30 11:47:15 +01:00
|
|
|
|
|
|
|
# check for kolla repo to be available
|
|
|
|
unless File.directory?(kolla_repo_path)
|
|
|
|
raise VagrantConfigMissing,
|
|
|
|
"Missing kolla repository checkout at #{kolla_repo_path}"
|
|
|
|
end
|
|
|
|
|
2015-09-25 18:47:57 +09:00
|
|
|
config.vm.box = get_default(:base_image)
|
2015-07-21 21:57:44 +02:00
|
|
|
|
2017-06-02 13:51:37 +01:00
|
|
|
# these may change depending on the image
|
|
|
|
username = get_default(:username)
|
|
|
|
user_home = "/home/#{username}"
|
|
|
|
vagrant_shared_folder = "#{user_home}/sync"
|
|
|
|
kolla_path = "#{user_home}/kolla"
|
|
|
|
kolla_ansible_path = "#{user_home}/kolla-ansible"
|
2018-04-19 12:36:31 -07:00
|
|
|
kolla_cli_path = "#{user_home}/kolla-cli"
|
2017-06-02 13:51:37 +01:00
|
|
|
|
2015-07-21 21:57:44 +02:00
|
|
|
# Next to the hostonly NAT-network there is a host-only network with all
|
|
|
|
# nodes attached. Plus, each node receives a 3rd adapter connected to the
|
|
|
|
# outside public network.
|
2015-09-25 10:29:24 +09:00
|
|
|
config.vm.network "private_network", type: "dhcp"
|
Attach external NIC to a NAT-Network if on Wi-Fi
On computers with wi-fi adapters, promiscuous mode on the VirtualBox (or
maybe other hypervisors as well) NICs does not work, which means the
default way of connecting the Neutron external interface to a bridged
adapter, will not allow communication to and from the Nova VMs over
floating IPs with any computer on the external network (except the host
computer) or with the wi-fi router. This means no ability to connect to
the Nova VMs and no internet access inside the Nova VMs.
According to VirtualBox documentation (excerpt): "Bridging to a wireless
interface is done differently from bridging to a wired interface,
because most wireless adapters do not support promiscuous mode. All
traffic has to use the MAC address of the host’s wireless adapter, and
therefore VirtualBox needs to replace the source MAC address in the
Ethernet header of an outgoing packet to make sure the reply will be
sent to the host interface. When VirtualBox sees an incoming packet with
a destination IP address that belongs to one of the virtual machine
adapters it replaces the destination MAC address in the Ethernet header
with the VM adapter’s MAC address and passes it on. VirtualBox examines
ARP and DHCP packets in order to learn the IP addresses of virtual
machines."
To fix this issue, a new flag has been introduced: WIFI. If true, the
default Vagrant public network is not created anymore. Instead, the 3rd
NIC will be connected to a NAT-Network named OSNetwork. The NAT-Network
has a virtual gateway, which will be used to communicate with the
external physical wi-fi router. Since Vagrant does not have a high-level
mechanism to attach an adapter to a NAT-Network, the code uses the
low-level Vagrant construct vm.customize which makes it provider
specific.
Promiscuous mode is now activated by default on the 3rd NIC.
The WIFI flag is false by default.
This commit only addresses VirtualBox, and it is currently unknown if
the problem described and fixed in this commit is present in other
hypervisors.
DocImpact
Closes-Bug: #1558766
Change-Id: I0b4dbbc562d87191b2179f47b634cdd6f6361a5e
Signed-off-by: Andrei-Lucian Șerb <lucian.serb@icloud.com>
2016-03-18 01:30:32 +02:00
|
|
|
# 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), mode: 'bridge', type: 'bridge'
|
|
|
|
end
|
2015-07-21 21:57:44 +02:00
|
|
|
|
2015-11-18 17:47:15 +09:00
|
|
|
my_privatekey = File.read(File.join(vagrant_dir, "vagrantkey"))
|
|
|
|
my_publickey = File.read(File.join(vagrant_dir, "vagrantkey.pub"))
|
2015-07-21 21:57:44 +02:00
|
|
|
|
2015-09-07 13:09:56 +01:00
|
|
|
config.vm.provision :shell, inline: <<-EOS
|
|
|
|
mkdir -p /root/.ssh
|
|
|
|
echo '#{my_privatekey}' > /root/.ssh/id_rsa
|
|
|
|
chmod 600 /root/.ssh/id_rsa
|
|
|
|
echo '#{my_publickey}' > /root/.ssh/authorized_keys
|
|
|
|
chmod 600 /root/.ssh/authorized_keys
|
2015-09-22 01:01:38 +00:00
|
|
|
echo '#{my_publickey}' > /root/.ssh/id_rsa.pub
|
|
|
|
chmod 644 /root/.ssh/id_rsa.pub
|
2017-06-02 13:51:37 +01:00
|
|
|
mkdir -p #{user_home}/.ssh
|
|
|
|
echo '#{my_privatekey}' >> #{user_home}/.ssh/id_rsa
|
|
|
|
chmod 600 #{user_home}/.ssh/*
|
|
|
|
echo 'Host *' > #{user_home}/.ssh/config
|
|
|
|
echo StrictHostKeyChecking no >> #{user_home}/.ssh/config
|
|
|
|
chown -R #{username} #{user_home}/.ssh
|
2015-09-07 13:09:56 +01:00
|
|
|
EOS
|
2015-07-21 21:57:44 +02:00
|
|
|
|
|
|
|
config.hostmanager.enabled = true
|
2015-09-25 18:47:57 +09:00
|
|
|
# Make sure hostmanager picks IP address of eth1
|
|
|
|
config.hostmanager.ip_resolver = proc do |vm, resolving_vm|
|
|
|
|
case PROVIDER
|
|
|
|
when "libvirt"
|
|
|
|
if vm.name
|
2016-02-09 12:09:33 +09:00
|
|
|
`python newest_dhcp_lease.py #{vm.name}`.chop
|
2015-09-25 18:47:57 +09:00
|
|
|
end
|
2016-03-16 08:38:31 +09:00
|
|
|
when "virtualbox"
|
2015-09-25 18:47:57 +09:00
|
|
|
if vm.id
|
|
|
|
`VBoxManage guestproperty get #{vm.id} "/VirtualBox/GuestInfo/Net/1/V4/IP"`.split()[1]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-07-21 21:57:44 +02:00
|
|
|
|
|
|
|
# The operator controls the deployment
|
2016-06-17 14:38:51 +02:00
|
|
|
config.vm.define "operator", primary: true do |admin|
|
2015-07-21 21:57:44 +02:00
|
|
|
admin.vm.hostname = "operator.local"
|
2018-06-15 03:16:35 +00:00
|
|
|
admin.vm.provision :shell, path: PROVISION_SCRIPT, args: "operator #{MULTINODE ? 'multinode' : 'aio'} #{kolla_path} #{kolla_ansible_path} #{kolla_cli_path} #{NUMBER_OF_COMPUTE_NODES} #{NUMBER_OF_STORAGE_NODES} #{NUMBER_OF_NETWORK_NODES} #{NUMBER_OF_CONTROL_NODES} #{NUMBER_OF_MONITOR_NODES}"
|
2017-06-02 13:51:37 +01:00
|
|
|
admin.vm.synced_folder kolla_ansible_repo_path, kolla_ansible_path, create:"True", type: get_default(:sync_method)
|
|
|
|
admin.vm.synced_folder kolla_repo_path, kolla_path, create:"True", type: get_default(:sync_method)
|
2018-04-19 12:36:31 -07:00
|
|
|
admin.vm.synced_folder kolla_cli_repo_path, kolla_cli_path, create:"True", type: get_default(:sync_method)
|
2015-11-18 17:47:15 +09:00
|
|
|
admin.vm.synced_folder File.join(vagrant_dir, 'storage', 'operator'), "/data/host", create:"True", type: get_default(:sync_method)
|
|
|
|
admin.vm.synced_folder File.join(vagrant_dir, 'storage', 'shared'), "/data/shared", create:"True", type: get_default(:sync_method)
|
2017-06-02 13:51:37 +01:00
|
|
|
admin.vm.synced_folder ".", vagrant_shared_folder, disabled: true
|
2015-09-14 23:07:46 +09:00
|
|
|
admin.vm.provider PROVIDER do |vm|
|
2015-11-10 09:53:12 -05:00
|
|
|
vm.memory = MULTINODE ? get_setting(:operator, :memory) : get_setting(:aio, :memory)
|
|
|
|
vm.cpus = MULTINODE ? get_setting(:operator, :cpus) : get_setting(:aio, :cpus)
|
2016-03-03 17:31:53 +09:00
|
|
|
if PROVIDER == "libvirt"
|
|
|
|
vm.graphics_ip = GRAPHICSIP
|
|
|
|
end
|
Attach external NIC to a NAT-Network if on Wi-Fi
On computers with wi-fi adapters, promiscuous mode on the VirtualBox (or
maybe other hypervisors as well) NICs does not work, which means the
default way of connecting the Neutron external interface to a bridged
adapter, will not allow communication to and from the Nova VMs over
floating IPs with any computer on the external network (except the host
computer) or with the wi-fi router. This means no ability to connect to
the Nova VMs and no internet access inside the Nova VMs.
According to VirtualBox documentation (excerpt): "Bridging to a wireless
interface is done differently from bridging to a wired interface,
because most wireless adapters do not support promiscuous mode. All
traffic has to use the MAC address of the host’s wireless adapter, and
therefore VirtualBox needs to replace the source MAC address in the
Ethernet header of an outgoing packet to make sure the reply will be
sent to the host interface. When VirtualBox sees an incoming packet with
a destination IP address that belongs to one of the virtual machine
adapters it replaces the destination MAC address in the Ethernet header
with the VM adapter’s MAC address and passes it on. VirtualBox examines
ARP and DHCP packets in order to learn the IP addresses of virtual
machines."
To fix this issue, a new flag has been introduced: WIFI. If true, the
default Vagrant public network is not created anymore. Instead, the 3rd
NIC will be connected to a NAT-Network named OSNetwork. The NAT-Network
has a virtual gateway, which will be used to communicate with the
external physical wi-fi router. Since Vagrant does not have a high-level
mechanism to attach an adapter to a NAT-Network, the code uses the
low-level Vagrant construct vm.customize which makes it provider
specific.
Promiscuous mode is now activated by default on the 3rd NIC.
The WIFI flag is false by default.
This commit only addresses VirtualBox, and it is currently unknown if
the problem described and fixed in this commit is present in other
hypervisors.
DocImpact
Closes-Bug: #1558766
Change-Id: I0b4dbbc562d87191b2179f47b634cdd6f6361a5e
Signed-off-by: Andrei-Lucian Șerb <lucian.serb@icloud.com>
2016-03-18 01:30:32 +02:00
|
|
|
configure_wifi_if_enabled(vm)
|
2016-02-23 08:09:45 -08:00
|
|
|
end
|
2015-07-21 21:57:44 +02:00
|
|
|
admin.hostmanager.aliases = "operator"
|
|
|
|
end
|
|
|
|
|
2015-09-14 22:51:34 +09:00
|
|
|
if MULTINODE
|
2015-11-18 16:43:45 +09:00
|
|
|
['compute', 'storage', 'network', 'control'].each do |node_type|
|
|
|
|
(1..self.class.const_get("NUMBER_OF_#{node_type.upcase}_NODES")).each do |i|
|
|
|
|
hostname = "#{node_type}0#{i}"
|
|
|
|
config.vm.define hostname do |node|
|
|
|
|
node.vm.hostname = "#{hostname}.local"
|
2018-06-15 03:16:35 +00:00
|
|
|
node.vm.provision :shell, path: PROVISION_SCRIPT, args: "#{hostname} multinode #{kolla_path} #{kolla_ansible_path} #{kolla_cli_path} #{NUMBER_OF_COMPUTE_NODES} #{NUMBER_OF_STORAGE_NODES} #{NUMBER_OF_NETWORK_NODES} #{NUMBER_OF_CONTROL_NODES} #{NUMBER_OF_MONITOR_NODES}"
|
2015-11-18 17:47:15 +09:00
|
|
|
node.vm.synced_folder File.join(vagrant_dir, 'storage', node_type), "/data/host", create:"True", type: get_default(:sync_method)
|
|
|
|
node.vm.synced_folder File.join(vagrant_dir, 'storage', 'shared'), "/data/shared", create:"True", type: get_default(:sync_method)
|
2017-06-02 13:51:37 +01:00
|
|
|
node.vm.synced_folder ".", vagrant_shared_folder, disabled: true
|
2015-11-18 16:43:45 +09:00
|
|
|
node.vm.provider PROVIDER do |vm|
|
|
|
|
vm.memory = get_setting(node_type.to_sym, :memory)
|
|
|
|
vm.cpus = get_setting(node_type.to_sym, :cpus)
|
2016-03-03 17:31:53 +09:00
|
|
|
if PROVIDER == "libvirt"
|
|
|
|
vm.graphics_ip = GRAPHICSIP
|
|
|
|
end
|
Attach external NIC to a NAT-Network if on Wi-Fi
On computers with wi-fi adapters, promiscuous mode on the VirtualBox (or
maybe other hypervisors as well) NICs does not work, which means the
default way of connecting the Neutron external interface to a bridged
adapter, will not allow communication to and from the Nova VMs over
floating IPs with any computer on the external network (except the host
computer) or with the wi-fi router. This means no ability to connect to
the Nova VMs and no internet access inside the Nova VMs.
According to VirtualBox documentation (excerpt): "Bridging to a wireless
interface is done differently from bridging to a wired interface,
because most wireless adapters do not support promiscuous mode. All
traffic has to use the MAC address of the host’s wireless adapter, and
therefore VirtualBox needs to replace the source MAC address in the
Ethernet header of an outgoing packet to make sure the reply will be
sent to the host interface. When VirtualBox sees an incoming packet with
a destination IP address that belongs to one of the virtual machine
adapters it replaces the destination MAC address in the Ethernet header
with the VM adapter’s MAC address and passes it on. VirtualBox examines
ARP and DHCP packets in order to learn the IP addresses of virtual
machines."
To fix this issue, a new flag has been introduced: WIFI. If true, the
default Vagrant public network is not created anymore. Instead, the 3rd
NIC will be connected to a NAT-Network named OSNetwork. The NAT-Network
has a virtual gateway, which will be used to communicate with the
external physical wi-fi router. Since Vagrant does not have a high-level
mechanism to attach an adapter to a NAT-Network, the code uses the
low-level Vagrant construct vm.customize which makes it provider
specific.
Promiscuous mode is now activated by default on the 3rd NIC.
The WIFI flag is false by default.
This commit only addresses VirtualBox, and it is currently unknown if
the problem described and fixed in this commit is present in other
hypervisors.
DocImpact
Closes-Bug: #1558766
Change-Id: I0b4dbbc562d87191b2179f47b634cdd6f6361a5e
Signed-off-by: Andrei-Lucian Șerb <lucian.serb@icloud.com>
2016-03-18 01:30:32 +02:00
|
|
|
configure_wifi_if_enabled(vm)
|
2016-02-23 08:09:45 -08:00
|
|
|
end
|
2015-11-18 16:43:45 +09:00
|
|
|
node.hostmanager.aliases = hostname
|
2015-09-14 22:51:34 +09:00
|
|
|
end
|
|
|
|
end
|
2015-07-21 21:57:44 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|