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(options = {:retry_auth => true})
  @retries = options[:retries] || 3
  @authuser = options[:username] || (raise Exception::MissingArgument, "Must supply a :username")
  @authkey = options[:api_key] || (raise Exception::MissingArgument, "Must supply an :api_key")
  @auth_url = options[:auth_url] || (raise Exception::MissingArgument, "Must supply an :auth_url")
  @authtenant = (options[:authtenant_id])? {:type => "tenantId", :value=>options[:authtenant_id]} : {:type=>"tenantName", :value=>(options[:authtenant_name] || options[:authtenant] || @authuser)}
  @auth_method = options[:auth_method] || "password"
  @service_name = options[:service_name] || nil
  @service_type = options[:service_type] || "compute"
  @user_domain_id = options[:user_domain_id] || "default"
  @user_domain = options[:user_domain] || nil
  @project_id = options[:project_id] || nil
  @project_name = options[:project_name] || nil
  @logger = options[:logger] || nil
  @project_domain_name = options[:project_domain_name] || nil
  @project_domain_id = options[:project_domain_id] || nil
  @domain_name = options[:domain_name] || nil
  @domain_id = options[:domain_id] || nil
  @region = options[:region] || @region = nil
  @regions_list = {} # this is populated during authentication - from the returned service catalogue
  @is_debug = options[:is_debug]
  auth_uri=nil
  begin
    auth_uri=URI.parse(@auth_url)
  rescue Exception => e
    raise Exception::InvalidArgument, "Invalid :auth_url parameter: #{e.message}"
  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 = options[:retry_auth]
  @proxy_host = options[:proxy_host]
  @proxy_port = options[:proxy_port]
  @ca_cert = options[:ca_cert]
  @ssl_version = options[:ssl_version]
  @authok = false
  @http = {}
  @quantum_version = 'v2.0' if @service_type == 'network'
  @quantum_version = 'v2' if @service_type == 'metering'
  @endpoint_type = options[:endpoint_type] || "publicURL"
end