Module: FogTracker
- Defined in:
- lib/fog_tracker.rb,
lib/fog_tracker/tracker.rb,
lib/fog_tracker/version.rb,
lib/fog_tracker/account_tracker.rb,
lib/fog_tracker/collection_tracker.rb,
lib/fog_tracker/extensions/fog_model.rb,
lib/fog_tracker/query/query_processor.rb
Defined Under Namespace
Modules: Extensions, Query Classes: AccountTracker, CollectionTracker, Tracker
Constant Summary collapse
- DEFAULT_POLLING_TIME =
The default polling interval in seconds This. can be overriden when a FogTracker::Tracker is created, either in the
accounts
definitions, or in theoptions
parameter 300
- VERSION =
"0.4.0"
Class Method Summary collapse
-
.default_logger(output = nil) ⇒ Object
Returns a slightly-modified version of the default Ruby Logger.
-
.read_accounts(account_file = ENV['ACCOUNT_FILE']) ⇒ Hash
Loads account information defined in account_file.
-
.validate_accounts(account_hash) ⇒ Hash
Performs validation and cleanup on an Array of account Hashes.
Class Method Details
.default_logger(output = nil) ⇒ Object
Returns a slightly-modified version of the default Ruby Logger
15 16 17 18 19 20 21 22 |
# File 'lib/fog_tracker.rb', line 15 def self.default_logger(output = nil) logger = ::Logger.new(output) logger.sev_threshold = Logger::INFO logger.formatter = proc {|lvl, time, prog, msg| "#{lvl} #{time.strftime '%Y-%m-%d %H:%M:%S %Z'}: #{msg}\n" } logger end |
.read_accounts(account_file = ENV['ACCOUNT_FILE']) ⇒ Hash
Loads account information defined in account_file.
27 28 29 30 |
# File 'lib/fog_tracker.rb', line 27 def self.read_accounts(account_file = ENV['ACCOUNT_FILE']) account_file ||= "./config/accounts.yml" FogTracker.validate_accounts(YAML::load(File.read account_file)) end |
.validate_accounts(account_hash) ⇒ Hash
Performs validation and cleanup on an Array of account Hashes. Changes Strings to Symbols for all required keys.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fog_tracker.rb', line 36 def self.validate_accounts(account_hash) account_hash.each do |name, account| account.symbolize_keys raise "Account #{name} defines no service" if not account[:service] raise "Account #{name} defines no provider" if not account[:provider] raise "Account #{name} defines no credentials" if not account[:credentials] if account[:exclude_resources] account[:exclude_resources] = account[:exclude_resources].map do |r| r.to_sym end end end account_hash end |