diff --git a/lib/rbvmomi/vim.rb b/lib/rbvmomi/vim.rb index f4ef9141..c80e6db0 100644 --- a/lib/rbvmomi/vim.rb +++ b/lib/rbvmomi/vim.rb @@ -39,8 +39,7 @@ def self.connect opts opts[:port] ||= (opts[:ssl] ? 443 : 80) opts[:path] ||= '/sdk' opts[:ns] ||= 'urn:vim25' - rev_given = opts[:rev] != nil - opts[:rev] = '6.5' unless rev_given + opts[:rev] = '6.5' if opts[:rev].nil? opts[:debug] = (!ENV['RBVMOMI_DEBUG'].empty? rescue false) unless opts.member? :debug conn = new(opts).tap do |vim| @@ -61,10 +60,8 @@ def self.connect opts vim.serviceContent.sessionManager.Login :userName => opts[:user], :password => opts[:password] end end - unless rev_given - rev = vim.serviceContent.about.apiVersion - vim.rev = [rev, '6.5'].min - end + rev = vim.serviceContent.about.apiVersion + vim.rev = [rev, opts[:rev]].min { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) } end at_exit { conn.close }