lib/rbvmomi/vim.rb in rbvmomi-2.1.2 vs lib/rbvmomi/vim.rb in rbvmomi-2.2.0

- old
+ new

@@ -25,10 +25,11 @@ # @option opts [String] :password Password. # @option opts [String] :path (/sdk) SDK endpoint path. # @option opts [Boolean] :debug (false) If true, print SOAP traffic to stderr. # @option opts [String] :operation_id If set, use for operationID # @option opts [Boolean] :close_on_exit (true) If true, will close connection with at_exit + # @option opts [RbVmomi::SSO] :sso (nil) Use SSO token to login if set def self.connect opts fail unless opts.is_a? Hash fail "host option required" unless opts[:host] opts[:cookie] ||= nil opts[:user] ||= (WIN32 ? ENV['USERNAME'].dup : 'root') @@ -36,11 +37,11 @@ opts[:ssl] = true unless opts.member? :ssl or opts[:"no-ssl"] opts[:insecure] ||= false opts[:port] ||= (opts[:ssl] ? 443 : 80) opts[:path] ||= '/sdk' opts[:ns] ||= 'urn:vim25' - opts[:rev] = '6.5' if opts[:rev].nil? + opts[:rev] = '6.7' if opts[:rev].nil? opts[:debug] = (!ENV['RBVMOMI_DEBUG'].empty? rescue false) unless opts.member? :debug conn = new(opts).tap do |vim| unless opts[:cookie] if WIN32 && opts[:password] == '' @@ -53,11 +54,13 @@ raise else vim.serviceContent.sessionManager.LoginBySSPI :base64Token => negotiation.complete_authentication(fault.base64Token) end end + elsif opts[:sso] + vim.serviceContent.sessionManager.LoginByToken else - vim.serviceContent.sessionManager.Login :userName => opts[:user], :password => opts[:password] + vim.serviceContent.sessionManager.Login :userName => opts[:user], :password => opts[:password] end end rev = vim.serviceContent.about.apiVersion vim.rev = [rev, opts[:rev]].min { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) } end