Class: Rackspace::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/rackspace/base.rb

Direct Known Subclasses

Vm, Volume

Constant Summary collapse

DEFAULT_CREDENTIALS =
'rackspace_credentials.yml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
14
15
# File 'lib/rackspace/base.rb', line 7

def initialize(params)
  @logger            = params.fetch(:logger, Rackspace::Logger.new)
  @account           = params.fetch(:account)
  @region            = params.fetch(:region, DEFAULT_REGION)
  @credentials       = params.fetch(:credentials) {
    credentials_file = params.fetch(:credentials_file, DEFAULT_CREDENTIALS)
    YAML.load(File.read(credentials_file))
  }
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



3
4
5
# File 'lib/rackspace/base.rb', line 3

def 
  @account
end

#credentialsObject (readonly)

Returns the value of attribute credentials.



3
4
5
# File 'lib/rackspace/base.rb', line 3

def credentials
  @credentials
end

#loggerObject (readonly)

Returns the value of attribute logger.



3
4
5
# File 'lib/rackspace/base.rb', line 3

def logger
  @logger
end

#regionObject (readonly)

Returns the value of attribute region.



3
4
5
# File 'lib/rackspace/base.rb', line 3

def region
  @region
end

Instance Method Details

#log(msg) ⇒ Object



17
18
19
# File 'lib/rackspace/base.rb', line 17

def log(msg)
  logger.log(msg)
end

#server_apiObject



21
22
23
# File 'lib/rackspace/base.rb', line 21

def server_api
  @server_api ||= ServerApi.new(rackspace_credentials)
end

#storage_apiObject



25
26
27
# File 'lib/rackspace/base.rb', line 25

def storage_api
  @storage_api ||= StorageApi.new(rackspace_credentials)
end