lib/wbem/wsman.rb in wbem-0.1.0 vs lib/wbem/wsman.rb in wbem-0.1.1

- old
+ new

@@ -29,10 +29,31 @@ end end module Wbem class WsmanClient < WbemClient +private + # + # WS-Identify + # returns Openwsman::XmlDoc + # + def _identify + STDERR.puts "Identify client #{@client} with #{@options}" if Wbem.debug + doc = @client.identify( @options ) + unless doc + raise RuntimeError.new "Identify failed: HTTP #{@client.response_code}, Err #{@client.last_error}:#{@client.fault_string}" + end + if doc.fault? + fault = doc.fault + STDERR.puts "Fault: #{fault.to_xml}" + raise fault.to_s + end +# STDERR.puts "Return #{doc.to_xml}" + doc + end +public + def initialize uri super uri @url.path = "/wsman" if @url.path.nil? || @url.path.empty? # Openwsman::debug = -1 STDERR.puts "WsmanClient connecting to #{uri}" if Wbem.debug @@ -45,11 +66,11 @@ # FIXME # @client.transport.auth_method = (@url.scheme == 'http') ? Openwsman::BASIC_AUTH_STR : Openwsman::DIGEST_AUTH_STR @client.transport.auth_method = Openwsman::BASIC_AUTH_STR @options = Openwsman::ClientOptions.new - doc = identify + doc = _identify # STDERR.puts doc.to_xml @protocol_version = doc.ProtocolVersion.text @product_vendor = doc.ProductVendor.text @product_version = doc.ProductVersion.text if Wbem.debug @@ -101,28 +122,9 @@ def objectpath classname, namespace Openwsman::ObjectPath.new classname, namespace end - # - # WS-Identify - # returns Openwsman::XmlDoc - # - def identify - STDERR.puts "Identify client #{@client} with #{@options}" if Wbem.debug - doc = @client.identify( @options ) - unless doc - raise RuntimeError.new "Identify failed: HTTP #{@client.response_code}, Err #{@client.last_error}:#{@client.fault_string}" - end - if doc.fault? - fault = doc.fault - STDERR.puts "Fault: #{fault.to_xml}" - raise fault.to_s - end -# STDERR.puts "Return #{doc.to_xml}" - doc - end - def each_instance( ns, cn ) @options.flags = Openwsman::FLAG_ENUMERATION_OPTIMIZATION @options.max_elements = 999 resource = "#{@prefix}#{ns}/#{cn}" result = @client.enumerate( @options, nil, resource ) \ No newline at end of file