mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2024-07-07 04:22:58 -05:00
Support iface_name setting for management network (#1739)
Allow setting the interface name that appears on the host for the management network interface in the guest. This allows for more complex networking layouts by allowiing matching against devices for vlan configurations. Fixes: #1701
This commit is contained in:
parent
768e18f086
commit
99ac328621
|
@ -592,6 +592,7 @@ used by this network are configurable at the provider level.
|
|||
the Libvirt default (1500) will be used.
|
||||
* `management_network_keep` - Starting from version *0.7.0*, *always_destroy* is set to *true* by default for any network.
|
||||
This option allows to change this behaviour for the management network.
|
||||
* `management_network_iface_name` - Allow controlling of the network device name that appears on the host for the management network, same as `:libvirt__iface_name` for public and private network definitions. (unreleased).
|
||||
* `management_network_model_type` - Model of the network adapter to use for the management interface. Default is 'virtio'.
|
||||
|
||||
You may wonder how vagrant-libvirt knows the IP address a VM received. Libvirt
|
||||
|
|
|
@ -81,7 +81,7 @@ module VagrantPlugins
|
|||
@driver_name = iface_configuration.fetch(:driver_name, false)
|
||||
@driver_iommu = iface_configuration.fetch(:driver_iommu, false )
|
||||
@driver_queues = iface_configuration.fetch(:driver_queues, false)
|
||||
@device_name = iface_configuration.fetch(:iface_name, false)
|
||||
@device_name = iface_configuration.fetch(:iface_name, nil)
|
||||
@mtu = iface_configuration.fetch(:mtu, nil)
|
||||
@pci_bus = iface_configuration.fetch(:bus, nil)
|
||||
@pci_slot = iface_configuration.fetch(:slot, nil)
|
||||
|
|
|
@ -70,6 +70,7 @@ module VagrantPlugins
|
|||
attr_accessor :management_network_mtu
|
||||
attr_accessor :management_network_keep
|
||||
attr_accessor :management_network_driver_iommu
|
||||
attr_accessor :management_network_iface_name
|
||||
attr_accessor :management_network_model_type
|
||||
|
||||
# System connection information
|
||||
|
@ -258,6 +259,7 @@ module VagrantPlugins
|
|||
@management_network_mtu = UNSET_VALUE
|
||||
@management_network_keep = UNSET_VALUE
|
||||
@management_network_driver_iommu = UNSET_VALUE
|
||||
@management_network_iface_name = UNSET_VALUE
|
||||
@management_network_model_type = UNSET_VALUE
|
||||
|
||||
# System connection information
|
||||
|
@ -973,6 +975,7 @@ module VagrantPlugins
|
|||
@management_network_mtu = nil if @management_network_mtu == UNSET_VALUE
|
||||
@management_network_keep = false if @management_network_keep == UNSET_VALUE
|
||||
@management_network_driver_iommu = false if @management_network_driver_iommu == UNSET_VALUE
|
||||
@management_network_iface_name = nil if @management_network_iface_name == UNSET_VALUE
|
||||
@management_network_model_type = 'virtio' if @management_network_model_type == UNSET_VALUE
|
||||
|
||||
# Domain specific settings.
|
||||
|
|
|
@ -34,6 +34,7 @@ module VagrantPlugins
|
|||
management_network_mtu = machine.provider_config.management_network_mtu
|
||||
management_network_keep = machine.provider_config.management_network_keep
|
||||
management_network_driver_iommu = machine.provider_config.management_network_driver_iommu
|
||||
management_network_iface_name = machine.provider_config.management_network_iface_name
|
||||
management_network_model_type = machine.provider_config.management_network_model_type
|
||||
logger.info "Using #{management_network_name} at #{management_network_address} as the management network #{management_network_mode} is the mode"
|
||||
|
||||
|
@ -79,6 +80,7 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
management_network_options[:driver_iommu] = management_network_driver_iommu
|
||||
management_network_options[:iface_name] = management_network_iface_name
|
||||
|
||||
unless management_network_mac.nil?
|
||||
management_network_options[:mac] = management_network_mac
|
||||
|
|
|
@ -92,6 +92,56 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateNetworkInterfaces do
|
|||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
|
||||
context 'management network' do
|
||||
let(:domain_xml) {
|
||||
# don't need full domain here, just enough for the network element to work
|
||||
<<-EOF.unindent
|
||||
<domain type='qemu'>
|
||||
<devices>
|
||||
<interface type='network'>
|
||||
<alias name='ua-net-0'/>
|
||||
<mac address='52:54:00:7d:14:0e'/>
|
||||
<source network='vagrant-libvirt'/>
|
||||
<target dev="myvnet0"></target>
|
||||
<model type='virtio'/>
|
||||
<driver iommu='off'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
|
||||
</interface>
|
||||
</devices>
|
||||
</domain>
|
||||
EOF
|
||||
}
|
||||
|
||||
before do
|
||||
allow(libvirt_domain).to receive(:xml_desc).and_return(domain_xml)
|
||||
end
|
||||
|
||||
context 'when iface name is set' do
|
||||
let(:vagrantfile_providerconfig) {
|
||||
<<-EOF
|
||||
libvirt.management_network_iface_name = 'myvnet0'
|
||||
EOF
|
||||
}
|
||||
let(:management_nic_xml) {
|
||||
<<-EOF.unindent
|
||||
<interface type="network">
|
||||
<alias name="ua-net-0"></alias>
|
||||
<source network="vagrant-libvirt"></source>
|
||||
<target dev="myvnet0"></target>
|
||||
<model type="virtio"></model>
|
||||
<driver iommu="off"></driver>
|
||||
</interface>
|
||||
EOF
|
||||
}
|
||||
|
||||
it 'should set target appropriately' do
|
||||
expect(driver).to receive(:attach_device).with(management_nic_xml)
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'private network' do
|
||||
let(:vagrantfile) do
|
||||
<<-EOF
|
||||
|
|
Loading…
Reference in New Issue
Block a user