rbvmomi2 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbvmomi/version.rb +1 -1
- data/lib/tasks/vmodl_helper.rb +107 -35
- data/vmodl.db +0 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca23adf85e7f9aa7fc531ed9c16e45a07c4ed9aedc6725afed17b94aa978c45b
|
4
|
+
data.tar.gz: 3b2be36f622eb5ac2311315ce3a39e75245e91684fb22a3fb7574e58fc33375f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 429eb97268d0b4be01876bb6b19371726e7177589418fe7fcae34729b77fc333e19e0d897fbcb6fd3aa5d988b4ed9b36c396e2f2ffb990bd20921dd93052eb52
|
7
|
+
data.tar.gz: 037b902b0da661ddc142c2a5eb27df979ac9b91db18c778ec40f102bc094ef16fd9b0f575d290d15299dbe7361ec1cbadbc43f921795615b5acddcc29c20f3ae
|
data/lib/rbvmomi/version.rb
CHANGED
data/lib/tasks/vmodl_helper.rb
CHANGED
@@ -50,7 +50,7 @@ class VmodlHelper
|
|
50
50
|
def verify!
|
51
51
|
# Loop through the ComplexTypes in the WSDL and compare their types
|
52
52
|
# to the types which are defined in the vmodl.db
|
53
|
-
|
53
|
+
wsdl_classes_by_name.each_value do |type|
|
54
54
|
type_name = type.name.name
|
55
55
|
vmodl_data = @vmodl[type_name]
|
56
56
|
|
@@ -60,7 +60,7 @@ class VmodlHelper
|
|
60
60
|
#
|
61
61
|
# Print a warning that the type is missing and skip it.
|
62
62
|
if vmodl_data.nil?
|
63
|
-
puts " #{type_name} is missing"
|
63
|
+
puts " class #{type_name} is missing"
|
64
64
|
next
|
65
65
|
end
|
66
66
|
|
@@ -82,42 +82,49 @@ class VmodlHelper
|
|
82
82
|
puts "#{type_name}.#{vmodl_prop["name"]} #{wsdl_klass.wsdl_name} doesn't match #{vmodl_klass.wsdl_name}" unless vmodl_klass <= wsdl_klass
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
# Loop through the SimpleTypes (enums) in the WSDL
|
87
|
+
wsdl_enums_by_name.each_value do |enum|
|
88
|
+
enum_name = enum.name.name
|
89
|
+
vmodl_data = @vmodl[enum_name]
|
90
|
+
|
91
|
+
if vmodl_data.nil?
|
92
|
+
puts " enum #{enum_name} is missing"
|
93
|
+
next
|
94
|
+
end
|
95
|
+
end
|
85
96
|
end
|
86
97
|
|
87
98
|
def generate!
|
88
|
-
|
89
|
-
type_name
|
90
|
-
vmodl_data = @vmodl[type_name]
|
99
|
+
wsdl_classes_by_name.each_value do |type|
|
100
|
+
type_name = type.name.name
|
91
101
|
|
92
|
-
if
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
'is-array' => element.maxoccurs != 1,
|
104
|
-
'version-id-ref' => nil,
|
105
|
-
'wsdl_type' => wsdl_to_vmodl_type(element.type)
|
106
|
-
}
|
107
|
-
end,
|
108
|
-
'wsdl_base' => type.complexcontent.extension.base.name
|
109
|
-
}
|
110
|
-
|
111
|
-
@vmodl[type_name] = vmodl_data
|
112
|
-
@vmodl['_typenames']['_typenames'] << type_name
|
113
|
-
|
114
|
-
puts "Adding #{type_name} to vmodl"
|
115
|
-
|
116
|
-
wsdl_to_rbvmomi_namespace(type).loader.add_types type_name => vmodl_data
|
102
|
+
# Update the existing vmodl object if it exists otherwise instantiate a
|
103
|
+
# new one.
|
104
|
+
vmodl_data = @vmodl[type_name] || build_wsdl_class!(type)
|
105
|
+
props_by_name = vmodl_data['props'].index_by { |prop| prop['name'] }
|
106
|
+
|
107
|
+
vmodl_data['props'] = wsdl_properties(type).map do |element|
|
108
|
+
# NOTE we should prioritize the existing property hash over building a
|
109
|
+
# new one because the generic ManagedObjectReferences are manually
|
110
|
+
# replaced with their specific counterparts (e.g. Datastore) which
|
111
|
+
# cannot be computed programmatically.
|
112
|
+
props_by_name[element.name.name] || build_vmodl_property(element)
|
117
113
|
end
|
114
|
+
|
115
|
+
# Some types (e.g. ManagedObjectReference) have extra properties which are
|
116
|
+
# not present in the WSDL but are required for proper function of RbVmomi.
|
117
|
+
vmodl_data['props'] += extra_props_for_type(type_name)
|
118
118
|
end
|
119
119
|
|
120
|
-
|
120
|
+
wsdl_enums_by_name.each_value do |enum|
|
121
|
+
enum_name = enum.name.name
|
122
|
+
|
123
|
+
vmodl_data = @vmodl[enum_name] || build_wsdl_enum(enum)
|
124
|
+
vmodl_data['values'] = enum.restriction.enumeration
|
125
|
+
end
|
126
|
+
|
127
|
+
wsdl_classes_by_name.each_value do |type|
|
121
128
|
type_name = type.name.name
|
122
129
|
vmodl_data = @vmodl[type_name]
|
123
130
|
|
@@ -159,12 +166,77 @@ class VmodlHelper
|
|
159
166
|
|
160
167
|
private
|
161
168
|
|
162
|
-
def
|
163
|
-
|
169
|
+
def build_wsdl_class!(type)
|
170
|
+
type_name = type.name.name
|
171
|
+
|
172
|
+
puts "Adding class #{type_name} to vmodl"
|
173
|
+
|
174
|
+
vmodl_obj = {'kind' => 'data', 'props' => [], 'wsdl_base' => type.complexcontent.extension.base.name}
|
175
|
+
|
176
|
+
@vmodl[type_name] = vmodl_obj
|
177
|
+
@vmodl['_typenames']['_typenames'] << type_name
|
178
|
+
|
179
|
+
wsdl_to_rbvmomi_namespace(type).loader.add_types(type_name => vmodl_obj)
|
180
|
+
|
181
|
+
vmodl_obj
|
182
|
+
end
|
183
|
+
|
184
|
+
def build_wsdl_enum(enum)
|
185
|
+
enum_name = enum.name.name
|
186
|
+
|
187
|
+
puts "Adding enum #{enum_name} to vmodl"
|
188
|
+
|
189
|
+
vmodl_obj = {'kind' => 'enum', 'values' => []}
|
190
|
+
|
191
|
+
@vmodl[enum_name] = vmodl_obj
|
192
|
+
@vmodl['_typenames']['_typenames'] << enum_name
|
193
|
+
|
194
|
+
wsdl_to_rbvmomi_namespace(enum).loader.add_types(enum_name => vmodl_obj)
|
195
|
+
|
196
|
+
vmodl_obj
|
197
|
+
end
|
198
|
+
|
199
|
+
def build_vmodl_property(element)
|
200
|
+
{
|
201
|
+
'name' => element.name.name,
|
202
|
+
'is-optional' => element.minoccurs == 0,
|
203
|
+
'is-array' => element.maxoccurs != 1,
|
204
|
+
'version-id-ref' => nil,
|
205
|
+
'wsdl_type' => wsdl_to_vmodl_type(element.type)
|
206
|
+
}
|
207
|
+
end
|
208
|
+
|
209
|
+
def wsdl_properties(type)
|
210
|
+
base_class = wsdl_classes_by_name[type.complexcontent&.extension&.base&.name]
|
211
|
+
if base_class
|
212
|
+
inherited_properties = base_class.elements.map { |element| element.name.name }
|
213
|
+
type.elements.reject { |e| inherited_properties.include?(e.name.name) }
|
214
|
+
else
|
215
|
+
type.elements
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def extra_props_for_type(type)
|
220
|
+
@extra_props_for_type ||= {
|
221
|
+
'ManagedObjectReference' => [
|
222
|
+
{'name' => 'type', 'is-optional' => false, 'is-array' => false, 'version-id-ref' => nil, 'wsdl_type' => 'xsd:string'},
|
223
|
+
{'name' => 'value', 'is-optional' => false, 'is-array' => false, 'version-id-ref' => nil, 'wsdl_type' => 'xsd:string'}
|
224
|
+
]
|
225
|
+
}
|
226
|
+
|
227
|
+
@extra_props_for_type[type] || []
|
228
|
+
end
|
229
|
+
|
230
|
+
def wsdl_classes_by_name
|
231
|
+
@wsdl_classes_by_name ||= @wsdl.collect_complextypes
|
164
232
|
.reject { |type| type.name.name.match?(/^ArrayOf|RequestType$/) }
|
165
233
|
.index_by { |type| type.name.name }
|
166
234
|
end
|
167
235
|
|
236
|
+
def wsdl_enums_by_name
|
237
|
+
@wsdl_enums_by_name ||= @wsdl.collect_simpletypes.index_by { |type| type.name.name }
|
238
|
+
end
|
239
|
+
|
168
240
|
def wsdl_to_vmodl_type(type)
|
169
241
|
case type.source
|
170
242
|
when /vim25:/, /pbm:/, /sms:/
|
@@ -180,7 +252,7 @@ class VmodlHelper
|
|
180
252
|
|
181
253
|
def wsdl_to_rbvmomi_namespace(type)
|
182
254
|
case type.targetnamespace
|
183
|
-
when '
|
255
|
+
when 'urn:vim25'
|
184
256
|
RbVmomi::VIM
|
185
257
|
when 'urn:pbm'
|
186
258
|
RbVmomi::PBM
|
@@ -201,6 +273,6 @@ class VmodlHelper
|
|
201
273
|
type = 'ManagedObject' if type == 'ManagedObjectReference'
|
202
274
|
|
203
275
|
type = type.camelcase
|
204
|
-
type.safe_constantize || "RbVmomi::BasicTypes::#{type}".safe_constantize || "
|
276
|
+
type.safe_constantize || "RbVmomi::BasicTypes::#{type}".safe_constantize || "#{wsdl_to_rbvmomi_namespace(@wsdl)}::#{type}".safe_constantize
|
205
277
|
end
|
206
278
|
end
|
data/vmodl.db
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbvmomi2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Grare
|
8
8
|
- Jason Frey
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -93,14 +93,14 @@ dependencies:
|
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.14.1
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.14.1
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
105
|
name: rake
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,7 +185,7 @@ dependencies:
|
|
185
185
|
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: 0.9.25
|
188
|
-
description:
|
188
|
+
description:
|
189
189
|
email:
|
190
190
|
- adam@grare.com
|
191
191
|
- fryguy9@gmail.com
|
@@ -245,7 +245,7 @@ homepage: https://github.com/ManageIQ/rbvmomi2
|
|
245
245
|
licenses:
|
246
246
|
- MIT
|
247
247
|
metadata: {}
|
248
|
-
post_install_message:
|
248
|
+
post_install_message:
|
249
249
|
rdoc_options: []
|
250
250
|
require_paths:
|
251
251
|
- lib
|
@@ -260,8 +260,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
260
260
|
- !ruby/object:Gem::Version
|
261
261
|
version: '0'
|
262
262
|
requirements: []
|
263
|
-
rubygems_version: 3.3.
|
264
|
-
signing_key:
|
263
|
+
rubygems_version: 3.3.15
|
264
|
+
signing_key:
|
265
265
|
specification_version: 4
|
266
266
|
summary: Ruby interface to the VMware vSphere API
|
267
267
|
test_files: []
|