fog_tracker 0.3.4 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/config/{accounts.yml.example → accounts.example.yml} +0 -0
- data/fog_tracker.gemspec +2 -1
- data/lib/fog_tracker.rb +8 -0
- data/lib/fog_tracker/tracker.rb +3 -3
- data/lib/fog_tracker/version.rb +1 -1
- data/lib/tasks/track.rake +15 -0
- data/spec/lib/fog_tracker_spec.rb +15 -7
- metadata +23 -24
- data/bin/fog_tracker +0 -73
File without changes
|
data/fog_tracker.gemspec
CHANGED
@@ -22,7 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
24
|
# Runtime dependencies
|
25
|
-
|
25
|
+
# Fog v1.2.0 has a bug in Compute[:aws].servers
|
26
|
+
s.add_dependency "fog", '=1.1.2'
|
26
27
|
|
27
28
|
# Development / Test dependencies
|
28
29
|
s.add_development_dependency "rake"
|
data/lib/fog_tracker.rb
CHANGED
@@ -21,6 +21,14 @@ module FogTracker
|
|
21
21
|
logger
|
22
22
|
end
|
23
23
|
|
24
|
+
# Loads account information defined in account_file.
|
25
|
+
# @param account_file the path to a YAML file (see accounts.example.yml).
|
26
|
+
# @return [Hash] the cleaned, validated Hash of account info.
|
27
|
+
def self.read_accounts(account_file = ENV['ACCOUNT_FILE'])
|
28
|
+
account_file ||= "./config/accounts.yml"
|
29
|
+
FogTracker.validate_accounts(YAML::load(File.read account_file))
|
30
|
+
end
|
31
|
+
|
24
32
|
# Performs validation and cleanup on an Array of account Hashes.
|
25
33
|
# Changes Strings to Symbols for all required keys.
|
26
34
|
# @param [Hash] account_array an Array of Hash objects.
|
data/lib/fog_tracker/tracker.rb
CHANGED
@@ -3,12 +3,12 @@ module FogTracker
|
|
3
3
|
# Tracks one or more Fog accounts and exposes a {#query} on the results
|
4
4
|
class Tracker
|
5
5
|
|
6
|
-
#a Hash of account information (see accounts.yml
|
6
|
+
#a Hash of account information (see accounts.example.yml)
|
7
7
|
attr_reader :accounts
|
8
8
|
|
9
9
|
# Creates an object for tracking multiple Fog accounts
|
10
10
|
# @param [Hash] accounts a Hash of account information
|
11
|
-
# (see accounts.yml
|
11
|
+
# (see accounts.example.yml)
|
12
12
|
# @param [Hash] options optional additional parameters:
|
13
13
|
# - :delay (Integer) - Default time between polling of accounts
|
14
14
|
# - :callback (Proc) - A Method or Proc to call each time an account is polled.
|
@@ -105,7 +105,7 @@ module FogTracker
|
|
105
105
|
# Sets the account information.
|
106
106
|
# If any account info has changed, all trackers are restarted.
|
107
107
|
# @param [Hash] accounts a Hash of account information
|
108
|
-
# (see accounts.yml
|
108
|
+
# (see accounts.example.yml)
|
109
109
|
def accounts=(new_accounts)
|
110
110
|
old_accounts = @accounts
|
111
111
|
@accounts = FogTracker.validate_accounts(new_accounts)
|
data/lib/fog_tracker/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
desc "Runs the tracker [LOG_LEVEL=[INFO]]"
|
2
|
+
task :track do
|
3
|
+
require File.join(File.dirname(__FILE__), '..', 'fog_tracker')
|
4
|
+
|
5
|
+
# Setup logging
|
6
|
+
log = FogTracker.default_logger(STDOUT)
|
7
|
+
log.level = ::Logger.const_get((ENV['LOG_LEVEL'] || 'INFO').to_sym)
|
8
|
+
|
9
|
+
log.info "Loading account information..."
|
10
|
+
accounts = FogTracker.read_accounts './config/accounts.yml'
|
11
|
+
|
12
|
+
FogTracker::Tracker.new(accounts, {:logger => log}).start
|
13
|
+
while true do ; sleep 60 end # Loop forever
|
14
|
+
|
15
|
+
end
|
@@ -1,25 +1,33 @@
|
|
1
1
|
module FogTracker
|
2
|
-
|
2
|
+
|
3
|
+
describe '#read_accounts' do
|
4
|
+
it "converts a YAML file into a Hash of account info" do
|
5
|
+
accounts = FogTracker.read_accounts('./config/accounts.example.yml')
|
6
|
+
accounts.should be_a Hash
|
7
|
+
accounts.should_not be_empty
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
3
11
|
describe '#validate_accounts' do
|
4
|
-
it "
|
12
|
+
it "raises an exception when no service is specified" do
|
5
13
|
(Proc.new { FogTracker.validate_accounts(
|
6
14
|
FAKE_ACCOUNT_NAME => FAKE_ACCOUNT.merge({:service => nil})
|
7
15
|
)}).should raise_error
|
8
16
|
end
|
9
|
-
|
10
|
-
it "
|
17
|
+
|
18
|
+
it "raises an exception when no provider is specified" do
|
11
19
|
(Proc.new { FogTracker.validate_accounts(
|
12
20
|
FAKE_ACCOUNT_NAME => FAKE_ACCOUNT.merge({:provider => nil})
|
13
21
|
)}).should raise_error
|
14
22
|
end
|
15
|
-
|
16
|
-
it "
|
23
|
+
|
24
|
+
it "raises an exception when no credentials are specified" do
|
17
25
|
(Proc.new { FogTracker.validate_accounts(
|
18
26
|
FAKE_ACCOUNT_NAME => FAKE_ACCOUNT.merge({:credentials => nil})
|
19
27
|
)}).should raise_error
|
20
28
|
end
|
21
29
|
|
22
|
-
it "
|
30
|
+
it "symbolizes all account keys" do
|
23
31
|
validated_accounts = FogTracker.validate_accounts(
|
24
32
|
FAKE_ACCOUNT_NAME => {
|
25
33
|
'provider' => 'AWS',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fog
|
16
|
-
requirement: &
|
16
|
+
requirement: &70290730545600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.1.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70290730545600
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70290730539940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70290730539940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70290730530160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70290730530160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &70290730526680 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70290730526680
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard
|
60
|
-
requirement: &
|
60
|
+
requirement: &70290730524120 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70290730524120
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &70290730521300 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70290730521300
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: ruby_gntp
|
82
|
-
requirement: &
|
82
|
+
requirement: &70290730310040 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,13 +87,12 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70290730310040
|
91
91
|
description: This gem peridically polls mutiple cloud computing services using the
|
92
92
|
fog gem, asynchronously updating the state of the resulting collections of Fog Resources.
|
93
93
|
email:
|
94
94
|
- benton@bentonroberts.com
|
95
|
-
executables:
|
96
|
-
- fog_tracker
|
95
|
+
executables: []
|
97
96
|
extensions: []
|
98
97
|
extra_rdoc_files: []
|
99
98
|
files:
|
@@ -104,8 +103,7 @@ files:
|
|
104
103
|
- LICENSE.TXT
|
105
104
|
- README.md
|
106
105
|
- Rakefile
|
107
|
-
-
|
108
|
-
- config/accounts.yml.example
|
106
|
+
- config/accounts.example.yml
|
109
107
|
- fog_tracker.gemspec
|
110
108
|
- lib/fog_tracker.rb
|
111
109
|
- lib/fog_tracker/account_tracker.rb
|
@@ -117,6 +115,7 @@ files:
|
|
117
115
|
- lib/fog_tracker/util/string_underscore.rb
|
118
116
|
- lib/fog_tracker/version.rb
|
119
117
|
- lib/tasks/rspec.rake
|
118
|
+
- lib/tasks/track.rake
|
120
119
|
- spec/lib/fog_tracker/account_tracker_spec.rb
|
121
120
|
- spec/lib/fog_tracker/collection_tracker_spec.rb
|
122
121
|
- spec/lib/fog_tracker/extensions/fog_model_spec.rb
|
@@ -141,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
140
|
version: '0'
|
142
141
|
segments:
|
143
142
|
- 0
|
144
|
-
hash:
|
143
|
+
hash: -1170305047196625380
|
145
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
145
|
none: false
|
147
146
|
requirements:
|
@@ -150,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
149
|
version: '0'
|
151
150
|
segments:
|
152
151
|
- 0
|
153
|
-
hash:
|
152
|
+
hash: -1170305047196625380
|
154
153
|
requirements: []
|
155
154
|
rubyforge_project: fog_tracker
|
156
155
|
rubygems_version: 1.8.15
|
data/bin/fog_tracker
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# == Synopsis
|
4
|
-
# Uses the Fog gem to track the status of cloud computing resources
|
5
|
-
#
|
6
|
-
# == Usage
|
7
|
-
# fog_tracker.rb [options] ACCOUNTS_CONFIG_FILE.YML
|
8
|
-
#
|
9
|
-
# == Options (all options can be put into the config file)
|
10
|
-
# -d, --delay [INTEGER] Seconds between status updates.
|
11
|
-
# -l, --log-level [LEVEL] Sets Log4r level for console output. default = INFO
|
12
|
-
# -h, --help Displays help message
|
13
|
-
#
|
14
|
-
# == Author
|
15
|
-
# Benton Roberts
|
16
|
-
|
17
|
-
require 'optparse'
|
18
|
-
require 'fog_tracker'
|
19
|
-
LOG_LVLS = {
|
20
|
-
"DEBUG" => ::Logger::DEBUG,
|
21
|
-
"INFO" => ::Logger::INFO,
|
22
|
-
"WARN" => ::Logger::WARN,
|
23
|
-
"ERROR" => ::Logger::ERROR,
|
24
|
-
"FATAL" => ::Logger::FATAL
|
25
|
-
}
|
26
|
-
|
27
|
-
module FogTracker
|
28
|
-
class FogTrackerConsoleApp
|
29
|
-
|
30
|
-
def initialize
|
31
|
-
@log = FogTracker.default_logger(STDOUT)
|
32
|
-
parse_options
|
33
|
-
@log.info "Loading account information from #{ARGV[0]}"
|
34
|
-
@accounts = YAML::load(File.open(ARGV[0]))
|
35
|
-
@tracker = FogTracker::Tracker.new(
|
36
|
-
@accounts, {:logger => @log, :delay => @opts[:delay]}
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
def go
|
41
|
-
@tracker.start
|
42
|
-
while true do
|
43
|
-
sleep 60 # Loop forever
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def parse_options
|
48
|
-
@opts = {:log_level => 'INFO'}
|
49
|
-
optparse = OptionParser.new do |opts|
|
50
|
-
opts.banner = "Usage: tracker [options] ACCOUNTS.YML"
|
51
|
-
opts.on('-d', '--delay SECONDS', Integer,
|
52
|
-
'Number of seconds between status updates') do |delay|
|
53
|
-
@opts[:delay] = delay
|
54
|
-
end
|
55
|
-
opts.on('-l', '--log-level LEVEL', 'Set logging level') do |log_level|
|
56
|
-
@opts[:log_level] = log_level.upcase
|
57
|
-
end
|
58
|
-
opts.on('-h', '--help', 'Display this help message') do
|
59
|
-
puts opts ; exit
|
60
|
-
end
|
61
|
-
end
|
62
|
-
optparse.parse!
|
63
|
-
@log.level = LOG_LVLS[@opts[:log_level]] if LOG_LVLS[@opts[:log_level]]
|
64
|
-
if ARGV.count < 1
|
65
|
-
@log.error "A YAML file with account info must be specified"
|
66
|
-
exit 1
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
FogTracker::FogTrackerConsoleApp.new.go
|