<commit_before>require "log4r"

module VagrantPlugins
  module GuestWindows
    # Manages the remote Windows guest network.
    class GuestNetwork
      PS_GET_WSMAN_VER = '((test-wsman).productversion.split(" ") | select -last 1).split("\.")[0]'
      WQL_NET_ADAPTERS_V2 = 'SELECT * FROM Win32_NetworkAdapter WHERE MACAddress IS NOT NULL'

      def initialize(communicator)
        @logger       = Log4r::Logger.new("vagrant::windows::guestnetwork")
        @communicator = communicator
      end

      # Returns an array of all NICs on the guest. Each array entry is a
      # Hash of the NICs properties.
      #
      # @return [Array]
      def network_adapters
        wsman_version == 2? network_adapters_v2_winrm : network_adapters_v3_winrm
      end

      # Checks to see if the specified NIC is currently configured for DHCP.
      #
      # @return [Boolean]
      def is_dhcp_enabled(nic_index)
        cmd = <<-EOH
          if (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=#{nic_index} and DHCPEnabled=True") {
            exit 0
          }
          exit 1
        EOH
        @communicator.test(cmd, { shell: :powershell })
      end

      # Configures the specified interface for DHCP<commit_msg>test() defaults to powershell for winssh, no need to pass it<commit_after>require "log4r"

module VagrantPlugins
  module GuestWindows
    # Manages the remote Windows guest network.
    class GuestNetwork
      PS_GET_WSMAN_VER = '((test-wsman).productversion.split(" ") | select -last 1).split("\.")[0]'
      WQL_NET_ADAPTERS_V2 = 'SELECT * FROM Win32_NetworkAdapter WHERE MACAddress IS NOT NULL'

      def initialize(communicator)
        @logger       = Log4r::Logger.new("vagrant::windows::guestnetwork")
        @communicator = communicator
      end

      # Returns an array of all NICs on the guest. Each array entry is a
      # Hash of the NICs properties.
      #
      # @return [Array]
      def network_adapters
        wsman_version == 2? network_adapters_v2_winrm : network_adapters_v3_winrm
      end

      # Checks to see if the specified NIC is currently configured for DHCP.
      #
      # @return [Boolean]
      def is_dhcp_enabled(nic_index)
        cmd = <<-EOH
          if (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "Index=#{nic_index} and DHCPEnabled=True") {
            exit 0
          }
          exit 1
        EOH
        @communicator.test(cmd)
      end

      # Configures the specified interface for DHCP
{'fraction_non_alphanumeric': 0.08124253285543608, 'fraction_numerical': 0.011150935882118677, 'mean_word_length': 2.553041018387553, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1996809', 'n_tokens_mistral': 791, 'n_tokens_neox': 743, 'n_words': 215}