rbvmomi 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rbvmomi/connection.rb +4 -3
- data/test/test_emit_request.rb +17 -0
- metadata +3 -23
- data/README.html +0 -76
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
data/lib/rbvmomi/connection.rb
CHANGED
@@ -26,9 +26,10 @@ class Connection < TrivialSoap
|
|
26
26
|
xml.tag! method, :xmlns => @ns do
|
27
27
|
obj2xml xml, '_this', 'ManagedObject', false, this
|
28
28
|
descs.each do |d|
|
29
|
-
k = d['name']
|
30
|
-
if params.member?
|
31
|
-
|
29
|
+
k = d['name']
|
30
|
+
k = k.to_sym if !params.member?(k) && params.member?(k.to_sym)
|
31
|
+
v = params[k]
|
32
|
+
if not v == nil
|
32
33
|
obj2xml xml, d['name'], d['wsdl_type'], d['is-array'], v
|
33
34
|
else
|
34
35
|
fail "missing required parameter #{d['name']}" unless d['is-optional']
|
data/test/test_emit_request.rb
CHANGED
@@ -86,6 +86,23 @@ class EmitRequestTest < Test::Unit::TestCase
|
|
86
86
|
EOS
|
87
87
|
end
|
88
88
|
|
89
|
+
def test_nil_optional_param
|
90
|
+
desc = [
|
91
|
+
{
|
92
|
+
'name' => 'blah',
|
93
|
+
'is-array' => false,
|
94
|
+
'is-optional' => true,
|
95
|
+
'wsdl_type' => 'xsd:string',
|
96
|
+
}
|
97
|
+
]
|
98
|
+
|
99
|
+
check desc, <<-EOS, MO, :blah => nil
|
100
|
+
<root xmlns="urn:vim25">
|
101
|
+
<_this type="VirtualMachine">foo</_this>
|
102
|
+
</root>
|
103
|
+
EOS
|
104
|
+
end
|
105
|
+
|
89
106
|
def test_string_key
|
90
107
|
desc = [
|
91
108
|
{
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbvmomi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 2
|
8
|
-
- 0
|
9
|
-
version: 1.2.0
|
4
|
+
prerelease:
|
5
|
+
version: 1.2.1
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Rich Lane
|
@@ -25,10 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 4
|
31
|
-
- 1
|
32
24
|
version: 1.4.1
|
33
25
|
type: :runtime
|
34
26
|
version_requirements: *id001
|
@@ -40,8 +32,6 @@ dependencies:
|
|
40
32
|
requirements:
|
41
33
|
- - ">="
|
42
34
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
35
|
version: "0"
|
46
36
|
type: :runtime
|
47
37
|
version_requirements: *id002
|
@@ -53,8 +43,6 @@ dependencies:
|
|
53
43
|
requirements:
|
54
44
|
- - ">="
|
55
45
|
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 0
|
58
46
|
version: "0"
|
59
47
|
type: :runtime
|
60
48
|
version_requirements: *id003
|
@@ -66,7 +54,6 @@ extensions: []
|
|
66
54
|
|
67
55
|
extra_rdoc_files:
|
68
56
|
- LICENSE
|
69
|
-
- README.html
|
70
57
|
- README.rdoc
|
71
58
|
files:
|
72
59
|
- .yardopts
|
@@ -116,7 +103,6 @@ files:
|
|
116
103
|
- test/test_parse_response.rb
|
117
104
|
- test/test_serialization.rb
|
118
105
|
- vmodl.db
|
119
|
-
- README.html
|
120
106
|
has_rdoc: true
|
121
107
|
homepage: https://github.com/rlane/rbvmomi
|
122
108
|
licenses: []
|
@@ -131,23 +117,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
117
|
requirements:
|
132
118
|
- - ">="
|
133
119
|
- !ruby/object:Gem::Version
|
134
|
-
segments:
|
135
|
-
- 1
|
136
|
-
- 8
|
137
|
-
- 7
|
138
120
|
version: 1.8.7
|
139
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
122
|
none: false
|
141
123
|
requirements:
|
142
124
|
- - ">="
|
143
125
|
- !ruby/object:Gem::Version
|
144
|
-
segments:
|
145
|
-
- 0
|
146
126
|
version: "0"
|
147
127
|
requirements: []
|
148
128
|
|
149
129
|
rubyforge_project:
|
150
|
-
rubygems_version: 1.3
|
130
|
+
rubygems_version: 1.5.3
|
151
131
|
signing_key:
|
152
132
|
specification_version: 3
|
153
133
|
summary: Ruby interface to the VMware vSphere API
|
data/README.html
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
<h1>RbVmomi</h1>
|
2
|
-
|
3
|
-
<h2>Introduction</h2>
|
4
|
-
|
5
|
-
<p>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 4.1 API.</p>
|
8
|
-
|
9
|
-
<h2>Usage</h2>
|
10
|
-
|
11
|
-
<p>A simple example of turning on a VM:</p>
|
12
|
-
|
13
|
-
<pre><code>require 'rbvmomi'
|
14
|
-
conn = RbVmomi.connect host: 'foo', user: 'bar', password: 'baz'
|
15
|
-
dc = conn.serviceInstance.find_datacenter("mydatacenter") or fail "datacenter not found"
|
16
|
-
vm = dc.find_vm("myvm") or fail "VM not found"
|
17
|
-
vm.PowerOn_Task.wait_for_completion
|
18
|
-
</code></pre>
|
19
|
-
|
20
|
-
<p>This code uses several RbVmomi extensions to the VI API for concision. The
|
21
|
-
expanded snippet below uses only standard API calls and should be familiar to
|
22
|
-
users of the Java SDK:</p>
|
23
|
-
|
24
|
-
<pre><code>require 'rbvmomi'
|
25
|
-
conn = RbVmomi.connect host: 'foo', user: 'bar', password: 'baz'
|
26
|
-
rootFolder = conn.serviceInstance.content.rootFolder
|
27
|
-
dc = rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).find { |x| x.name == "mydatacenter" } or fail "datacenter not found"
|
28
|
-
vm = dc.vmFolder.childEntity.grep(RbVmomi::VIM::VirtualMachine).find { |x| x.name == "myvm" } or fail "VM not found"
|
29
|
-
task = vm.PowerOn_Task
|
30
|
-
filter = conn.propertyCollector.CreateFilter(
|
31
|
-
spec: {
|
32
|
-
propSet: [{ type => 'Task', all: false, pathSet: ['info.state']}],
|
33
|
-
objectSet: [{ obj: task }]
|
34
|
-
},
|
35
|
-
partialUpdates: false
|
36
|
-
)
|
37
|
-
ver = ''
|
38
|
-
while true
|
39
|
-
result = conn.propertyCollector.WaitForUpdates(version: ver)
|
40
|
-
ver = result.version
|
41
|
-
break if ['success', ['error'].member? task.info.state
|
42
|
-
end
|
43
|
-
filter.DestroyPropertyFilter
|
44
|
-
raise task.info.error if task.info.state == 'error'
|
45
|
-
</code></pre>
|
46
|
-
|
47
|
-
<p>As you can see, the extensions RbVmomi adds can dramatically decrease the code
|
48
|
-
needed to perform simple tasks while still letting you use the full power of
|
49
|
-
the API when necessary. RbVmomi extensions are often more efficient than a
|
50
|
-
naive implementation; for example, the find_vm method on VIM::Datacenter used
|
51
|
-
in the first example uses the SearchIndex for fast lookups.</p>
|
52
|
-
|
53
|
-
<p>A few important points:</p>
|
54
|
-
|
55
|
-
<ul>
|
56
|
-
<li>Ruby 1.9 is required.</li>
|
57
|
-
<li>Properties are exposed as methods: vm.summary</li>
|
58
|
-
<li>All class, method, parameter, and property names match the <a href="http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/index.html">official documentation</a>.</li>
|
59
|
-
<li>Data object types can usually be inferred from context, so you may simply use a hash instead.</li>
|
60
|
-
<li>Enumeration values are simply strings.</li>
|
61
|
-
<li>Example code is included in the examples/ directory.</li>
|
62
|
-
<li>A set of helper methods for Trollop is included to speed up development of
|
63
|
-
command line apps. See the included examples for usage.</li>
|
64
|
-
<li>This is a side project of a VMware developer and is entirely unsupported by VMware.</li>
|
65
|
-
</ul>
|
66
|
-
|
67
|
-
<p>Built-in extensions are in lib/rbvmomi/extensions.rb. You are encouraged to
|
68
|
-
reopen VIM classes in your applications and add extensions of your own. If you
|
69
|
-
write something generally useful please send it to me and I'll add it in. One
|
70
|
-
important point about extensions is that since VIM classes are lazily loaded,
|
71
|
-
you need to trigger this loading before you can reopen the class. Putting the
|
72
|
-
class name on a line by itself before reopening is enough.</p>
|
73
|
-
|
74
|
-
<h2>Development</h2>
|
75
|
-
|
76
|
-
<p>Send patches to rlane@vmware.com.</p>
|