Class: OpenStack::Compute::AuthV10
- Inherits:
-
Object
- Object
- OpenStack::Compute::AuthV10
- Defined in:
- lib/openstack/compute/authentication.rb
Instance Method Summary collapse
-
#initialize(connection) ⇒ AuthV10
constructor
A new instance of AuthV10.
Constructor Details
#initialize(connection) ⇒ AuthV10
Returns a new instance of AuthV10.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/openstack/compute/authentication.rb', line 89 def initialize(connection) hdrhash = { "X-Auth-User" => connection.authuser, "X-Auth-Key" => connection.authkey } begin server = Net::HTTP::Proxy(connection.proxy_host, connection.proxy_port).new(connection.auth_host, connection.auth_port) if connection.auth_scheme == "https" server.use_ssl = true server.verify_mode = OpenSSL::SSL::VERIFY_NONE end server.start rescue raise OpenStack::Compute::Exception::Connection, "Unable to connect to #{server}" end response = server.get(connection.auth_path, hdrhash) if (response.code =~ /^20./) connection.authtoken = response["x-auth-token"] uri = URI.parse(response["x-server-management-url"]) connection.svrmgmthost = uri.host connection.svrmgmtpath = uri.path connection.svrmgmtport = uri.port connection.svrmgmtscheme = uri.scheme connection.authok = true else connection.authtoken = false raise OpenStack::Compute::Exception::Authentication, "Authentication failed with response code #{response.code}" end server.finish end |