flapjack 0.6.45 → 0.6.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,6 +35,7 @@ config = Flapjack::Configuration.new
|
|
35
35
|
config.load(options.config)
|
36
36
|
@config_env = config.all
|
37
37
|
@redis_options = config.for_redis
|
38
|
+
puts @redis_options.inspect
|
38
39
|
|
39
40
|
if @config_env.nil? || @config_env.empty?
|
40
41
|
puts "No config data for environment '#{FLAPJACK_ENV}' found in '#{options.config}'"
|
@@ -94,7 +95,7 @@ def process_input(redis)
|
|
94
95
|
end
|
95
96
|
|
96
97
|
def main
|
97
|
-
redis = Redis.new(@redis_options)
|
98
|
+
redis = Redis.new(@redis_options.merge(:driver => 'ruby'))
|
98
99
|
|
99
100
|
while true
|
100
101
|
process_input(redis)
|
@@ -3,16 +3,6 @@
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'logger'
|
5
5
|
|
6
|
-
require 'flapjack/executive'
|
7
|
-
|
8
|
-
require 'flapjack/gateways/api'
|
9
|
-
require 'flapjack/gateways/jabber'
|
10
|
-
require 'flapjack/gateways/oobetet'
|
11
|
-
require 'flapjack/gateways/pagerduty'
|
12
|
-
require 'flapjack/gateways/email'
|
13
|
-
require 'flapjack/gateways/sms'
|
14
|
-
require 'flapjack/gateways/web'
|
15
|
-
|
16
6
|
module Flapjack
|
17
7
|
|
18
8
|
class Configuration
|
@@ -62,37 +52,6 @@ module Flapjack
|
|
62
52
|
redis_config
|
63
53
|
end
|
64
54
|
|
65
|
-
PIKELET_TYPES = {'executive' => Flapjack::Executive}
|
66
|
-
|
67
|
-
GATEWAY_TYPES = {'web' => Flapjack::Gateways::Web,
|
68
|
-
'api' => Flapjack::Gateways::API,
|
69
|
-
'jabber' => Flapjack::Gateways::Jabber,
|
70
|
-
'pagerduty' => Flapjack::Gateways::Pagerduty,
|
71
|
-
'oobetet' => Flapjack::Gateways::Oobetet,
|
72
|
-
'email' => Flapjack::Gateways::Email,
|
73
|
-
'sms' => Flapjack::Gateways::Sms}
|
74
|
-
|
75
|
-
def pikelets
|
76
|
-
return {} unless @config_env
|
77
|
-
@config_env.inject({}) {|memo, (k, v)|
|
78
|
-
if klass = PIKELET_TYPES[k]
|
79
|
-
memo[klass] = v
|
80
|
-
end
|
81
|
-
memo
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
def gateways
|
86
|
-
return {} unless @config_env && @config_env['gateways'] &&
|
87
|
-
!@config_env['gateways'].nil?
|
88
|
-
@config_env['gateways'].inject({}) {|memo, (k, v)|
|
89
|
-
if klass = GATEWAY_TYPES[k]
|
90
|
-
memo[klass] = v
|
91
|
-
end
|
92
|
-
memo
|
93
|
-
}
|
94
|
-
end
|
95
|
-
|
96
55
|
def load(filename)
|
97
56
|
unless File.file?(filename)
|
98
57
|
logger.error "Could not find file '#{filename}'"
|
data/lib/flapjack/coordinator.rb
CHANGED
@@ -20,6 +20,16 @@ require 'flapjack/redis_pool'
|
|
20
20
|
require 'flapjack/pikelet'
|
21
21
|
require 'flapjack/gateways/base'
|
22
22
|
|
23
|
+
require 'flapjack/executive'
|
24
|
+
|
25
|
+
require 'flapjack/gateways/api'
|
26
|
+
require 'flapjack/gateways/jabber'
|
27
|
+
require 'flapjack/gateways/oobetet'
|
28
|
+
require 'flapjack/gateways/pagerduty'
|
29
|
+
require 'flapjack/gateways/email'
|
30
|
+
require 'flapjack/gateways/sms'
|
31
|
+
require 'flapjack/gateways/web'
|
32
|
+
|
23
33
|
module Flapjack
|
24
34
|
|
25
35
|
class Coordinator
|
@@ -62,12 +72,14 @@ module Flapjack
|
|
62
72
|
|
63
73
|
EM.synchrony do
|
64
74
|
|
65
|
-
@config.
|
75
|
+
config_env = @config.all
|
76
|
+
|
77
|
+
pikelets(config_env).each_pair do |pikelet_class, pikelet_cfg|
|
66
78
|
next unless pikelet_cfg['enabled']
|
67
79
|
build_pikelet(pikelet_class, pikelet_cfg)
|
68
80
|
end
|
69
81
|
|
70
|
-
|
82
|
+
gateways(config_env).each_pair do |gateway_class, gateway_cfg|
|
71
83
|
# TODO split out gateway logic to build_gateway
|
72
84
|
next unless gateway_cfg['enabled']
|
73
85
|
build_pikelet(gateway_class, gateway_cfg)
|
@@ -250,6 +262,38 @@ module Flapjack
|
|
250
262
|
(class << klass; self; end).included_modules
|
251
263
|
end
|
252
264
|
|
265
|
+
PIKELET_TYPES = {'executive' => Flapjack::Executive}
|
266
|
+
|
267
|
+
GATEWAY_TYPES = {'web' => Flapjack::Gateways::Web,
|
268
|
+
'api' => Flapjack::Gateways::API,
|
269
|
+
'jabber' => Flapjack::Gateways::Jabber,
|
270
|
+
'pagerduty' => Flapjack::Gateways::Pagerduty,
|
271
|
+
'oobetet' => Flapjack::Gateways::Oobetet,
|
272
|
+
'email' => Flapjack::Gateways::Email,
|
273
|
+
'sms' => Flapjack::Gateways::Sms}
|
274
|
+
|
275
|
+
|
276
|
+
def pikelets(config_env)
|
277
|
+
return {} unless config_env
|
278
|
+
config_env.inject({}) {|memo, (k, v)|
|
279
|
+
if klass = PIKELET_TYPES[k]
|
280
|
+
memo[klass] = v
|
281
|
+
end
|
282
|
+
memo
|
283
|
+
}
|
284
|
+
end
|
285
|
+
|
286
|
+
def gateways(config_env)
|
287
|
+
return {} unless config_env && config_env['gateways'] &&
|
288
|
+
!config_env['gateways'].nil?
|
289
|
+
config_env['gateways'].inject({}) {|memo, (k, v)|
|
290
|
+
if klass = GATEWAY_TYPES[k]
|
291
|
+
memo[klass] = v
|
292
|
+
end
|
293
|
+
memo
|
294
|
+
}
|
295
|
+
end
|
296
|
+
|
253
297
|
end
|
254
298
|
|
255
299
|
end
|
@@ -121,7 +121,7 @@ module Flapjack
|
|
121
121
|
action = nil
|
122
122
|
entity_check = nil
|
123
123
|
case
|
124
|
-
when command =~ /^ACKID\s+(\d+)(?:\s*(.*?)(?:\s*duration
|
124
|
+
when command =~ /^ACKID\s+(\d+)(?:\s*(.*?)(?:\s*duration:.*?(\w+.*))?)$/i;
|
125
125
|
ackid = $1
|
126
126
|
comment = $2
|
127
127
|
duration_str = $3
|
data/lib/flapjack/version.rb
CHANGED
@@ -27,8 +27,7 @@ describe Flapjack::Coordinator do
|
|
27
27
|
it "runs undaemonized" do
|
28
28
|
EM.should_receive(:synchrony).and_yield
|
29
29
|
config.should_receive(:for_redis).and_return({})
|
30
|
-
config.should_receive(:
|
31
|
-
config.should_receive(:gateways).and_return({})
|
30
|
+
config.should_receive(:all).and_return('executive' => {'enabled' => 'yes'})
|
32
31
|
|
33
32
|
fc = Flapjack::Coordinator.new(config)
|
34
33
|
fc.should_receive(:build_pikelet)
|
@@ -39,8 +38,7 @@ describe Flapjack::Coordinator do
|
|
39
38
|
EM.should_receive(:synchrony).and_yield
|
40
39
|
|
41
40
|
config.should_receive(:for_redis).and_return({})
|
42
|
-
config.should_receive(:
|
43
|
-
config.should_receive(:gateways).and_return({})
|
41
|
+
config.should_receive(:all).and_return('executive' => {'enabled' => 'yes'})
|
44
42
|
|
45
43
|
fc = Flapjack::Coordinator.new(config)
|
46
44
|
fc.should_receive(:build_pikelet)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flapjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.46
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-11-
|
14
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: daemons
|