lib/wbem/wsman.rb in wbem-0.2.3 vs lib/wbem/wsman.rb in wbem-0.2.4
- old
+ new
@@ -25,10 +25,19 @@
def initialize namespace, classname = nil
@namespace = namespace
@classname = classname
end
end
+ # Provide Cim::ObjectPath like accessors
+ class EndPointReference
+ alias keys selector_names
+ alias key_count selector_count
+ alias add_key add_selector
+ def each_key
+ keys.each { |key| yield key }
+ end
+ end
end
module Wbem
class WsmanClient < WbemClient
private
@@ -217,26 +226,26 @@
end
return classes
end
def instance_names namespace, classname
+ @options.flags = Openwsman::FLAG_ENUMERATION_ENUM_EPR # get EPRs
@options.flags = Openwsman::FLAG_ENUMERATION_OPTIMIZATION
@options.max_elements = 999
@options.cim_namespace = namespace
uri = Openwsman::epr_prefix_for(classname, namespace) + "/#{classname}"
result = @client.enumerate( @options, nil, uri )
if result.fault?
puts "Enumerate instances (#{uri}) failed:\n\tResult code #{@client.response_code}, Fault: #{@client.fault_string}"
return []
end
- instances = []
- result.Items.each do |item|
- item.add(nil, "namespace", namespace)
- item.add(nil, "classname", classname)
- instances << item
+ names = []
+ # expect <n:Item><a:EndpointReference>...
+ result.Items.each do |epr|
+ names << Openwsman::EndPointReference.new(epr)
end
- return instances
+ return names
end
end
end # module
\ No newline at end of file