lib/rvc/modules/vim.rb in rvc-1.2.1 vs lib/rvc/modules/vim.rb in rvc-1.2.2
- old
+ new
@@ -34,10 +34,11 @@
opts :connect do
summary 'Open a connection to ESX/VC'
arg :uri, "Host to connect to"
opt :insecure, "don't verify ssl certificate", :short => 'k', :default => (ENV['RBVMOMI_INSECURE'] == '1')
+ opt :rev, "Override protocol revision", :type => :string
end
rvc_alias :connect
def connect uri, opts
@@ -55,11 +56,11 @@
begin
vim = RbVmomi::VIM.new :host => host,
:port => 443,
:path => '/sdk',
:ns => 'urn:vim25',
- :rev => '4.0',
+ :rev => (opts[:rev]||'4.0'),
:ssl => true,
:insecure => insecure
break
rescue OpenSSL::SSL::SSLError
err "Connection failed" unless prompt_insecure
@@ -67,12 +68,15 @@
rescue Errno::EHOSTUNREACH, SocketError
err $!.message
end
end
- # negotiate API version
- rev = vim.serviceContent.about.apiVersion
- vim.rev = [rev, '4.1'].min
+ unless opts[:rev]
+ # negotiate API version
+ rev = vim.serviceContent.about.apiVersion
+ vim.rev = [rev, '4.1'].min
+ end
+
isVC = vim.serviceContent.about.apiType == "VirtualCenter"
# authenticate
if username == nil
username = isVC ? 'Administrator' : 'root'