rbvmomi 2.1.0 → 2.1.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.
- checksums.yaml +4 -4
- data/lib/rbvmomi/version.rb +1 -1
- data/lib/rbvmomi/vim.rb +2 -1
- metadata +3 -4
- data/lib/rbvmomi/#vim.rb# +0 -155
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 954401ddca3b6efabc4879ff009428998c3ea39b2ec270ec71e4182fa5d06590
|
4
|
+
data.tar.gz: f368fc8acffbeb51f140eabec67859b228c779704eb402e6d5891222eee792b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a98e486560b2b5f3559c5c8394325ed216b2b679b46f360f4e2bce6b4355293f8aae4a250104d4014de9bf8e2d47581e7a17fdadc4ecdf66700294f3ceb57b0
|
7
|
+
data.tar.gz: d633d2a3d4c7acbc2eb17fe13c41fcded11a6c172d20dca6062dde281d6fc4a462fa32456d706b35ea1965434f4715fc3e07cc600eae95c8aaadd4f51d6a28cd
|
data/lib/rbvmomi/version.rb
CHANGED
data/lib/rbvmomi/vim.rb
CHANGED
@@ -28,6 +28,7 @@ class VIM < Connection
|
|
28
28
|
# @option opts [String] :path (/sdk) SDK endpoint path.
|
29
29
|
# @option opts [Boolean] :debug (false) If true, print SOAP traffic to stderr.
|
30
30
|
# @option opts [String] :operation_id If set, use for operationID
|
31
|
+
# @option opts [Boolean] :close_on_exit (true) If true, will close connection with at_exit
|
31
32
|
def self.connect opts
|
32
33
|
fail unless opts.is_a? Hash
|
33
34
|
fail "host option required" unless opts[:host]
|
@@ -64,7 +65,7 @@ class VIM < Connection
|
|
64
65
|
vim.rev = [rev, opts[:rev]].min { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
|
65
66
|
end
|
66
67
|
|
67
|
-
at_exit { conn.close }
|
68
|
+
at_exit { conn.close } if opts.fetch(:close_on_exit, true)
|
68
69
|
conn
|
69
70
|
end
|
70
71
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbvmomi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Lane
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|
@@ -134,7 +134,6 @@ files:
|
|
134
134
|
- README.md
|
135
135
|
- exe/rbvmomish
|
136
136
|
- lib/rbvmomi.rb
|
137
|
-
- lib/rbvmomi/#vim.rb#
|
138
137
|
- lib/rbvmomi/basic_types.rb
|
139
138
|
- lib/rbvmomi/connection.rb
|
140
139
|
- lib/rbvmomi/deserialization.rb
|
@@ -192,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
191
|
- !ruby/object:Gem::Version
|
193
192
|
version: '0'
|
194
193
|
requirements: []
|
195
|
-
rubygems_version: 3.0.
|
194
|
+
rubygems_version: 3.0.3
|
196
195
|
signing_key:
|
197
196
|
specification_version: 4
|
198
197
|
summary: Ruby interface to the VMware vSphere API
|
data/lib/rbvmomi/#vim.rb#
DELETED
@@ -1,155 +0,0 @@
|
|
1
|
-
# Copyright (c) 2011-2017 VMware, Inc. All Rights Reserved.
|
2
|
-
# SPDX-License-Identifier: MIT
|
3
|
-
|
4
|
-
require 'rbvmomi'
|
5
|
-
|
6
|
-
# Win32::SSPI is part of core on Windows
|
7
|
-
begin
|
8
|
-
require 'win32/sspi'
|
9
|
-
rescue LoadError
|
10
|
-
end
|
11
|
-
WIN32 = (defined? Win32::SSPI)
|
12
|
-
|
13
|
-
module RbVmomi
|
14
|
-
|
15
|
-
# A connection to one vSphere SDK endpoint.
|
16
|
-
# @see #serviceInstance
|
17
|
-
class VIM < Connection
|
18
|
-
# Connect to a vSphere SDK endpoint
|
19
|
-
#
|
20
|
-
# @param [Hash] opts The options hash.
|
21
|
-
# @option opts [String] :host Host to connect to.
|
22
|
-
# @option opts [Numeric] :port (443) Port to connect to.
|
23
|
-
# @option opts [Boolean] :ssl (true) Whether to use SSL.
|
24
|
-
# @option opts [Boolean] :insecure (false) If true, ignore SSL certificate errors.
|
25
|
-
# @option opts [String] :cookie If set, use cookie to connect instead of user/password
|
26
|
-
# @option opts [String] :user (root) Username.
|
27
|
-
# @option opts [String] :password Password.
|
28
|
-
# @option opts [String] :path (/sdk) SDK endpoint path.
|
29
|
-
# @option opts [Boolean] :debug (false) If true, print SOAP traffic to stderr.
|
30
|
-
# @option opts [String] :operation_id If set, use for operationID
|
31
|
-
def self.connect opts
|
32
|
-
fail unless opts.is_a? Hash
|
33
|
-
fail "host option required" unless opts[:host]
|
34
|
-
opts[:cookie] ||= nil
|
35
|
-
opts[:user] ||= (WIN32 ? ENV['USERNAME'].dup : 'root')
|
36
|
-
opts[:password] ||= ''
|
37
|
-
opts[:ssl] = true unless opts.member? :ssl or opts[:"no-ssl"]
|
38
|
-
opts[:insecure] ||= false
|
39
|
-
opts[:port] ||= (opts[:ssl] ? 443 : 80)
|
40
|
-
opts[:path] ||= '/sdk'
|
41
|
-
opts[:ns] ||= 'urn:vim25'
|
42
|
-
opts[:rev] = '6.5' if opts[:rev].nil?
|
43
|
-
opts[:debug] = (!ENV['RBVMOMI_DEBUG'].empty? rescue false) unless opts.member? :debug
|
44
|
-
|
45
|
-
conn = new(opts).tap do |vim|
|
46
|
-
unless opts[:cookie]
|
47
|
-
if WIN32 && opts[:password] == ''
|
48
|
-
# Attempt login by SSPI if no password specified on Windows
|
49
|
-
negotiation = Win32::SSPI::NegotiateAuth.new opts[:user], ENV['USERDOMAIN'].dup
|
50
|
-
begin
|
51
|
-
vim.serviceContent.sessionManager.LoginBySSPI :base64Token => negotiation.get_initial_token
|
52
|
-
rescue RbVmomi::Fault => fault
|
53
|
-
if !fault.fault.is_a?(RbVmomi::VIM::SSPIChallenge)
|
54
|
-
raise
|
55
|
-
else
|
56
|
-
vim.serviceContent.sessionManager.LoginBySSPI :base64Token => negotiation.complete_authentication(fault.base64Token)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
else
|
60
|
-
vim.serviceContent.sessionManager.Login :userName => opts[:user], :password => opts[:password]
|
61
|
-
end
|
62
|
-
end
|
63
|
-
rev = vim.serviceContent.about.apiVersion
|
64
|
-
vim.rev = [rev, opts[:rev]].min { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
|
65
|
-
end
|
66
|
-
|
67
|
-
at_exit { conn.close }
|
68
|
-
conn
|
69
|
-
end
|
70
|
-
|
71
|
-
def close
|
72
|
-
serviceContent.sessionManager.Logout
|
73
|
-
rescue RbVmomi::Fault => e
|
74
|
-
$stderr.puts(e.message) if debug
|
75
|
-
ensure
|
76
|
-
self.cookie = nil
|
77
|
-
super
|
78
|
-
end
|
79
|
-
|
80
|
-
def rev= x
|
81
|
-
super
|
82
|
-
@serviceContent = nil
|
83
|
-
end
|
84
|
-
|
85
|
-
# Return the ServiceInstance
|
86
|
-
#
|
87
|
-
# The ServiceInstance is the root of the vSphere inventory.
|
88
|
-
# @see http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.ServiceInstance.html
|
89
|
-
def serviceInstance
|
90
|
-
VIM::ServiceInstance self, 'ServiceInstance'
|
91
|
-
end
|
92
|
-
|
93
|
-
# Alias to serviceInstance.RetrieveServiceContent
|
94
|
-
def serviceContent
|
95
|
-
@serviceContent ||= serviceInstance.RetrieveServiceContent
|
96
|
-
end
|
97
|
-
|
98
|
-
# Alias to serviceContent.rootFolder
|
99
|
-
def rootFolder
|
100
|
-
serviceContent.rootFolder
|
101
|
-
end
|
102
|
-
|
103
|
-
alias root rootFolder
|
104
|
-
|
105
|
-
# Alias to serviceContent.propertyCollector
|
106
|
-
def propertyCollector
|
107
|
-
serviceContent.propertyCollector
|
108
|
-
end
|
109
|
-
|
110
|
-
# Alias to serviceContent.searchIndex
|
111
|
-
def searchIndex
|
112
|
-
serviceContent.searchIndex
|
113
|
-
end
|
114
|
-
|
115
|
-
# @private
|
116
|
-
def pretty_print pp
|
117
|
-
pp.text "VIM(#{@opts[:host]})"
|
118
|
-
end
|
119
|
-
|
120
|
-
def instanceUuid
|
121
|
-
serviceContent.about.instanceUuid
|
122
|
-
end
|
123
|
-
|
124
|
-
def get_log_lines logKey, lines=5, start=nil, host=nil
|
125
|
-
diagMgr = self.serviceContent.diagnosticManager
|
126
|
-
if !start
|
127
|
-
log = diagMgr.BrowseDiagnosticLog(:host => host, :key => logKey, :start => 999999999)
|
128
|
-
lineEnd = log.lineEnd
|
129
|
-
start = lineEnd - lines
|
130
|
-
end
|
131
|
-
start = start < 0 ? 0 : start
|
132
|
-
log = diagMgr.BrowseDiagnosticLog(:host => host, :key => logKey, :start => start)
|
133
|
-
if log.lineText.size > 0
|
134
|
-
[log.lineText.slice(-lines, log.lineText.size), log.lineEnd]
|
135
|
-
else
|
136
|
-
[log.lineText, log.lineEnd]
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def get_log_keys host=nil
|
141
|
-
diagMgr = self.serviceContent.diagnosticManager
|
142
|
-
keys = []
|
143
|
-
diagMgr.QueryDescriptions(:host => host).each do |desc|
|
144
|
-
keys << "#{desc.key}"
|
145
|
-
end
|
146
|
-
keys
|
147
|
-
end
|
148
|
-
|
149
|
-
add_extension_dir File.join(File.dirname(__FILE__), "vim")
|
150
|
-
(ENV['RBVMOMI_VIM_EXTENSION_PATH']||'').split(':').each { |dir| add_extension_dir dir }
|
151
|
-
|
152
|
-
load_vmodl(ENV['VMODL'] || File.join(File.dirname(__FILE__), "../../vmodl.db"))
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|