rbvmomi 1.1.8 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -2
- data/VERSION +1 -1
- data/examples/create_vm-1.9.rb +2 -3
- data/lib/rbvmomi/connection.rb +10 -1
- data/lib/rbvmomi/trollop.rb +1 -1
- data/lib/rbvmomi/type_loader.rb +15 -6
- data/lib/rbvmomi/vim.rb +1 -1
- data/test/test_deserialization.rb +2 -2
- data/{vmodl.cdb → vmodl.db} +0 -0
- metadata +7 -27
data/Rakefile
CHANGED
@@ -14,9 +14,8 @@ begin
|
|
14
14
|
gem.add_dependency 'nokogiri', '>= 1.4.1'
|
15
15
|
gem.add_dependency 'builder'
|
16
16
|
gem.add_dependency 'trollop'
|
17
|
-
gem.add_dependency 'cdb-full'
|
18
17
|
gem.required_ruby_version = '>= 1.8.7'
|
19
|
-
gem.files.include 'vmodl.
|
18
|
+
gem.files.include 'vmodl.db'
|
20
19
|
gem.files.include '.yardopts'
|
21
20
|
end
|
22
21
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/examples/create_vm-1.9.rb
CHANGED
@@ -4,14 +4,13 @@ require 'rbvmomi'
|
|
4
4
|
require 'rbvmomi/trollop'
|
5
5
|
|
6
6
|
VIM = RbVmomi::VIM
|
7
|
-
N = 2
|
8
7
|
|
9
8
|
opts = Trollop.options do
|
10
9
|
banner <<-EOS
|
11
|
-
Create
|
10
|
+
Create a VM.
|
12
11
|
|
13
12
|
Usage:
|
14
|
-
create_vm.rb [options]
|
13
|
+
create_vm-1.9.rb [options]
|
15
14
|
|
16
15
|
VIM connection options:
|
17
16
|
EOS
|
data/lib/rbvmomi/connection.rb
CHANGED
@@ -7,6 +7,8 @@ require 'rbvmomi/type_loader'
|
|
7
7
|
|
8
8
|
module RbVmomi
|
9
9
|
|
10
|
+
IS_JRUBY = RUBY_PLATFORM == 'java'
|
11
|
+
|
10
12
|
class DeserializationFailed < Exception; end
|
11
13
|
|
12
14
|
class Connection < TrivialSoap
|
@@ -78,7 +80,14 @@ class Connection < TrivialSoap
|
|
78
80
|
end
|
79
81
|
|
80
82
|
def xml2obj xml, typename
|
81
|
-
|
83
|
+
if IS_JRUBY
|
84
|
+
type_attr = xml.attribute_nodes.find { |a| a.name == 'type' &&
|
85
|
+
a.namespace &&
|
86
|
+
a.namespace.prefix == 'xsi' }
|
87
|
+
else
|
88
|
+
type_attr = xml.attribute_with_ns('type', NS_XSI)
|
89
|
+
end
|
90
|
+
typename = (type_attr || typename).to_s
|
82
91
|
|
83
92
|
if typename =~ /^ArrayOf/
|
84
93
|
typename = demangle_array_type $'
|
data/lib/rbvmomi/trollop.rb
CHANGED
@@ -56,7 +56,7 @@ class Parser
|
|
56
56
|
# !!!plain
|
57
57
|
# computer: -R --computer RBVMOMI_COMPUTER
|
58
58
|
def rbvmomi_computer_opt
|
59
|
-
opt :computer, "Compute resource", :type => :string, :short => "R", :default => ENV['RBVMOMI_COMPUTER']
|
59
|
+
opt :computer, "Compute resource", :type => :string, :short => "R", :default => (ENV['RBVMOMI_COMPUTER']||'ha-compute-res')
|
60
60
|
end
|
61
61
|
|
62
62
|
# Select a datastore
|
data/lib/rbvmomi/type_loader.rb
CHANGED
@@ -1,21 +1,30 @@
|
|
1
1
|
# Copyright (c) 2010 VMware, Inc. All Rights Reserved.
|
2
|
-
require 'cdb'
|
3
2
|
require 'set'
|
4
3
|
|
5
4
|
module RbVmomi
|
6
5
|
|
6
|
+
class TypeStore
|
7
|
+
def initialize fn
|
8
|
+
File.open(fn, 'r') do |io|
|
9
|
+
@db = Marshal.load io
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def [](k)
|
14
|
+
@db[k]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
7
18
|
class TypeLoader
|
8
19
|
attr_reader :typenames
|
9
20
|
|
10
21
|
def initialize target, fn
|
11
22
|
@target = target
|
12
|
-
@
|
23
|
+
@db = TypeStore.new fn
|
13
24
|
end
|
14
25
|
|
15
26
|
def init
|
16
|
-
@
|
17
|
-
@vmodl = Hash.new { |h,k| if e = @db[k] then h[k] = Marshal.load(e) end }
|
18
|
-
@typenames = Set.new(Marshal.load(@db['_typenames']) + BasicTypes::BUILTIN)
|
27
|
+
@typenames = Set.new(@db['_typenames'] + BasicTypes::BUILTIN)
|
19
28
|
@target.constants.select { |x| has_type? x.to_s }.each { |x| load_type x.to_s }
|
20
29
|
BasicTypes::BUILTIN.each do |x|
|
21
30
|
@target.const_set x, BasicTypes.const_get(x)
|
@@ -50,7 +59,7 @@ class TypeLoader
|
|
50
59
|
def make_type name
|
51
60
|
name = name.to_s
|
52
61
|
fail if BasicTypes::BUILTIN.member? name
|
53
|
-
desc = @
|
62
|
+
desc = @db[name] or fail "unknown VMODL type #{name}"
|
54
63
|
case desc['kind']
|
55
64
|
when 'data' then make_data_type name, desc
|
56
65
|
when 'managed' then make_managed_type name, desc
|
data/lib/rbvmomi/vim.rb
CHANGED
@@ -118,8 +118,8 @@ def test_empty_array
|
|
118
118
|
:linkUp => true,
|
119
119
|
:blocked => false,
|
120
120
|
:vlanIds => [],
|
121
|
-
vmDirectPathGen2InactiveReasonNetwork
|
122
|
-
vmDirectPathGen2InactiveReasonOther
|
121
|
+
:vmDirectPathGen2InactiveReasonNetwork => [],
|
122
|
+
:vmDirectPathGen2InactiveReasonOther => []
|
123
123
|
)
|
124
124
|
|
125
125
|
check <<-EOS, obj, 'DVPortStatus'
|
data/{vmodl.cdb → vmodl.db}
RENAMED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbvmomi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 1.2.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Rich Lane
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-17 00:00:00 -07:00
|
19
18
|
default_executable: rbvmomish
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
28
|
segments:
|
31
29
|
- 1
|
32
30
|
- 4
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
version: "0"
|
@@ -56,26 +53,11 @@ dependencies:
|
|
56
53
|
requirements:
|
57
54
|
- - ">="
|
58
55
|
- !ruby/object:Gem::Version
|
59
|
-
hash: 3
|
60
56
|
segments:
|
61
57
|
- 0
|
62
58
|
version: "0"
|
63
59
|
type: :runtime
|
64
60
|
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: cdb-full
|
67
|
-
prerelease: false
|
68
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
|
-
requirements:
|
71
|
-
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
hash: 3
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
version: "0"
|
77
|
-
type: :runtime
|
78
|
-
version_requirements: *id004
|
79
61
|
description:
|
80
62
|
email: rlane@vmware.com
|
81
63
|
executables:
|
@@ -133,7 +115,7 @@ files:
|
|
133
115
|
- test/test_misc.rb
|
134
116
|
- test/test_parse_response.rb
|
135
117
|
- test/test_serialization.rb
|
136
|
-
- vmodl.
|
118
|
+
- vmodl.db
|
137
119
|
- README.html
|
138
120
|
has_rdoc: true
|
139
121
|
homepage: https://github.com/rlane/rbvmomi
|
@@ -149,7 +131,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
131
|
requirements:
|
150
132
|
- - ">="
|
151
133
|
- !ruby/object:Gem::Version
|
152
|
-
hash: 57
|
153
134
|
segments:
|
154
135
|
- 1
|
155
136
|
- 8
|
@@ -160,14 +141,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
141
|
requirements:
|
161
142
|
- - ">="
|
162
143
|
- !ruby/object:Gem::Version
|
163
|
-
hash: 3
|
164
144
|
segments:
|
165
145
|
- 0
|
166
146
|
version: "0"
|
167
147
|
requirements: []
|
168
148
|
|
169
149
|
rubyforge_project:
|
170
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 1.3.7
|
171
151
|
signing_key:
|
172
152
|
specification_version: 3
|
173
153
|
summary: Ruby interface to the VMware vSphere API
|