mkuzmin-rbvmomi 1.8.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +6 -0
  3. data/LICENSE +19 -0
  4. data/README.rdoc +78 -0
  5. data/Rakefile +45 -0
  6. data/VERSION +1 -0
  7. data/bin/rbvmomish +138 -0
  8. data/devel/analyze-vim-declarations.rb +213 -0
  9. data/devel/analyze-xml.rb +46 -0
  10. data/devel/benchmark.rb +117 -0
  11. data/devel/collisions.rb +18 -0
  12. data/devel/merge-internal-vmodl.rb +59 -0
  13. data/devel/merge-manual-vmodl.rb +32 -0
  14. data/examples/annotate.rb +54 -0
  15. data/examples/cached_ovf_deploy.rb +120 -0
  16. data/examples/clone_vm.rb +84 -0
  17. data/examples/create_vm-1.9.rb +93 -0
  18. data/examples/create_vm.rb +93 -0
  19. data/examples/extraConfig.rb +54 -0
  20. data/examples/lease_tool.rb +102 -0
  21. data/examples/logbundle.rb +63 -0
  22. data/examples/logtail.rb +60 -0
  23. data/examples/nfs_datastore.rb +95 -0
  24. data/examples/power.rb +59 -0
  25. data/examples/readme-1.rb +35 -0
  26. data/examples/readme-2.rb +51 -0
  27. data/examples/run.sh +41 -0
  28. data/examples/screenshot.rb +48 -0
  29. data/examples/vdf.rb +81 -0
  30. data/examples/vm_drs_behavior.rb +76 -0
  31. data/lib/rbvmomi.rb +12 -0
  32. data/lib/rbvmomi/basic_types.rb +375 -0
  33. data/lib/rbvmomi/connection.rb +270 -0
  34. data/lib/rbvmomi/deserialization.rb +248 -0
  35. data/lib/rbvmomi/fault.rb +17 -0
  36. data/lib/rbvmomi/pbm.rb +66 -0
  37. data/lib/rbvmomi/sms.rb +61 -0
  38. data/lib/rbvmomi/sms/SmsStorageManager.rb +7 -0
  39. data/lib/rbvmomi/trivial_soap.rb +114 -0
  40. data/lib/rbvmomi/trollop.rb +70 -0
  41. data/lib/rbvmomi/type_loader.rb +136 -0
  42. data/lib/rbvmomi/utils/admission_control.rb +398 -0
  43. data/lib/rbvmomi/utils/deploy.rb +314 -0
  44. data/lib/rbvmomi/utils/leases.rb +142 -0
  45. data/lib/rbvmomi/utils/perfdump.rb +628 -0
  46. data/lib/rbvmomi/vim.rb +128 -0
  47. data/lib/rbvmomi/vim/ComputeResource.rb +51 -0
  48. data/lib/rbvmomi/vim/Datacenter.rb +17 -0
  49. data/lib/rbvmomi/vim/Datastore.rb +68 -0
  50. data/lib/rbvmomi/vim/DynamicTypeMgrAllTypeInfo.rb +75 -0
  51. data/lib/rbvmomi/vim/DynamicTypeMgrDataTypeInfo.rb +20 -0
  52. data/lib/rbvmomi/vim/DynamicTypeMgrManagedTypeInfo.rb +46 -0
  53. data/lib/rbvmomi/vim/Folder.rb +207 -0
  54. data/lib/rbvmomi/vim/HostSystem.rb +174 -0
  55. data/lib/rbvmomi/vim/ManagedEntity.rb +57 -0
  56. data/lib/rbvmomi/vim/ManagedObject.rb +60 -0
  57. data/lib/rbvmomi/vim/ObjectContent.rb +23 -0
  58. data/lib/rbvmomi/vim/ObjectUpdate.rb +23 -0
  59. data/lib/rbvmomi/vim/OvfManager.rb +200 -0
  60. data/lib/rbvmomi/vim/PerfCounterInfo.rb +26 -0
  61. data/lib/rbvmomi/vim/PerformanceManager.rb +110 -0
  62. data/lib/rbvmomi/vim/PropertyCollector.rb +25 -0
  63. data/lib/rbvmomi/vim/ReflectManagedMethodExecuter.rb +30 -0
  64. data/lib/rbvmomi/vim/ResourcePool.rb +55 -0
  65. data/lib/rbvmomi/vim/ServiceInstance.rb +55 -0
  66. data/lib/rbvmomi/vim/Task.rb +65 -0
  67. data/lib/rbvmomi/vim/VirtualMachine.rb +74 -0
  68. data/test/test_deserialization.rb +383 -0
  69. data/test/test_emit_request.rb +128 -0
  70. data/test/test_exceptions.rb +14 -0
  71. data/test/test_helper.rb +14 -0
  72. data/test/test_misc.rb +24 -0
  73. data/test/test_parse_response.rb +69 -0
  74. data/test/test_serialization.rb +311 -0
  75. data/vmodl.db +0 -0
  76. metadata +163 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cbe53d8d48667507d93ddd16bb4a0a9bac091fa2
