Cleaner DHCP detection for Windows guests

This commit is contained in:
Shawn Neal 2014-04-22 13:28:51 -07:00
parent 728ec28f2d
commit 62f5be49d5
1 changed files with 7 additions and 7 deletions

View File

@ -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