Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions lib/vagrant-parallels/action/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,20 +444,18 @@ def hostonly_create_network(config)

# This finds a matching host only network for the given configuration.
def hostonly_find_matching_network(config)
existing = @env[:machine].provider.driver.read_host_only_interfaces
this_netaddr = network_address(config[:ip], config[:netmask])

if config[:name]
# Search networks strongly by specified name
matched_iface = existing.detect { |i| config[:name] == i[:name] }
else
# Name is not specified - search by network address
this_netaddr = network_address(config[:ip], config[:netmask])
matched_iface = existing.detect do |i|
this_netaddr == network_address(i[:ip], i[:netmask])
@env[:machine].provider.driver.read_host_only_interfaces.each do |interface|
return interface if config[:name] && config[:name] == interface[:name]

if interface[:ip]
return interface if this_netaddr == \
network_address(interface[:ip], interface[:netmask])
end
end

matched_iface || nil
nil
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions lib/vagrant-parallels/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ def read_host_info
end

# Returns a list of available host only interfaces.
# Each interface is represented as a Hash with the following details:
#
# {
# name: 'Host-Only', # Parallels Network ID
# bound_to: 'vnic1', # interface name
# ip: '10.37.129.2', # IP address of the interface
# netmask: '255.255.255.0', # netmask associated with the interface
# status: 'Up' # status of the interface
# }
#
# @return [Array<Symbol => String>]
def read_host_only_interfaces
Expand Down
11 changes: 0 additions & 11 deletions lib/vagrant-parallels/driver/pd_10.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,6 @@ def read_host_only_interfaces
iface[:status] = 'Up'
end

# There may be a fake DHCPv4 parameters
# We can trust them only if adapter IP and DHCP IP are in the same subnet
dhcp_info = net_info['DHCPv4 server']
if dhcp_info && (network_address(iface[:ip], iface[:netmask]) ==
network_address(dhcp_info['Server address'], iface[:netmask]))
iface[:dhcp] = {
ip: dhcp_info['Server address'],
lower: dhcp_info['IP scope start address'],
upper: dhcp_info['IP scope end address']
}
end
hostonly_ifaces << iface
end
hostonly_ifaces
Expand Down
11 changes: 0 additions & 11 deletions lib/vagrant-parallels/driver/pd_8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,6 @@ def read_host_only_interfaces
iface[:status] = 'Up'
end

# There may be a fake DHCPv4 parameters
# We can trust them only if adapter IP and DHCP IP are in the same subnet
dhcp_info = net_info['DHCPv4 server']
if dhcp_info && (network_address(iface[:ip], iface[:netmask]) ==
network_address(dhcp_info['Server address'], iface[:netmask]))
iface[:dhcp] = {
ip: dhcp_info['Server address'],
lower: dhcp_info['IP scope start address'],
upper: dhcp_info['IP scope end address']
}
end
hostonly_ifaces << iface
end
hostonly_ifaces
Expand Down