Class: Wbem::WbemClient

Inherits:
Object
  • Object
show all
Defined in:
lib/wbem/wbem.rb

Overview

WbemClient - base class for CimxmlClient and WsmanClient

Direct Known Subclasses

CimxmlClient, WsmanClient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, auth_scheme = :basic) ⇒ WbemClient



21
22
23
24
# File 'lib/wbem/wbem.rb', line 21

def initialize url, auth_scheme = :basic
  @url = (url.is_a? URI) ? url : URI.parse(url)
  @auth_scheme = auth_scheme.to_s.to_sym
end

Instance Attribute Details

#auth_schemeObject

Returns the value of attribute auth_scheme



19
20
21
# File 'lib/wbem/wbem.rb', line 19

def auth_scheme
  @auth_scheme
end

#productObject (readonly)

Returns the value of attribute product



18
19
20
# File 'lib/wbem/wbem.rb', line 18

def product
  @product
end

#responseObject (readonly)

Returns the value of attribute response



17
18
19
# File 'lib/wbem/wbem.rb', line 17

def response
  @response
end

#urlObject (readonly)

Returns the value of attribute url



17
18
19
# File 'lib/wbem/wbem.rb', line 17

def url
  @url
end

Instance Method Details

#class_names(ns, deep_inheritance = false) ⇒ Object

return list of classnames for namespace ns



67
68
69
# File 'lib/wbem/wbem.rb', line 67

def class_names ns, deep_inheritance=false
  raise "#{self.class}.class_names not implemented"
end

#fault_stringObject



30
31
32
# File 'lib/wbem/wbem.rb', line 30

def fault_string
  @client.fault_string
end

#namespacesObject

return list of namespaces



55
56
57
58
59
60
61
62
63
64
# File 'lib/wbem/wbem.rb', line 55

def namespaces
  STDERR.puts "Namespaces for #{@url}"
  result = []
  ['root', 'Interop', 'interop'].each do |ns|
    ["CIM_Namespace", "__Namespace", "__NAMESPACE"].each do |cn|
      result.concat(_namespaces ns, cn)
    end
  end
  result.uniq
end

#network_class_nameObject



98
99
100
101
102
103
104
105
# File 'lib/wbem/wbem.rb', line 98

def network_class_name
  case @product
  when :winrm then "Win32_NetworkAdapter"
  when :iamt then "CIM_NetworkPort"
  else
    "CIM_NetworkAdapter"
  end
end

#networks(ns = "root/cimv2") ⇒ Object



106
107
108
109
# File 'lib/wbem/wbem.rb', line 106

def networks ns="root/cimv2"
  ns = "" if @product == :iamt
  instance_names ns, network_class_name
end

#objectpath(namespace, classname) ⇒ Object



34
35
36
# File 'lib/wbem/wbem.rb', line 34

def objectpath namespace, classname
  raise "#{self.class}.objectpath not implemented"
end

#processes(ns = "root/cimv2") ⇒ Object



94
95
96
97
# File 'lib/wbem/wbem.rb', line 94

def processes ns="root/cimv2"
  ns = "" if @product == :iamt
  instance_names ns, (@product == :winrm) ? "Win32_Process" : "CIM_Process"
end

#response_codeObject



26
27
28
# File 'lib/wbem/wbem.rb', line 26

def response_code
  @client.response_code
end

#service_class_nameObject



83
84
85
86
87
88
89
# File 'lib/wbem/wbem.rb', line 83

def service_class_name
  case @product
  when :winrm then "Win32_Service"
  else
    "CIM_Service"
  end
end

#services(ns = "root/cimv2") ⇒ Object



90
91
92
93
# File 'lib/wbem/wbem.rb', line 90

def services ns="root/cimv2"
  ns = "" if @product == :iamt
  instance_names ns, service_class_name
end

#storage_class_nameObject



110
111
112
113
114
115
116
117
# File 'lib/wbem/wbem.rb', line 110

def storage_class_name
  case @product
  when :winrm then "Win32_DiskDrive"
  when :iamt then "CIM_StorageExtent"
  else
    "CIM_DiskDrive"
  end
end

#storages(ns = "root/cimv2") ⇒ Object



118
119
120
121
# File 'lib/wbem/wbem.rb', line 118

def storages ns="root/cimv2"
  ns = "" if @product == :iamt
  instance_names ns, storage_class_name
end

#system_class_nameObject



71
72
73
74
75
76
77
# File 'lib/wbem/wbem.rb', line 71

def system_class_name
  case @product
  when :winrm then "Win32_ComputerSystem"
  else
    "CIM_ComputerSystem"
  end
end

#systems(ns = "root/cimv2") ⇒ Object



78
79
80
81
# File 'lib/wbem/wbem.rb', line 78

def systems ns="root/cimv2"
  ns = "" if @product == :iamt
  instance_names ns, system_class_name
end