wbem 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.2.0
2
+
3
+ * add 'class_names', supporting WINRM
4
+
1
5
  == 0.1.1
2
6
 
3
7
  * Unify 'identify'
data/lib/wbem/cimxml.rb CHANGED
@@ -61,8 +61,8 @@ public
61
61
  #
62
62
  # Return list of classnames for given namespace
63
63
  #
64
- def classnames namespace, deep_inheritance = false
65
- STDERR.puts "#{@client}.classnames(#{namespace})"
64
+ def class_names namespace, deep_inheritance = false
65
+ STDERR.puts "#{@client}.class_names(#{namespace})"
66
66
  ret = []
67
67
  op = Sfcc::Cim::ObjectPath.new(namespace)
68
68
  flags = deep_inheritance ? Sfcc::Flags::DeepInheritance : 0
data/lib/wbem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wbem
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/wbem/wbem.rb CHANGED
@@ -34,8 +34,10 @@ module Wbem
34
34
  end
35
35
 
36
36
  private
37
+ # assemble all namespaces
37
38
  def _namespaces ns, cn
38
39
  result = nil
40
+ # each_instance is the downcall to cimxml or wsman
39
41
  each_instance( ns, cn ) do |inst|
40
42
  result ||= [ns]
41
43
  name = "#{ns}/#{inst.Name}"
@@ -60,8 +62,8 @@ public
60
62
  end
61
63
 
62
64
  # return list of classnames for namespace ns
63
- def classnames ns, deep_inheritance=false
64
- raise "#{self.class}.classnames not implemented"
65
+ def class_names ns, deep_inheritance=false
66
+ raise "#{self.class}.class_names not implemented"
65
67
  end
66
68
 
67
69
  def instance_names classname
data/lib/wbem/wsman.rb CHANGED
@@ -138,26 +138,59 @@ public
138
138
  end if items
139
139
  end
140
140
 
141
- def classnames namespace, deep_inheritance
142
- # enum_classnames is Openwsman-specific
143
- unless @product_vendor =~ /Openwsman/ && @product_version >= "2.2"
144
- STDERR.puts "ENUMERATE_CLASS_NAMES unsupported for #{@product_vendor} #{@product_version}"
145
- return []
146
- end
141
+ def class_names namespace, deep_inheritance = false
147
142
  @options.flags = Openwsman::FLAG_ENUMERATION_OPTIMIZATION
148
143
  @options.max_elements = 999
149
144
  @options.cim_namespace = namespace
150
- method = Openwsman::CIM_ACTION_ENUMERATE_CLASS_NAMES
151
- uri = Openwsman::XML_NS_CIM_INTRINSIC
152
- result = @client.invoke( @options, uri, method )
145
+ case @product
146
+ when :openwsman
147
+ unless @product_version >= "2.2"
148
+ STDERR.puts "ENUMERATE_CLASS_NAMES unsupported for #{@product_vendor} #{@product_version}, please upgrade"
149
+ return []
150
+ end
151
+ method = Openwsman::CIM_ACTION_ENUMERATE_CLASS_NAMES
152
+ uri = Openwsman::XML_NS_CIM_INTRINSIC
153
+ @options.add_selector("DeepInheritance", "True") if deep_inheritance
154
+ result = @client.invoke( @options, uri, method )
155
+ when :winrm
156
+ # see https://github.com/kkaempf/openwsman/blob/master/bindings/ruby/tests/winenum.rb
157
+ filter = Openwsman::Filter.new
158
+ query = "select * from meta_class"
159
+ query << " where __SuperClass is null" unless deep_inheritance
160
+ filter.wql query
161
+ uri = "#{@prefix}#{namespace}/*"
162
+ result = @client.enumerate( @options, filter, uri )
163
+ else
164
+ raise "Unsupported for WSMAN product #{@product}"
165
+ end
166
+
153
167
  if result.fault?
154
168
  puts "Enumerate class names (#{uri}) failed:\n\tResult code #{@client.response_code}, Fault: #{@client.fault_string}"
155
169
  return []
156
170
  end
157
- output = result.body[method]
171
+
158
172
  classes = []
159
- output.each do |c|
160
- classes << c.to_s
173
+
174
+ case @product
175
+ when :openwsman
176
+ # extract invoke result
177
+ output = result.body[method]
178
+ output.each do |c|
179
+ classes << c.to_s
180
+ end
181
+ when :winrm
182
+ # extract enumerate/pull result
183
+ loop do
184
+ output = result.Items
185
+ output.each do |node|
186
+ classes << node.name.to_s
187
+ end if output
188
+ context = result.context
189
+ break unless context
190
+ # get the next chunk
191
+ result = @client.pull( @options, nil, uri, context)
192
+ break unless result
193
+ end
161
194
  end
162
195
  return classes
163
196
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbem
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Klaus K\xC3\xA4mpf"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-18 00:00:00 +01:00
18
+ date: 2012-02-10 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency