rbvmomi 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.4
1
+ 1.1.5
data/bin/rbvmomish CHANGED
@@ -43,7 +43,7 @@ rescue Errno::EHOSTUNREACH
43
43
  abort $!.message
44
44
  end
45
45
 
46
- typenames = VIM.instance_variable_get(:@typenames)
46
+ typenames = VIM.loader.typenames
47
47
  Readline.completion_append_character = " "
48
48
  Readline.completion_proc = lambda do |word|
49
49
  return unless word
data/examples/vdf.rb CHANGED
@@ -51,8 +51,8 @@ def b n
51
51
  unit(n,'B',3)
52
52
  end
53
53
 
54
- puts "Filesystem#{' '*43}Size Used Avail Use% Mounted on"
55
- fmt = "%-52s %-7s %-7s %-7s %-7s %s"
54
+ puts "Filesystem#{' '*53}Size Used Avail Use% Mounted on"
55
+ fmt = "%-62s %-8s %-8s %-8s %-8s %s"
56
56
 
57
57
  if false
58
58
  # simple version
@@ -211,6 +211,8 @@ class Connection < TrivialSoap
211
211
  fail "must be implemented in subclass"
212
212
  end
213
213
 
214
+ def self.loader; @loader; end
215
+
214
216
  protected
215
217
 
216
218
  def self.const_missing sym
@@ -233,6 +235,7 @@ protected
233
235
 
234
236
  def self.load_vmodl fn
235
237
  @loader = RbVmomi::TypeLoader.new self, fn
238
+ @loader.init
236
239
  end
237
240
  end
238
241
 
@@ -5,16 +5,25 @@ require 'set'
5
5
  module RbVmomi
6
6
 
7
7
  class TypeLoader
8
+ attr_reader :typenames
9
+
8
10
  def initialize target, fn
9
11
  @target = target
10
- @db = CDB.new fn
12
+ @fn = fn
13
+ end
14
+
15
+ def init
16
+ @db = CDB.new @fn
11
17
  @vmodl = Hash.new { |h,k| if e = @db[k] then h[k] = Marshal.load(e) end }
12
18
  @typenames = Set.new(Marshal.load(@db['_typenames']) + BasicTypes::BUILTIN)
13
19
  @target.constants.select { |x| has_type? x.to_s }.each { |x| load_type x.to_s }
14
20
  BasicTypes::BUILTIN.each do |x|
15
- target.const_set x, BasicTypes.const_get(x)
21
+ @target.const_set x, BasicTypes.const_get(x)
16
22
  load_extension x
17
23
  end
24
+ Object.constants.map(&:to_s).select { |x| has_type? x }.each do |x|
25
+ load_type x
26
+ end
18
27
  end
19
28
 
20
29
  def has_type? name
data/lib/rbvmomi/vim.rb CHANGED
@@ -33,7 +33,7 @@ class VIM < Connection
33
33
  new(opts).tap do |vim|
34
34
  vim.serviceContent.sessionManager.Login :userName => opts[:user], :password => opts[:password]
35
35
  rev = vim.serviceContent.about.apiVersion
36
- vim.rev = rev if %w(4.0 4.1).member? rev
36
+ vim.rev = [rev, '4.1'].min
37
37
  end
38
38
  end
39
39
 
data/test/test_misc.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'test/unit'
2
+ require 'rbvmomi'
3
+ VIM = RbVmomi::VIM unless Object.const_defined? :VIM
4
+
5
+ class MiscTest < Test::Unit::TestCase
6
+ def test_overridden_const
7
+ assert(VIM::SecurityError < RbVmomi::BasicTypes::Base)
8
+ assert_equal 'SecurityError', VIM::SecurityError.wsdl_name
9
+ end
10
+
11
+ # XXX
12
+ def disabled_test_dynamically_overridden_const
13
+ assert !VIM.const_defined?(:ClusterAttemptedVmInfo)
14
+ Object.const_set :ClusterAttemptedVmInfo, :override
15
+ assert VIM::ClusterAttemptedVmInfo.is_a?(Class)
16
+ assert(VIM::ClusterAttemptedVmInfo < RbVmomi::BasicTypes::Base)
17
+ assert_equal 'ClusterAttemptedVmInfo', VIM::ClusterAttemptedVmInfo.wsdl_name
18
+ end
19
+ end
20
+
data/vmodl.cdb CHANGED
Binary file
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 4
9
- version: 1.1.4
8
+ - 5
9
+ version: 1.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rich Lane
@@ -124,6 +124,7 @@ files:
124
124
  - test/test_deserialization.rb
125
125
  - test/test_emit_request.rb
126
126
  - test/test_exceptions.rb
127
+ - test/test_misc.rb
127
128
  - test/test_parse_response.rb
128
129
  - test/test_serialization.rb
129
130
  - vmodl.cdb
@@ -175,5 +176,6 @@ test_files:
175
176
  - test/test_deserialization.rb
176
177
  - test/test_emit_request.rb
177
178
  - test/test_exceptions.rb
179
+ - test/test_misc.rb
178
180
  - test/test_parse_response.rb
179
181
  - test/test_serialization.rb