wbem 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ == 0.2.4
2
+
3
+ * Make CimXml::ObjectPath and Wsman::EndPointReference behave similar
4
+
1
5
  == 0.2.3
2
6
 
3
7
  * Make #instance_names return generic result
@@ -39,10 +39,6 @@ See the testsuite for more examples. Or run rake docs.
39
39
 
40
40
  * http://rdoc.info/projects/kkaempf/ruby-wbem
41
41
 
42
- === Code Metrics
43
-
44
- * http://getcaliper.com/caliper/project?repo=git%3A%2F%2Fgithub.com%2Fkkaempf%2Fruby-wbem.git
45
-
46
42
  == Authors
47
43
 
48
44
  * Klaus Kämpf <kkaempf@suse.de>
@@ -35,6 +35,7 @@ module Wbem
35
35
  STDERR.puts "Wbem::Client.connect(#{uri},#{protocol},#{auth_scheme})"
36
36
  unless uri.is_a?(URI)
37
37
  u = URI.parse(uri)
38
+ # u.port will be set in any case, so check the uri for port specification
38
39
  protocol_given = uri.match(/:\d/)
39
40
  else
40
41
  u = uri
@@ -55,9 +56,9 @@ module Wbem
55
56
  # no connect, check known ports
56
57
  case u.port
57
58
  when 8888, 8889, 5985, 5986
58
- return WsmanClient.new u, auth_scheme
59
+ return Wbem::Client.connect u, :wsman, auth_scheme
59
60
  when 5988, 5989
60
- return CimxmlClient.new u
61
+ return Wbem::Client.connect u, :cimxml, auth_scheme
61
62
  end
62
63
  # STDERR.puts "no known ports"
63
64
  port = u.port # keep orig port as we change u.port below
@@ -69,11 +70,7 @@ module Wbem
69
70
  if port == 443 && u.scheme == 'https' # https://hostname
70
71
  u.port = (protocol == :cimxml) ? 5989: 5986
71
72
  end
72
- c = Wbem::Client.connect u, protocol, auth_scheme
73
- if c
74
- # STDERR.puts "Connect #{u} as #{c}"
75
- return c
76
- end
73
+ Wbem::Client.connect u, protocol, auth_scheme
77
74
  end
78
75
  end
79
76
 
@@ -9,6 +9,18 @@
9
9
  #
10
10
  require "wbem/wbem"
11
11
 
12
+ module Sfcc
13
+ module Cim
14
+ class ObjectPath
15
+ def keys
16
+ res = []
17
+ each_key { |key| res << each_key }
18
+ res
19
+ end
20
+ end
21
+ end
22
+ end
23
+
12
24
  module Wbem
13
25
  class CimxmlClient < WbemClient
14
26
  require "sfcc"
@@ -34,14 +46,18 @@ private
34
46
  end
35
47
  public
36
48
 
49
+ #
50
+ # Initialize a CIMXML client connection
51
+ #
37
52
  def initialize url, auth_scheme = nil
38
53
  super url, auth_scheme
39
- STDERR.puts "CIMXML.connect >#{url}<"
40
54
  @client = Sfcc::Cim::Client.connect( { :uri => url, :verify => false } )
41
- STDERR.puts "CIMXML.connect #{url} -> #{@client}" if Wbem.debug
42
55
  _identify
43
56
  end
44
57
 
58
+ #
59
+ # Create ObjectPath from namespace and classname
60
+ #
45
61
  def objectpath namespace, classname = nil
46
62
  Sfcc::Cim::ObjectPath.new(namespace, classname)
47
63
  end
@@ -1,3 +1,3 @@
1
1
  module Wbem
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -27,6 +27,15 @@ module Openwsman
27
27
  @classname = classname
28
28
  end
29
29
  end
30
+ # Provide Cim::ObjectPath like accessors
31
+ class EndPointReference
32
+ alias keys selector_names
33
+ alias key_count selector_count
34
+ alias add_key add_selector
35
+ def each_key
36
+ keys.each { |key| yield key }
37
+ end
38
+ end
30
39
  end
31
40
 
32
41
  module Wbem
@@ -219,6 +228,7 @@ public
219
228
  end
220
229
 
221
230
  def instance_names namespace, classname
231
+ @options.flags = Openwsman::FLAG_ENUMERATION_ENUM_EPR # get EPRs
222
232
  @options.flags = Openwsman::FLAG_ENUMERATION_OPTIMIZATION
223
233
  @options.max_elements = 999
224
234
  @options.cim_namespace = namespace
@@ -229,13 +239,12 @@ public
229
239
  return []
230
240
  end
231
241
 
232
- instances = []
233
- result.Items.each do |item|
234
- item.add(nil, "namespace", namespace)
235
- item.add(nil, "classname", classname)
236
- instances << item
242
+ names = []
243
+ # expect <n:Item><a:EndpointReference>...
244
+ result.Items.each do |epr|
245
+ names << Openwsman::EndPointReference.new(epr)
237
246
  end
238
- return instances
247
+ return names
239
248
  end
240
249
 
241
250
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-13 00:00:00.000000000 Z
12
+ date: 2012-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yard
16
- requirement: &3187880 !ruby/object:Gem::Requirement
16
+ requirement: &5664800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.5'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *3187880
24
+ version_requirements: *5664800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sfcc
27
- requirement: &3187220 !ruby/object:Gem::Requirement
27
+ requirement: &5664240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,18 @@ dependencies:
32
32
  version: 0.3.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *3187220
35
+ version_requirements: *5664240
36
+ - !ruby/object:Gem::Dependency
37
+ name: openwsman
38
+ requirement: &5663640 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 0.3.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *5663640
36
47
  description: ruby-wbem allows to access a CIMOM transparently through CIM/XML or WS-Management
37
48
  email:
38
49
  - kkaempf@suse.de
@@ -73,3 +84,4 @@ signing_key:
73
84
  specification_version: 3
74
85
  summary: WBEM client for Ruby based on ruby-sfcc and openwsman
75
86
  test_files: []
87
+ has_rdoc: