Skip to content

Commit

Permalink
Support for network interfaces named by biosdevname
Browse files Browse the repository at this point in the history
Tested with Ubuntu 18.04 where interfaces start from ens3.
  • Loading branch information
Mika Båtsman committed Jan 11, 2021
1 parent e1bc04a commit 1d870df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Vagrant.configure("2") do |config|
:ovirt__network_name => 'ovirtmgmt' #DHCP
# Static configuration
#:ovirt__ip => '192.168.2.198', :ovirt__network_name => 'ovirtmgmt', :ovirt__gateway => '192.168.2.125', :ovirt__netmask => '255.255.0.0', :ovirt__dns_servers => '192.168.2.1', :ovirt__dns_search => 'test.local'
# Static configuration with biosdevname naming interfaces in format ensX, where X starts from 3
#:ovirt__ip => '192.168.2.198', :ovirt__network_name => 'ovirtmgmt', :ovirt__gateway => '192.168.2.125', :ovirt__netmask => '255.255.0.0', :ovirt__dns_servers => '192.168.2.1', :ovirt__dns_search => 'test.local', :ovirt__biosdevname => true
config.vm.provider :ovirt4 do |ovirt|
ovirt.url = 'https://server/ovirt-engine/api'
Expand Down
11 changes: 9 additions & 2 deletions lib/vagrant-ovirt4/action/start_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,16 @@ def call(env)
(0...configured_ifaces_options.length()).each do |iface_index|
iface_options = configured_ifaces_options[iface_index]

if iface_options[:biosdevname] then
prefix = 'ens'
iface_index = iface_index + 3
else
prefix = 'eth'
end

if iface_options[:ip] then
nic_configuration = {
name: "eth#{iface_index}",
name: "#{prefix}#{iface_index}",
on_boot: true,
boot_protocol: OvirtSDK4::BootProtocol::STATIC,
ip: {
Expand All @@ -60,7 +67,7 @@ def call(env)
}
else
nic_configuration = {
name: "eth#{iface_index}",
name: "#{prefix}#{iface_index}",
on_boot: true,
boot_protocol: OvirtSDK4::BootProtocol::DHCP,
}
Expand Down

0 comments on commit 1d870df

Please sign in to comment.