Cleaner DHCP detection for Windows guests
This commit is contained in:
parent
728ec28f2d
commit
62f5be49d5
|
@ -24,13 +24,13 @@ module VagrantPlugins
|
||||||
#
|
#
|
||||||
# @return [Boolean]
|
# @return [Boolean]
|
||||||
def is_dhcp_enabled(nic_index)
|
def is_dhcp_enabled(nic_index)
|
||||||
has_dhcp_enabled = false
|
cmd = <<-EOH
|
||||||
cmd = "Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter \"Index=#{nic_index} and DHCPEnabled=True\""
|
if (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=#{nic_index} and DHCPEnabled=True") {
|
||||||
@communicator.execute(cmd) do |type, line|
|
exit 0
|
||||||
has_dhcp_enabled = !line.nil?
|
}
|
||||||
end
|
exit 1
|
||||||
@logger.debug("NIC #{nic_index} has DHCP enabled: #{has_dhcp_enabled}")
|
EOH
|
||||||
has_dhcp_enabled
|
@communicator.test(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Configures the specified interface for DHCP
|
# Configures the specified interface for DHCP
|
||||||
|
|
Loading…
Reference in New Issue