Method: Fog::Compute::AWS::Real#initialize

Defined in:
lib/fog/aws/compute.rb

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.


314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/fog/aws/compute.rb', line 314

def initialize(options={})
  require 'fog/core/parser'

  @use_iam_profile = options[:use_iam_profile]
  setup_credentials(options)
  @connection_options     = options[:connection_options] || {}
  @region                 = options[:region] ||= 'us-east-1'
  @instrumentor           = options[:instrumentor]
  @instrumentor_name      = options[:instrumentor_name] || 'fog.aws.compute'
  @version                = options[:version]     ||  '2012-07-20'

  if @endpoint = options[:endpoint]
    endpoint = URI.parse(@endpoint)
    @host = endpoint.host
    @path = endpoint.path
    @port = endpoint.port
    @scheme = endpoint.scheme
  else
    @host = options[:host] || "ec2.#{options[:region]}.amazonaws.com"
    @path       = options[:path]        || '/'
    @persistent = options[:persistent]  || false
    @port       = options[:port]        || 443
    @scheme     = options[:scheme]      || 'https'
  end
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end