4
+ data.tar.gz: 83ed4bcbc3165548ecc23358ff86b5f467ffd51c
5
+ SHA512:
6
+ metadata.gz: c7b944f9b3a7a25326888ad9a8e47130eb40953616986f5b0537d3328f3e23d45cb38a742342e987ba2d71a0a060cd5ceb65fe80dd659aeb871562b1b376b3c0
7
+ data.tar.gz: a09f02f93a3cf32d8e0197a1165918e45920c01312362a4984d22e7f64e9ae9c2634b20ea1290dbf32d9d0171090f664820b157f0bc5516a853e5ba3be114926
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --title "RbVmomi - a Ruby interface to the vSphere API"
2
+ --no-private
3
+ --readme README.rdoc
4
+ lib/rbvmomi/vim.rb
5
+ lib/rbvmomi/vim/*.rb
6
+ lib/rbvmomi/trollop.rb
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010 VMware, Inc. All Rights Reserved.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,78 @@
1
+ = RbVmomi
2
+
3
+ == Introduction
4
+
5
+ RbVmomi is a Ruby interface to the vSphere API. Like the Perl and Java SDKs,
6
+ you can use it to manage ESX and VirtualCenter servers. The current release
7
+ supports the vSphere 5.0 API. RbVmomi specific documentation is
8
+ online[http://rdoc.info/github/rlane/rbvmomi/master/frames] and is meant to
9
+ be used alongside the official documentation[http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/index.html].
10
+
11
+ == Installation
12
+
13
+ gem install rbvmomi
14
+
15
+ == Usage
16
+
17
+ A simple example of turning on a VM:
18
+
19
+ require 'rbvmomi'
20
+ vim = RbVmomi::VIM.connect host: 'foo', user: 'bar', password: 'baz'
21
+ dc = vim.serviceInstance.find_datacenter("mydatacenter") or fail "datacenter not found"
22
+ vm = dc.find_vm("myvm") or fail "VM not found"
23
+ vm.PowerOnVM_Task.wait_for_completion
24
+
25
+ This code uses several RbVmomi extensions to the vSphere API for concision. The
26
+ expanded snippet below uses only standard API calls and should be familiar to
27
+ users of the Java SDK:
28
+
29
+ require 'rbvmomi'
30
+ vim = RbVmomi::VIM.connect host: 'foo', user: 'bar', password: 'baz'
31
+ rootFolder = vim.serviceInstance.content.rootFolder
32
+ dc = rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).find { |x| x.name == "mydatacenter" } or fail "datacenter not found"
33
+ vm = dc.vmFolder.childEntity.grep(RbVmomi::VIM::VirtualMachine).find { |x| x.name == "myvm" } or fail "VM not found"
34
+ task = vm.PowerOnVM_Task
35
+ filter = vim.propertyCollector.CreateFilter(
36
+ spec: {
37
+ propSet: [{ type: 'Task', all: false, pathSet: ['info.state']}],
38
+ objectSet: [{ obj: task }]
39
+ },
40
+ partialUpdates: false
41
+ )
42
+ ver = ''
43
+ while true
44
+ result = vim.propertyCollector.WaitForUpdates(version: ver)
45
+ ver = result.version
46
+ break if ['success', 'error'].member? task.info.state
47
+ end
48
+ filter.DestroyPropertyFilter
49
+ raise task.info.error if task.info.state == 'error'
50
+
51
+ As you can see, the extensions RbVmomi adds can dramatically decrease the code
52
+ needed to perform simple tasks while still letting you use the full power of
53
+ the API when necessary. RbVmomi extensions are often more efficient than a
54
+ naive implementation; for example, the find_vm method on VIM::Datacenter used
55
+ in the first example uses the SearchIndex for fast lookups.
56
+
57
+ A few important points:
58
+
59
+ * All class, method, parameter, and property names match the official documentation[http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/index.html].
60
+ * Properties are exposed as accessor methods.
61
+ * Data object types can usually be inferred from context, so you may use a hash instead.
62
+ * Enumeration values are simply strings.
63
+ * Example code is included in the examples/ directory.
64
+ * A set of helper methods for Trollop is included to speed up development of
65
+ command line apps. See the included examples for usage.
66
+ * If you don't have trusted SSL certificates installed on the host you're
67
+ connecting to, you'll get an +OpenSSL::SSL::SSLError+ "certificate verify failed".
68
+ You can work around this by using the +:insecure+ option to +RbVmomi::VIM.connect+.
69
+ * This is a side project of a VMware employee and is entirely unsupported by VMware.
70
+
71
+ Built-in extensions are under +lib/rbvmomi/vim/+. You are encouraged to
72
+ reopen VIM classes in your applications and add extensions of your own. If you
73
+ write something generally useful please send it to me and I'll add it in.
74
+
75
+ == Development
76
+
77
+ Fork the project on Github and send me a merge request, or send a patch to
78
+ rlane@vmware.com. RbVmomi developers hang out in #rbvmomi on Freenode.
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ require 'rake/testtask'
2
+ require 'rdoc/task'
3
+ require 'yard'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "mkuzmin-rbvmomi"
9
+ gem.summary = "Ruby interface to the VMware vSphere API"
10
+ #gem.description = ""
11
+ gem.email = "mkuzmin@gmail.com"
12
+ gem.homepage = "https://github.com/mkuzmin/rbvmomi"
13
+ gem.authors = ["Rich Lane", "Christian Dickmann"]
14
+ gem.add_dependency 'nokogiri', '>= 1.4.1'
15
+ gem.add_dependency 'builder'
16
+ gem.add_dependency 'trollop'
17
+ gem.required_ruby_version = '>= 1.8.7'
18
+ gem.files.include 'vmodl.db'
19
+ gem.files.include '.yardopts'
20
+ end
21
+ rescue LoadError
22
+ puts "Jeweler not available. Install it with: gem install jeweler"
23
+ end
24
+
25
+ Rake::TestTask.new do |t|
26
+ t.libs << "test"
27
+ t.test_files = FileList['test/test_*.rb']
28
+ t.verbose = true
29
+ end
30
+
31
+ YARD::Rake::YardocTask.new
32
+
33
+ begin
34
+ require 'rcov/rcovtask'
35
+ desc 'Measures test coverage using rcov'
36
+ Rcov::RcovTask.new do |rcov|
37
+ rcov.pattern = 'test/test_*.rb'
38
+ rcov.output_dir = 'coverage'
39
+ rcov.verbose = true
40
+ rcov.libs << "test"
41
+ rcov.rcov_opts << '--exclude "gems/*"'
42
+ end
43
+ rescue LoadError
44
+ puts "Rcov not available. Install it with: gem install rcov"
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.8.2.1
data/bin/rbvmomish ADDED
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env ruby
2
+ # TODO keepalive
3
+ # TODO rc file
4
+ # TODO proxy support?
5
+ require 'trollop'
6
+ require 'readline'
7
+ require 'rbvmomi'
8
+ require 'rbvmomi/trollop'
9
+
10
+ VIM = RbVmomi::VIM
11
+
12
+ opts = Trollop.options do
13
+ banner <<-EOS
14
+ vSphere API console.
15
+
16
+ Usage:
17
+ rbvmomish [options]
18
+
19
+ Predefined methods:
20
+ conn: Returns the VIM connection
21
+ si: Returns the ServiceInstance
22
+ help: Displays this text.
23
+
24
+ Special syntax:
25
+ Adding a '#' suffix to an expression displays information about the type of the
26
+ result, including its properties and methods, instead of the value.
27
+
28
+ VIM connection options:
29
+ EOS
30
+
31
+ rbvmomi_connection_opts
32
+
33
+ text <<-EOS
34
+
35
+ Other options:
36
+ EOS
37
+
38
+ $trollop = self
39
+ end
40
+
41
+ begin
42
+ $vim = VIM.connect opts
43
+ rescue Errno::EHOSTUNREACH
44
+ abort $!.message
45
+ end
46
+
47
+ typenames = VIM.loader.typenames
48
+ Readline.completion_append_character = " "
49
+ Readline.completion_proc = lambda do |word|
50
+ return unless word
51
+ prefix_regex = /^#{Regexp.escape(word)}/
52
+ candidates = typenames.sort
53
+ candidates.find_all { |e| e.match(prefix_regex) }
54
+ end
55
+
56
+ history_fn = "#{ENV['HOME']}/.rbvmomish-history"
57
+ IO.foreach(history_fn) { |l| Readline::HISTORY << l.chomp } rescue nil
58
+ history = File.open(history_fn, 'a')
59
+
60
+ def type name
61
+ klass = VIM.type(name) rescue err("invalid type #{name.inspect}")
62
+ q = lambda { |x| x =~ /^xsd:/ ? $' : x }
63
+ if klass < VIM::DataObject
64
+ puts "Data Object #{klass}"
65
+ klass.full_props_desc.each do |desc|
66
+ puts " #{desc['name']}: #{q[desc['wsdl_type']]}#{desc['is-array'] ? '[]' : ''}"
67
+ end
68
+ elsif klass < VIM::ManagedObject
69
+ puts "Managed Object #{klass}"
70
+ puts
71
+ puts "Properties:"
72
+ klass.full_props_desc.each do |desc|
73
+ puts " #{desc['name']}: #{q[desc['wsdl_type']]}#{desc['is-array'] ? '[]' : ''}"
74
+ end
75
+ puts
76
+ puts "Methods:"
77
+ klass.full_methods_desc.sort_by(&:first).each do |name,desc|
78
+ params = desc['params']
79
+ puts " #{name}(#{params.map { |x| "#{x['name']} : #{q[x['wsdl_type'] || 'void']}#{x['is-array'] ? '[]' : ''}" } * ', '}) : #{q[desc['result']['wsdl_type'] || 'void']}"
80
+ end
81
+ else
82
+ err("cannot introspect type #{klass}")
83
+ end
84
+ nil
85
+ end
86
+
87
+ class UserError < RuntimeError; end
88
+ def err msg
89
+ raise UserError.new(msg)
90
+ end
91
+
92
+ def cookie str
93
+ $vim.cookie = str
94
+ end
95
+
96
+ def conn
97
+ $vim
98
+ end
99
+
100
+ def si
101
+ $vim.serviceInstance
102
+ end
103
+
104
+ def help
105
+ $trollop.educate
106
+ :no_result
107
+ end
108
+
109
+ $binding = $vim.instance_eval { binding }
110
+
111
+ loop do
112
+ begin
113
+ input = Readline.readline("#{opts[:host]}> ", false) or break
114
+ input = input.strip
115
+ next if input.empty?
116
+
117
+ (history.puts input; Readline::HISTORY << input) unless input == Readline::HISTORY.to_a[-1]
118
+
119
+ result = eval(input, $binding)
120
+ if input =~ /\#$/
121
+ type result.class.wsdl_name
122
+ else
123
+ pp result unless result == :no_result
124
+ end
125
+ rescue SystemExit, IOError
126
+ raise
127
+ rescue RuntimeError, RbVmomi::Fault
128
+ puts "#{$!.class}: #{$!.message}"
129
+ puts $!.backtrace * "\n"
130
+ rescue UserError
131
+ puts $!.message
132
+ rescue Interrupt
133
+ puts
134
+ rescue Exception
135
+ puts "#{$!.class}: #{$!.message}"
136
+ puts $!.backtrace * "\n"
137
+ end
138
+ end
@@ -0,0 +1,213 @@
1
+ #!/usr/bin/env ruby
2
+ require 'nokogiri'
3
+ require 'pp'
4
+ # :usage => analyze-vim-declarations.rb vim-declarations.xml foo-declarations.xml vmodl.db
5
+
6
+ XML_FNS = ARGV[0...-1]
7
+ abort "must specify path to vim-declarations.xml" if XML_FNS.empty?
8
+ OUT_FN = ARGV[-1] or abort "must specify path to output database"
9
+
10
+ XML_FNS.each do |x|
11
+ abort "XML file #{x} does not exist" unless File.exists? x
12
+ end
13
+
14
+ TYPES = {}
15
+ VERSIONS = []
16
+
17
+ ID2NAME = Hash.new { |h,k| fail "unknown type-id #{k.inspect}" }
18
+
19
+ ID2NAME.merge!({
20
+ 'java.lang.String' => 'xsd:string',
21
+ 'BOOLEAN' => 'xsd:boolean',
22
+ 'BYTE' => 'xsd:byte',
23
+ 'SHORT' => 'xsd:short',
24
+ 'INT' => 'xsd:int',
25
+ 'LONG' => 'xsd:long',
26
+ 'FLOAT' => 'xsd:float',
27
+ 'DOUBLE' => 'xsd:double',
28
+ 'vmodl.DateTime' => 'xsd:dateTime',
29
+ 'vmodl.Binary' => 'xsd:base64Binary',
30
+ 'vmodl.Any' => 'xsd:anyType',
31
+ 'vmodl.URI' => 'xsd:anyURI',
32
+ 'void' => nil,
33
+ })
34
+
35
+ %w(DataObject ManagedObject MethodFault MethodName
36
+ PropertyPath RuntimeFault TypeName).each do |x|
37
+ ID2NAME['vmodl.' + x] = x
38
+ end
39
+
40
+ def handle_data_object node
41
+ if TYPES[node['name']]
42
+ puts "Type #{node['name']} already exists"
43
+ return
44
+ end
45
+
46
+ ID2NAME[node['type-id']] = node['name']
47
+ TYPES[node['name']] = {
48
+ 'kind' => 'data',
49
+ 'base-type-id' => node['base-type-id'],
50
+ 'props' => node.children.select { |x| x.name == 'property' }.map do |property|
51
+ {
52
+ 'name' => property['name'],
53
+ 'type-id-ref' => property['type-id-ref'],
54
+ 'is-optional' => property['is-optional'] ? true : false,
55
+ 'is-array' => property['is-array'] ? true : false,
56
+ 'version-id-ref' => property['version-id-ref'],
57
+ }
58
+ end
59
+ }
60
+ end
61
+
62
+ def handle_managed_object node
63
+ if TYPES[node['name']]
64
+ puts "Type #{node['name']} already exists"
65
+ return
66
+ end
67
+ ID2NAME[node['type-id']] = node['name']
68
+ TYPES[node['name']] = {
69
+ 'kind' => 'managed',
70
+ 'base-type-id' => node['base-type-id'],
71
+ 'props' => node.children.select { |x| x.name == 'property' }.map do |property|
72
+ {
73
+ 'name' => property['name'],
74
+ 'type-id-ref' => property['type-id-ref'],
75
+ 'is-optional' => property['is-optional'] ? true : false,
76
+ 'is-array' => property['is-array'] ? true : false,
77
+ 'version-id-ref' => property['version-id-ref'],
78
+ }
79
+ end,
80
+ 'methods' => Hash[
81
+ node.children.select { |x| x.name == 'method' }.map do |method|
82
+ [method['is-task'] ? "#{method['name']}_Task" : method['name'],
83
+ {
84
+ 'params' => method.children.select { |x| x.name == 'parameter' }.map do |param|
85
+ {
86
+ 'name' => param['name'],
87
+ 'type-id-ref' => param['type-id-ref'],
88
+ 'is-array' => param['is-array'] ? true : false,
89
+ 'is-optional' => param['is-optional'] ? true : false,
90
+ 'version-id-ref' => param['version-id-ref'],
91
+ }
92
+ end,
93
+ 'result' => {
94
+ 'type-id-ref' => method['type-id-ref'],
95
+ 'is-array' => method['is-array'] ? true : false,
96
+ 'is-optional' => method['is-optional'] ? true : false,
97
+ 'is-task' => method['is-task'] ? true : false,
98
+ 'version-id-ref' => method['version-id-ref'],
99
+ }
100
+ }
101
+ ]
102
+ end
103
+ ]
104
+ }
105
+ end
106
+
107
+ def handle_enum node
108
+ if TYPES[node['name']]
109
+ puts "Type #{node['name']} already exists"
110
+ return
111
+ end
112
+
113
+ ID2NAME[node['type-id']] = node['name']
114
+ TYPES[node['name']] = {
115
+ 'kind' => 'enum',
116
+ 'values' => node.children.map { |child| child['name'] },
117
+ }
118
+ end
119
+
120
+ def handle_fault node
121
+ handle_data_object node
122
+ end
123
+
124
+ def handle_version x
125
+ attrs = %w(display-name name service-namespace type-id version-id vmodl-name)
126
+ h = Hash[attrs.map { |k| [k, x[k]] }]
127
+ h['compatible'] = x.children.select(&:element?).map { |y| y.text }
128
+ VERSIONS << h
129
+ end
130
+
131
+ XML_FNS.each do |fn|
132
+ puts "parsing #{fn} ..."
133
+ xml_str = File.read(fn)
134
+ xml_str = xml_str.gsub(/\<description-html\>(.*?)\<\/description-html\>/m, "")
135
+ xml = Nokogiri.parse(xml_str, nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS)
136
+ xml.root.at('enums').children.each { |x| handle_enum x }
137
+ xml.root.at('managed-objects').children.each { |x| handle_managed_object x }
138
+ xml.root.at('data-objects').children.each { |x| handle_data_object x }
139
+ xml.root.at('faults').children.each { |x| handle_fault x }
140
+ #xml.root.at('definitions').at('version-types').children.each { |x| handle_version x }
141
+ end
142
+
143
+ #pp ID2NAME
144
+
145
+ munge_fault = lambda { |x| true }
146
+
147
+ TYPES.each do |k,t|
148
+ case t['kind']
149
+ when 'data'
150
+ t['wsdl_base'] = t['base-type-id'] ? ID2NAME[t['base-type-id']] : 'DataObject'
151
+ t.delete 'base-type-id'
152
+ t['props'].each do |x|
153
+ x['wsdl_type'] = ID2NAME[x['type-id-ref']]
154
+ x.delete 'type-id-ref'
155
+ munge_fault[x]
156
+ end
157
+ when 'managed'
158
+ t['wsdl_base'] = t['base-type-id'] ? ID2NAME[t['base-type-id']] : 'ManagedObject'
159
+ t.delete 'base-type-id'
160
+ t['props'].each do |x|
161
+ x['wsdl_type'] = ID2NAME[x['type-id-ref']]
162
+ x.delete 'type-id-ref'
163
+ munge_fault[x]
164
+ end
165
+ t['methods'].each do |mName,x|
166
+ if y = x['result']
167
+ begin
168
+ y['wsdl_type'] = ID2NAME[y['type-id-ref']]
169
+ rescue Exception => ex
170
+ pp ex
171
+ end
172
+ y.delete 'type-id-ref'
173
+ munge_fault[y]
174
+ end
175
+ x['params'].each do |r|
176
+ begin
177
+ r['wsdl_type'] = ID2NAME[r['type-id-ref']]
178
+ rescue Exception => ex
179
+ pp ex
180
+ end
181
+ r.delete 'type-id-ref'
182
+ munge_fault[r]
183
+ end
184
+ end
185
+ when 'enum'
186
+ else fail
187
+ end
188
+ end
189
+
190
+ db = {}
191
+
192
+ TYPES.each do |k,t|
193
+ db[k] = t
194
+ end
195
+
196
+ db['_typenames'] = TYPES.keys
197
+ db['_versions'] = VERSIONS
198
+
199
+ File.open(OUT_FN, 'w') { |io| Marshal.dump db, io }
200
+
201
+ if filename = ENV['VERSION_GRAPH']
202
+ File.open(filename, 'w') do |io|
203
+ io.puts "digraph versions\n{"
204
+ VERSIONS.each do |h|
205
+ io.puts "\"#{h['vmodl-name']}\" [label=\"#{h['vmodl-name']} (#{h['version-id']})\"]"
206
+ h['compatible'].each do |x|
207
+ x =~ /^interface / or fail x
208
+ io.puts "\"#{h['vmodl-name']}\" -> \"#{$'}\""
209
+ end
210
+ end
211
+ io.puts "}\n"
212
+ end
213
+ end