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 the options parameter

300
VERSION =
"0.4.0"

Class Method Summary collapse

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.

Parameters:

  • account_file (defaults to: ENV['ACCOUNT_FILE'])

    the path to a YAML file (see accounts.example.yml).

Returns:

  • (Hash)

    the cleaned, validated Hash of account info.



27
28
29
30
# File 'lib/fog_tracker.rb', line 27

def self.read_accounts( = ENV['ACCOUNT_FILE'])
   ||= "./config/accounts.yml"
  FogTracker.validate_accounts(YAML::load(File.read ))
end

.validate_accounts(account_hash) ⇒ Hash

Performs validation and cleanup on an Array of account Hashes. Changes Strings to Symbols for all required keys.

Parameters:

  • account_array (Hash)

    an Array of Hash objects.

Returns:

  • (Hash)

    the cleaned, validated Hash of account info.



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()
  .each do |name, |
    .symbolize_keys
    raise "Account #{name} defines no service" if not [:service]
    raise "Account #{name} defines no provider" if not [:provider]
    raise "Account #{name} defines no credentials" if not [:credentials]
    if [:exclude_resources]
      [:exclude_resources] = [:exclude_resources].map do |r|
        r.to_sym
      end
    end
  end
  
end