This commit creates a custom `read_dhcp_servers` method in the VirtualBox 6.1 driver to handle changes made in the ouput of `VBoxManage list dhcpservers`. Tests for VirtualBox 6.1+ can no longer use the shared examples for the VirtualBox 4.x driver, because the `read_dhcp_servers` change is not backwards compatible. This commit also creates the boilerplate for a VirtualBox 6.x shared example in case we want to put tests there in the future.
40 lines
1.2 KiB
Ruby
40 lines
1.2 KiB
Ruby
require File.expand_path("../version_6_0", __FILE__)
|
|
|
|
module VagrantPlugins
|
|
module ProviderVirtualBox
|
|
module Driver
|
|
# Driver for VirtualBox 6.1.x
|
|
class Version_6_1 < Version_6_0
|
|
def initialize(uuid)
|
|
super
|
|
|
|
@logger = Log4r::Logger.new("vagrant::provider::virtualbox_6_1")
|
|
end
|
|
|
|
def read_dhcp_servers
|
|
execute("list", "dhcpservers", retryable: true).split("\n\n").collect do |block|
|
|
info = {}
|
|
|
|
block.split("\n").each do |line|
|
|
if network = line[/^NetworkName:\s+HostInterfaceNetworking-(.+?)$/, 1]
|
|
info[:network] = network
|
|
info[:network_name] = "HostInterfaceNetworking-#{network}"
|
|
elsif ip = line[/^Dhcpd IP:\s+(.+?)$/, 1]
|
|
info[:ip] = ip
|
|
elsif netmask = line[/^NetworkMask:\s+(.+?)$/, 1]
|
|
info[:netmask] = netmask
|
|
elsif lower = line[/^LowerIPAddress:\s+(.+?)$/, 1]
|
|
info[:lower] = lower
|
|
elsif upper = line[/^UpperIPAddress:\s+(.+?)$/, 1]
|
|
info[:upper] = upper
|
|
end
|
|
end
|
|
|
|
info
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|