class Rackspace::Base
Constants
- DEFAULT_CREDENTIALS
Attributes
account[R]
credentials[R]
logger[R]
region[R]
Public Class Methods
new(params)
click to toggle source
# 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
Public Instance Methods
log(msg)
click to toggle source
# File lib/rackspace/base.rb, line 17 def log(msg) logger.log(msg) end
server_api()
click to toggle source
# File lib/rackspace/base.rb, line 21 def server_api @server_api ||= ServerApi.new(rackspace_credentials) end
storage_api()
click to toggle source
# File lib/rackspace/base.rb, line 25 def storage_api @storage_api ||= StorageApi.new(rackspace_credentials) end
Private Instance Methods
accounts()
click to toggle source
# File lib/rackspace/base.rb, line 31 def accounts credentials.fetch(:accounts) { raise("No :accounts section found in credentials") } end
rackspace_credentials()
click to toggle source
# File lib/rackspace/base.rb, line 35 def rackspace_credentials { rackspace_username: account, rackspace_api_key: accounts.fetch(account) { raise("No API key found for account: #{account}") }, rackspace_region: region, } end