Method: OpenStack::Connection#initialize
- Defined in:
- lib/openstack/connection.rb
#initialize(options = {:retry_auth => true}) ⇒ Connection
Returns a new instance of Connection.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/openstack/connection.rb', line 112 def initialize( = {:retry_auth => true}) @retries = [:retries] || 3 @authuser = [:username] || (raise Exception::MissingArgument, "Must supply a :username") @authkey = [:api_key] || (raise Exception::MissingArgument, "Must supply an :api_key") @auth_url = [:auth_url] || (raise Exception::MissingArgument, "Must supply an :auth_url") @authtenant = ([:authtenant_id])? {:type => "tenantId", :value=>[:authtenant_id]} : {:type=>"tenantName", :value=>([:authtenant_name] || [:authtenant] || @authuser)} @auth_method = [:auth_method] || "password" @service_name = [:service_name] || nil @service_type = [:service_type] || "compute" @user_domain_id = [:user_domain_id] || "default" @user_domain = [:user_domain] || nil @project_id = [:project_id] || nil @project_name = [:project_name] || nil @logger = [:logger] || nil @project_domain_name = [:project_domain_name] || nil @project_domain_id = [:project_domain_id] || nil @domain_name = [:domain_name] || nil @domain_id = [:domain_id] || nil @region = [:region] || @region = nil @regions_list = {} # this is populated during authentication - from the returned service catalogue @is_debug = [:is_debug] auth_uri=nil begin auth_uri=URI.parse(@auth_url) rescue Exception => e raise Exception::InvalidArgument, "Invalid :auth_url parameter: #{e.}" end raise Exception::InvalidArgument, "Invalid :auth_url parameter." if auth_uri.nil? or auth_uri.host.nil? @auth_host = auth_uri.host @auth_port = auth_uri.port @auth_scheme = auth_uri.scheme @auth_path = auth_uri.path @retry_auth = [:retry_auth] @proxy_host = [:proxy_host] @proxy_port = [:proxy_port] @ca_cert = [:ca_cert] @ssl_version = [:ssl_version] @authok = false @http = {} @quantum_version = 'v2.0' if @service_type == 'network' @quantum_version = 'v2' if @service_type == 'metering' @endpoint_type = [:endpoint_type] || "publicURL" end |