Class: Wbem::WbemClient
- Inherits:
-
Object
- Object
- Wbem::WbemClient
- Defined in:
- lib/wbem/wbem.rb,
lib/wbem/wbem.rb
Overview
WbemClient - base class for CimxmlClient and WsmanClient
Direct Known Subclasses
Instance Attribute Summary collapse
-
#auth_scheme ⇒ Object
Returns the value of attribute auth_scheme.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#class_names(op, deep_inheritance = false) ⇒ Object
return list of classnames for ObjectPath op.
-
#enumerate(classname) ⇒ Object
Enumerate class refs Returns Array of Instance References (Sfcc::Cim::ObjectPath or Openwsman::EndPointReference).
- #factory ⇒ Object
- #fault_string ⇒ Object
-
#get(instance_reference, keys = nil) ⇒ Object
get instance by reference.
-
#initialize(url, auth_scheme = :basic) ⇒ WbemClient
constructor
A new instance of WbemClient.
-
#network_class_name ⇒ Object
NetworkAdapter, NetworkPort.
- #networks(ns = "root/cimv2") ⇒ Object
- #objectpath(namespace, classname) ⇒ Object
- #processes(ns = "root/cimv2") ⇒ Object
-
#profile_class_name ⇒ Object
RegisteredProfile.
- #profiles(ns = "root/cimv2") ⇒ Object
- #response_code ⇒ Object
-
#service_class_name ⇒ Object
Service.
- #services(ns = "root/cimv2") ⇒ Object
-
#storage_class_name ⇒ Object
DiskDrive, StorageExtent.
- #storages(ns = "root/cimv2") ⇒ Object
-
#system_class_name ⇒ Object
ComputerSystem.
- #systems(ns = "root/cimv2") ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(url, auth_scheme = :basic) ⇒ WbemClient
Returns a new instance of WbemClient.
25 26 27 28 |
# File 'lib/wbem/wbem.rb', line 25 def initialize url, auth_scheme = :basic @url = (url.is_a? URI) ? url : URI.parse(url) @auth_scheme = auth_scheme.to_s.to_sym rescue nil end |
Instance Attribute Details
#auth_scheme ⇒ Object
Returns the value of attribute auth_scheme.
23 24 25 |
# File 'lib/wbem/wbem.rb', line 23 def auth_scheme @auth_scheme end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
22 23 24 |
# File 'lib/wbem/wbem.rb', line 22 def product @product end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
21 22 23 |
# File 'lib/wbem/wbem.rb', line 21 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
21 22 23 |
# File 'lib/wbem/wbem.rb', line 21 def url @url end |
Instance Method Details
#class_names(op, deep_inheritance = false) ⇒ Object
return list of classnames for ObjectPath op
52 53 54 |
# File 'lib/wbem/wbem.rb', line 52 def class_names op, deep_inheritance=false raise "#{self.class}.class_names not implemented" end |
#enumerate(classname) ⇒ Object
Enumerate class refs Returns Array of Instance References (Sfcc::Cim::ObjectPath or Openwsman::EndPointReference)
60 61 62 |
# File 'lib/wbem/wbem.rb', line 60 def enumerate classname raise "#{self.class}.enumerate not implemented" end |
#factory ⇒ Object
30 31 32 |
# File 'lib/wbem/wbem.rb', line 30 def factory @factory ||= Wbem::ClassFactory.new end |
#fault_string ⇒ Object
38 39 40 |
# File 'lib/wbem/wbem.rb', line 38 def fault_string @client.fault_string end |
#get(instance_reference, keys = nil) ⇒ Object
get instance by reference
call-seq
get Openwsman::EndPointReference -> Wbem::Instance
get Sfcc::Cim::ObjectPath -> Wbem::Instance
get EndPointReference-as-String -> Wbem::Instance
get ObjectPath-as-String -> Wbem::Instance
get "ClassName", "key" => "value", :namespace => "root/interop"
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/wbem/wbem.rb', line 74 def get instance_reference, keys = nil if keys if self.class == Wbem::WsmanClient uri = Openwsman.epr_uri_for "", instance_reference instance_reference = Openwsman::EndPointReference.new(uri, nil, keys) elsif self.class == Wbem::CimxmlClient namespace = keys.delete(:namespace) || "root/cimv2" instance_reference = Sfcc::Cim::ObjectPath.new(namespace, instance_reference) keys.each do |k,v| instance_reference.add_key k, v end end end puts "@client.get #{instance_reference.class}..." if Wbem.debug case instance_reference when Openwsman::EndPointReference get_by_epr instance_reference when Sfcc::Cim::ObjectPath get_by_objectpath instance_reference when String if self.class == WsmanClient get_by_epr Openwsman::EndPointReference.new(instance_reference) elsif self.class == CimxmlClient get_by_objectpath CimxmlClient.parse_object_path(instance_reference) else raise "Unsupported Wbem::get #{instance_reference.class} for #{self.class}" end else raise "Unsupported Wbem::get #{instance_reference.class}" end end |
#network_class_name ⇒ Object
NetworkAdapter, NetworkPort
153 154 155 156 157 158 159 160 |
# File 'lib/wbem/wbem.rb', line 153 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
161 162 163 164 |
# File 'lib/wbem/wbem.rb', line 161 def networks ns="root/cimv2" ns = "" if @product == :iamt instance_names ns, network_class_name end |
#objectpath(namespace, classname) ⇒ Object
42 43 44 |
# File 'lib/wbem/wbem.rb', line 42 def objectpath namespace, classname raise "#{self.class}.objectpath not implemented" end |
#processes(ns = "root/cimv2") ⇒ Object
145 146 147 148 |
# File 'lib/wbem/wbem.rb', line 145 def processes ns="root/cimv2" ns = "" if @product == :iamt instance_names ns, (@product == :winrm) ? "Win32_Process" : "CIM_Process" end |
#profile_class_name ⇒ Object
RegisteredProfile
123 124 125 |
# File 'lib/wbem/wbem.rb', line 123 def profile_class_name "CIM_RegisteredProfile" end |
#profiles(ns = "root/cimv2") ⇒ Object
126 127 128 129 |
# File 'lib/wbem/wbem.rb', line 126 def profiles ns="root/cimv2" ns = "" if @product == :iamt instance_names ns, profile_class_name end |
#response_code ⇒ Object
34 35 36 |
# File 'lib/wbem/wbem.rb', line 34 def response_code @client.response_code end |
#service_class_name ⇒ Object
Service
134 135 136 137 138 139 140 |
# File 'lib/wbem/wbem.rb', line 134 def service_class_name case @product when :winrm then "Win32_Service" else "CIM_Service" end end |
#services(ns = "root/cimv2") ⇒ Object
141 142 143 144 |
# File 'lib/wbem/wbem.rb', line 141 def services ns="root/cimv2" ns = "" if @product == :iamt instance_names ns, service_class_name end |
#storage_class_name ⇒ Object
DiskDrive, StorageExtent
169 170 171 172 173 174 175 176 |
# File 'lib/wbem/wbem.rb', line 169 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
177 178 179 180 |
# File 'lib/wbem/wbem.rb', line 177 def storages ns="root/cimv2" ns = "" if @product == :iamt instance_names ns, storage_class_name end |
#system_class_name ⇒ Object
ComputerSystem
108 109 110 111 112 113 114 |
# File 'lib/wbem/wbem.rb', line 108 def system_class_name case @product when :winrm then "Win32_ComputerSystem" else "CIM_ComputerSystem" end end |
#systems(ns = "root/cimv2") ⇒ Object
115 116 117 118 |
# File 'lib/wbem/wbem.rb', line 115 def systems ns="root/cimv2" ns = "" if @product == :iamt instance_names ns, system_class_name end |
#to_s ⇒ Object
46 47 48 |
# File 'lib/wbem/wbem.rb', line 46 def to_s "#{@product}(#{@url})" end |