Module: Facter::Util::WMI

Defined in:
lib/facter/util/wmi.rb

Constant Summary collapse

RPC_C_IMP_LEVEL_DEFAULT =
0
RPC_C_IMP_LEVEL_ANONYMOUS =
1
RPC_C_IMP_LEVEL_IDENTIFY =
2
RPC_C_IMP_LEVEL_IMPERSONATE =
3
RPC_C_IMP_LEVEL_DELEGATE =
4

Class Method Summary collapse

Class Method Details

.connect(uri = nil) ⇒ Object

returns a COM class implementing ISWbemServicesEx prior to Facter 2.5.0, this defaulted to using a moniker but now defaults to using COM classes directly to support Nano backward compatibility is maintained in case custom facts specified a moniker but note that passing in the uri parameter can never work on Nano



17
18
19
20
21
22
23
# File 'lib/facter/util/wmi.rb', line 17

def connect(uri = nil)
  require 'win32ole'
  uri.nil? ?
    connect2() :
    # NOTE: in the future it would be better to parse a given moniker uri / call connect2
    WIN32OLE.connect(uri)
end

.execquery(query) ⇒ Object



30
31
32
# File 'lib/facter/util/wmi.rb', line 30

def execquery(query)
  connect().execquery(query)
end

.wmi_resource_uri(host = '.') ⇒ Object

Deprecated.


26
27
28
# File 'lib/facter/util/wmi.rb', line 26

def wmi_resource_uri( host = '.' )
  "winmgmts:{impersonationLevel=impersonate}!//#{host}/root/cimv2"
end