flapjack 0.7.18 → 0.7.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. data/CHANGELOG.md +7 -0
  2. data/bin/flapjack +3 -0
  3. data/bin/flapjack-nagios-receiver +4 -1
  4. data/bin/flapjack-netsaint-parser +2 -1
  5. data/bin/flapjack-populator +6 -3
  6. data/bin/receive-events +3 -1
  7. data/bin/simulate-failed-check +2 -1
  8. data/etc/flapjack_config.yaml.example +20 -0
  9. data/features/events.feature +1 -1
  10. data/features/events_check_names.feature +1 -1
  11. data/features/notification_rules.feature +1 -1
  12. data/features/notifications.feature +1 -1
  13. data/features/steps/events_steps.rb +18 -17
  14. data/features/steps/flapjack-netsaint-parser_steps.rb +1 -2
  15. data/features/steps/notifications_steps.rb +14 -1
  16. data/features/support/env.rb +27 -10
  17. data/flapjack.gemspec +1 -3
  18. data/lib/flapjack/coordinator.rb +30 -20
  19. data/lib/flapjack/data/contact.rb +3 -2
  20. data/lib/flapjack/data/entity.rb +3 -3
  21. data/lib/flapjack/data/entity_check.rb +116 -43
  22. data/lib/flapjack/data/event.rb +10 -10
  23. data/lib/flapjack/data/message.rb +3 -6
  24. data/lib/flapjack/data/notification.rb +122 -57
  25. data/lib/flapjack/data/notification_rule.rb +11 -11
  26. data/lib/flapjack/filters/acknowledgement.rb +2 -2
  27. data/lib/flapjack/filters/ok.rb +1 -1
  28. data/lib/flapjack/gateways/api/entity_check_presenter.rb +1 -0
  29. data/lib/flapjack/gateways/api/entity_methods.rb +4 -6
  30. data/lib/flapjack/gateways/api/rack/json_params_parser.rb +1 -1
  31. data/lib/flapjack/gateways/email.rb +3 -5
  32. data/lib/flapjack/gateways/email/{alert.html.haml → alert.html.erb} +0 -0
  33. data/lib/flapjack/gateways/jabber.rb +66 -35
  34. data/lib/flapjack/gateways/oobetet.rb +5 -7
  35. data/lib/flapjack/gateways/pagerduty.rb +7 -7
  36. data/lib/flapjack/gateways/web.rb +101 -41
  37. data/lib/flapjack/gateways/web/public/css/flapjack.css +1 -1
  38. data/lib/flapjack/gateways/web/views/{_css.haml → _css.html.erb} +2 -1
  39. data/lib/flapjack/gateways/web/views/_foot.html.erb +3 -0
  40. data/lib/flapjack/gateways/web/views/_head.html.erb +4 -0
  41. data/lib/flapjack/gateways/web/views/_nav.html.erb +9 -0
  42. data/lib/flapjack/gateways/web/views/check.html.erb +204 -0
  43. data/lib/flapjack/gateways/web/views/checks.html.erb +77 -0
  44. data/lib/flapjack/gateways/web/views/contact.html.erb +114 -0
  45. data/lib/flapjack/gateways/web/views/contacts.html.erb +42 -0
  46. data/lib/flapjack/gateways/web/views/entities.html.erb +39 -0
  47. data/lib/flapjack/gateways/web/views/entity.html.erb +67 -0
  48. data/lib/flapjack/gateways/web/views/index.html.erb +27 -0
  49. data/lib/flapjack/gateways/web/views/self_stats.html.erb +97 -0
  50. data/lib/flapjack/logger.rb +71 -23
  51. data/lib/flapjack/notifier.rb +157 -0
  52. data/lib/flapjack/patches.rb +1 -41
  53. data/lib/flapjack/pikelet.rb +4 -2
  54. data/lib/flapjack/{executive.rb → processor.rb} +32 -145
  55. data/lib/flapjack/version.rb +1 -1
  56. data/spec/lib/flapjack/coordinator_spec.rb +134 -71
  57. data/spec/lib/flapjack/data/contact_spec.rb +1 -0
  58. data/spec/lib/flapjack/data/entity_check_spec.rb +146 -30
  59. data/spec/lib/flapjack/data/entity_spec.rb +4 -4
  60. data/spec/lib/flapjack/data/event_spec.rb +4 -4
  61. data/spec/lib/flapjack/data/message_spec.rb +2 -3
  62. data/spec/lib/flapjack/data/notification_spec.rb +13 -19
  63. data/spec/lib/flapjack/gateways/api/entity_methods_spec.rb +2 -2
  64. data/spec/lib/flapjack/gateways/jabber_spec.rb +34 -0
  65. data/spec/lib/flapjack/gateways/pagerduty_spec.rb +0 -2
  66. data/spec/lib/flapjack/gateways/web/views/{check.haml_spec.rb → check.html.erb_spec.rb} +2 -2
  67. data/spec/lib/flapjack/gateways/web/views/{contact.haml_spec.rb → contact.html.erb_spec.rb} +3 -3
  68. data/spec/lib/flapjack/gateways/web/views/index.html.erb_spec.rb +14 -0
  69. data/spec/lib/flapjack/gateways/web_spec.rb +20 -8
  70. data/spec/lib/flapjack/logger_spec.rb +30 -28
  71. data/spec/lib/flapjack/notifier_spec.rb +6 -0
  72. data/spec/lib/flapjack/pikelet_spec.rb +8 -8
  73. data/spec/lib/flapjack/{executive_spec.rb → processor_spec.rb} +4 -4
  74. data/spec/spec_helper.rb +1 -13
  75. data/spec/support/erb_view_helper.rb +23 -0
  76. data/tasks/profile.rake +1 -1
  77. data/tmp/acknowledge.rb +3 -1
  78. data/tmp/create_event_ok.rb +3 -1
  79. data/tmp/create_event_unknown.rb +3 -1
  80. data/tmp/create_events_failure.rb +3 -1
  81. data/tmp/create_events_ok.rb +3 -1
  82. data/tmp/create_events_ok_fail_ack_ok.rb +3 -1
  83. data/tmp/create_events_ok_failure.rb +3 -1
  84. data/tmp/create_events_ok_failure_ack.rb +3 -1
  85. data/tmp/test_json_post.rb +5 -3
  86. data/tmp/test_notification_rules_api.rb +5 -3
  87. metadata +32 -61
  88. data/lib/flapjack/gateways/web/views/_foot.haml +0 -8
  89. data/lib/flapjack/gateways/web/views/_head.haml +0 -10
  90. data/lib/flapjack/gateways/web/views/_nav.haml +0 -14
  91. data/lib/flapjack/gateways/web/views/check.haml +0 -191
  92. data/lib/flapjack/gateways/web/views/checks.haml +0 -49
  93. data/lib/flapjack/gateways/web/views/contact.haml +0 -85
  94. data/lib/flapjack/gateways/web/views/contacts.haml +0 -30
  95. data/lib/flapjack/gateways/web/views/entities.haml +0 -28
  96. data/lib/flapjack/gateways/web/views/entity.haml +0 -50
  97. data/lib/flapjack/gateways/web/views/index.haml +0 -32
  98. data/lib/flapjack/gateways/web/views/self_stats.haml +0 -70
  99. data/spec/lib/flapjack/gateways/web/views/index.haml_spec.rb +0 -13
  100. data/spec/support/haml_view_helper.rb +0 -15
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Flapjack Changelog
2
2
 
3
+ # 0.7.19 - 2013-07-17
4
+ - Feature: Removed log4r and YAJL dependencies gh-25 (@ali-graham)
5
+ - Feature: Made jabber entity status messages more verbose gh-245 (@ali-graham)
6
+ - Feature: Split executive pikelet into two parts (processor and notifier) gh-247 (@ali-graham)
7
+ - Feature: marking entities and entity_checks as disabled / inactive gh-104 (@jessereynolds)
8
+ - Feature: include check summary when listing checks (all, failing, and per entity) gh-255 (@jessereynolds)
9
+
3
10
  # 0.7.18 - 2013-07-05
4
11
  - Feature: delete currently active scheduled maintenance via api should truncate from Time.now gh-242 (@ali-graham)
5
12
 
data/bin/flapjack CHANGED
@@ -9,6 +9,9 @@ require 'dante'
9
9
  require 'optparse'
10
10
  require 'ostruct'
11
11
 
12
+ require 'oj'
13
+ Oj.default_options = { :indent => 0, :mode => :strict }
14
+
12
15
  require 'flapjack/configuration'
13
16
  require 'flapjack/version'
14
17
 
@@ -7,7 +7,10 @@ end
7
7
  require 'optparse'
8
8
  require 'ostruct'
9
9
  require 'redis'
10
- require 'yajl/json_gem'
10
+
11
+ require 'oj'
12
+ Oj.default_options = { :indent => 0, :mode => :strict }
13
+
11
14
  require 'dante'
12
15
 
13
16
  require 'flapjack/configuration'
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'yajl/json_gem'
3
+ require 'oj'
4
+ Oj.default_options = { :indent => 0, :mode => :strict }
4
5
 
5
6
  module Netsaint
6
7
  class Service
@@ -2,7 +2,10 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'ostruct'
5
- require 'yajl/json_gem'
5
+
6
+ require 'oj'
7
+ Oj.default_options = { :indent => 0, :mode => :strict }
8
+
6
9
  require 'redis'
7
10
 
8
11
  # add lib to the default include path
@@ -60,7 +63,7 @@ end
60
63
 
61
64
  case command
62
65
  when "import-contacts"
63
- contacts = JSON.parse(file)
66
+ contacts = Oj.load(file)
64
67
 
65
68
  if contacts && contacts.is_a?(Enumerable) && contacts.any? {|e| !e['id'].nil?}
66
69
  @persistence = Redis.new(redis_options)
@@ -75,7 +78,7 @@ when "import-contacts"
75
78
  end
76
79
 
77
80
  when "import-entities"
78
- entities = JSON.parse(file)
81
+ entities = Oj.load(file)
79
82
 
80
83
  if entities && entities.is_a?(Enumerable) && entities.any? {|e| !e['id'].nil?}
81
84
  @persistence = Redis.new(redis_options)
data/bin/receive-events CHANGED
@@ -7,7 +7,9 @@ end
7
7
  require 'optparse'
8
8
  require 'ostruct'
9
9
  require 'redis'
10
- require 'yajl/json_gem'
10
+
11
+ require 'oj'
12
+ Oj.default_options = { :indent => 0, :mode => :strict }
11
13
 
12
14
  require 'flapjack/configuration'
13
15
 
@@ -7,9 +7,10 @@ end
7
7
  require 'optparse'
8
8
  require 'ostruct'
9
9
  require 'redis'
10
- require 'yajl/json_gem'
11
10
  require 'eventmachine'
12
11
 
12
+ require 'json'
13
+
13
14
  require 'flapjack/configuration'
14
15
 
15
16
  def pike(message)
@@ -8,6 +8,26 @@ development:
8
8
  host: 127.0.0.1
9
9
  port: 6379
10
10
  db: 13
11
+ processor:
12
+ enabled: no
13
+ queue: events
14
+ notifier_queue: notifications
15
+ archive_events: true
16
+ events_archive_maxage: 10800
17
+ new_check_scheduled_maintenance_duration: 1 month
18
+ logger:
19
+ level: INFO
20
+ notifier:
21
+ enabled: no
22
+ queue: notifications
23
+ email_queue: email_notifications
24
+ sms_queue: sms_notifications
25
+ jabber_queue: jabber_notifications
26
+ pagerduty_queue: pagerduty_notifications
27
+ notification_log_file: log/notification.log
28
+ default_contact_timezone: Australia/Broken_Hill
29
+ logger:
30
+ level: INFO
11
31
  executive:
12
32
  enabled: yes
13
33
  email_queue: email_notifications
@@ -1,4 +1,4 @@
1
- @events
1
+ @events @processor
2
2
  Feature: events
3
3
  So people can be notified when things break and recover
4
4
  flapjack-executive must process events correctly
@@ -1,4 +1,4 @@
1
- @events
1
+ @events @processor
2
2
  Feature: events and check names
3
3
  Flapjack must handle weird characters in check names in events
4
4
 
@@ -1,4 +1,4 @@
1
- @notification_rules @resque
1
+ @notification_rules @resque @processor @notifier
2
2
  Feature: Notification rules on a per contact basis
3
3
 
4
4
  Background:
@@ -1,4 +1,4 @@
1
- @notifications
1
+ @notifications @processor @notifier
2
2
  Feature: notifications
3
3
  So people can be notified when things break and recover
4
4
  flapjack-notifier must send notifications correctly
@@ -2,9 +2,19 @@
2
2
 
3
3
  def drain_events
4
4
  loop do
5
- event = Flapjack::Data::Event.next(:block => false, :redis => @redis)
5
+ event = Flapjack::Data::Event.next('events', :block => false, :redis => @redis)
6
6
  break unless event
7
- @app.send(:process_event, event)
7
+ @processor.send(:process_event, event)
8
+ end
9
+ drain_notifications
10
+ end
11
+
12
+ def drain_notifications
13
+ return unless @notifier_redis
14
+ loop do
15
+ notification = Flapjack::Data::Notification.next('notifications', :block => false, :redis => @notifier_redis)
16
+ break unless notification
17
+ @notifier.send(:process_notification, notification)
8
18
  end
9
19
  end
10
20
 
@@ -15,7 +25,7 @@ end
15
25
  def set_scheduled_maintenance(entity, check, duration = 60*60*2)
16
26
  entity_check = Flapjack::Data::EntityCheck.for_entity_name(entity, check, :redis => @redis)
17
27
  t = Time.now.to_i
18
- entity_check.create_scheduled_maintenance(:start_time => t, :duration => duration, :summary => "upgrading everything")
28
+ entity_check.create_scheduled_maintenance(t, duration, :summary => "upgrading everything")
19
29
  @redis.setex("#{entity}:#{check}:scheduled_maintenance", duration, t)
20
30
  end
21
31
 
@@ -23,7 +33,7 @@ def remove_scheduled_maintenance(entity, check)
23
33
  entity_check = Flapjack::Data::EntityCheck.for_entity_name(entity, check, :redis => @redis)
24
34
  sm = entity_check.maintenances(nil, nil, :scheduled => true)
25
35
  sm.each do |m|
26
- entity_check.delete_scheduled_maintenance(:start_time => m[:start_time])
36
+ entity_check.end_scheduled_maintenance(m[:start_time])
27
37
  end
28
38
  end
29
39
 
@@ -255,16 +265,16 @@ end
255
265
  Then /^a notification should not be generated(?: for check '([\w\.\-]+)' on entity '([\w\.\-]+)')?$/ do |check, entity|
256
266
  check ||= @check
257
267
  entity ||= @entity
258
- message = @logger.messages.find_all {|m| m =~ /enerating notifications for event #{entity}:#{check}/ }.last
259
- found = message ? message.match(/Not generating notifications/) : false
268
+ message = @logger.messages.find_all {|m| m =~ /enerating notification for event #{entity}:#{check}/ }.last
269
+ found = message ? message.match(/Not generating notification/) : false
260
270
  found.should be_true
261
271
  end
262
272
 
263
273
  Then /^a notification should be generated(?: for check '([\w\.\-]+)' on entity '([\w\.\-]+)')?$/ do |check, entity|
264
274
  check ||= @check
265
275
  entity ||= @entity
266
- message = @logger.messages.find_all {|m| m =~ /enerating notifications for event #{entity}:#{check}/ }.last
267
- found = message ? message.match(/Generating notifications/) : false
276
+ message = @logger.messages.find_all {|m| m =~ /enerating notification for event #{entity}:#{check}/ }.last
277
+ found = message ? message.match(/Generating notification/) : false
268
278
  found.should be_true
269
279
  end
270
280
 
@@ -280,14 +290,12 @@ Then /^show me the (\w+ )*log$/ do |adjective|
280
290
  end
281
291
 
282
292
  # added for notification rules:
283
-
284
293
  Given /^the following entities exist:$/ do |entities|
285
294
  entities.hashes.each do |entity|
286
295
  contacts = entity['contacts'].split(',')
287
296
  contacts.map! do |contact|
288
297
  contact.strip
289
298
  end
290
- #puts "adding entity #{entity['name']} (#{entity['id']}) with contacts: [#{contacts.join(', ')}]"
291
299
  Flapjack::Data::Entity.add({'id' => entity['id'],
292
300
  'name' => entity['name'],
293
301
  'contacts' => contacts},
@@ -358,13 +366,6 @@ Then /^all alert dropping keys for user (\d+) should have expired$/ do |contact_
358
366
  @redis.keys("drop_alerts_for_contact:#{contact_id}*").should be_empty
359
367
  end
360
368
 
361
- # When /^the (\w*) alert block for user (\d*) for (?:the check|check '([\w\.\-]+)' for entity '([\w\.\-]+)') for state (.*) expires$/ do |media, contact, check, entity, state|
362
- # check = check ? check : @check
363
- # entity = entity ? entity : @entity
364
- # num_deleted = @redis.del("drop_alerts_for_contact:#{contact}:#{media}:#{entity}:#{check}:#{state}")
365
- # puts "Warning: no keys expired" unless num_deleted > 0
366
- # end
367
-
368
369
  Then /^(.*) email alert(?:s)? should be queued for (.*)$/ do |num_queued, address|
369
370
  check = check ? check : @check
370
371
  entity = entity ? entity : @entity
@@ -14,8 +14,7 @@ end
14
14
 
15
15
  Then /^I should see a valid JSON output$/ do
16
16
  lambda {
17
- parser = Yajl::Parser.new
18
- @data = parser.parse(@output)
17
+ @data = Oj.load(@output)
19
18
  }.should_not raise_error
20
19
  end
21
20
 
@@ -59,14 +59,27 @@ Given /^the user wants to receive SMS notifications for entity '([\w\.\-]+)' and
59
59
  :redis => @redis )
60
60
  end
61
61
 
62
+ # TODO create the notification object in redis, flag the relevant operation as
63
+ # only needing that part running, split up the before block that covers these
62
64
  When /^an event notification is generated for entity '([\w\.\-]+)'$/ do |entity|
63
65
  event = Flapjack::Data::Event.new('type' => 'service',
64
66
  'state' => 'critical',
65
67
  'summary' => '100% packet loss',
66
68
  'entity' => entity,
67
69
  'check' => 'ping')
70
+
71
+ notification_type = Flapjack::Data::Notification.type_for_event(event)
72
+
68
73
  entity_check = Flapjack::Data::EntityCheck.for_entity_name(entity, 'ping', :redis => @redis)
69
- @app.send(:generate_notification_messages, event, entity_check, Time.now.to_i)
74
+ max_notified_severity = entity_check.max_notified_severity_of_current_failure
75
+
76
+ severity = Flapjack::Data::Notification.severity_for_event(event, max_notified_severity)
77
+ last_state = entity_check.historical_state_before(event.time)
78
+
79
+ Flapjack::Data::Notification.add('notifications', event,
80
+ :type => notification_type, :severity => severity, :last_state => last_state,
81
+ :redis => @redis)
82
+ drain_notifications
70
83
  end
71
84
 
72
85
  Then /^an SMS notification for entity '([\w\.\-]+)' should be queued for the user$/ do |entity|
@@ -24,7 +24,8 @@ require 'pathname'
24
24
  require 'webmock/cucumber'
25
25
  WebMock.disable_net_connect!
26
26
 
27
- require 'flapjack/executive'
27
+ require 'flapjack/notifier'
28
+ require 'flapjack/processor'
28
29
  require 'flapjack/patches'
29
30
 
30
31
  require 'resque_spec'
@@ -124,20 +125,36 @@ end
124
125
 
125
126
  Before do
126
127
  @logger = MockLogger.new
127
- # Use a separate database whilst testing
128
- @app = Flapjack::Executive.new(:logger => @logger,
129
- :config => {'email_queue' => 'email_notifications',
130
- 'sms_queue' => 'sms_notifications',
131
- 'default_contact_timezone' => 'America/New_York'},
132
- :redis_config => redis_opts)
133
- @redis = @app.instance_variable_get('@redis')
134
128
  end
135
129
 
136
130
  After do
131
+ @logger.messages = []
132
+ end
133
+
134
+
135
+ Before('@processor') do
136
+ @processor = Flapjack::Processor.new(:logger => @logger,
137
+ :redis_config => redis_opts, :config => {})
138
+ @redis = @processor.instance_variable_get('@redis')
139
+ end
140
+
141
+ After('@processor') do
137
142
  @redis.flushdb
138
143
  @redis.quit
139
- # Reset the logged messages
140
- @logger.messages = []
144
+ end
145
+
146
+ Before('@notifier') do
147
+ @notifier = Flapjack::Notifier.new(:logger => @logger,
148
+ :redis_config => redis_opts,
149
+ :config => {'email_queue' => 'email_notifications',
150
+ 'sms_queue' => 'sms_notifications',
151
+ 'default_contact_timezone' => 'America/New_York'})
152
+ @notifier_redis = @notifier.instance_variable_get('@redis')
153
+ end
154
+
155
+ After('@notifier') do
156
+ @notifier_redis.flushdb
157
+ @notifier_redis.quit
141
158
  end
142
159
 
143
160
  Before('@resque') do
data/flapjack.gemspec CHANGED
@@ -18,8 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.version = Flapjack::VERSION
19
19
 
20
20
  gem.add_dependency 'dante'
21
- gem.add_dependency 'log4r'
22
- gem.add_dependency 'yajl-ruby'
21
+ gem.add_dependency 'oj'
23
22
  gem.add_dependency 'eventmachine', '~> 1.0.0'
24
23
  gem.add_dependency 'hiredis'
25
24
  gem.add_dependency 'em-synchrony', '~> 1.0.2'
@@ -29,7 +28,6 @@ Gem::Specification.new do |gem|
29
28
  gem.add_dependency 'resque', '~> 1.23.0'
30
29
  gem.add_dependency 'sinatra'
31
30
  gem.add_dependency 'rack-fiber_pool'
32
- gem.add_dependency 'haml'
33
31
  gem.add_dependency 'thin'
34
32
  gem.add_dependency 'mail'
35
33
  gem.add_dependency 'blather', '~> 0.8.3'
@@ -3,13 +3,14 @@
3
3
  require 'eventmachine'
4
4
  require 'em-synchrony'
5
5
 
6
+ require 'syslog'
7
+
6
8
  require 'flapjack/configuration'
7
9
  require 'flapjack/patches'
8
- require 'flapjack/executive'
9
10
  require 'flapjack/redis_pool'
10
11
 
12
+ require 'flapjack/logger'
11
13
  require 'flapjack/pikelet'
12
- require 'flapjack/executive'
13
14
 
14
15
  module Flapjack
15
16
 
@@ -20,18 +21,7 @@ module Flapjack
20
21
  @redis_options = config.for_redis
21
22
  @pikelets = []
22
23
 
23
- # TODO convert this to use flapjack-logger
24
- logger_name = "flapjack-coordinator"
25
- @logger = Log4r::Logger.new(logger_name)
26
-
27
- formatter = Log4r::PatternFormatter.new(:pattern => "%d [%l] :: #{logger_name} :: %m",
28
- :date_pattern => "%Y-%m-%dT%H:%M:%S%z")
29
-
30
- [Log4r::StdoutOutputter, Log4r::SyslogOutputter].each do |outp_klass|
31
- outp = outp_klass.new(logger_name)
32
- outp.formatter = formatter
33
- @logger.add(outp)
34
- end
24
+ @logger = Flapjack::Logger.new("flapjack-coordinator")
35
25
  end
36
26
 
37
27
  def start(options = {})
@@ -47,6 +37,7 @@ module Flapjack
47
37
  return if @stopping
48
38
  @stopping = true
49
39
  remove_pikelets(@pikelets, :shutdown => true)
40
+ # Syslog.close if Syslog.opened? # TODO revisit in threading branch
50
41
  end
51
42
 
52
43
  # NB: global config options (e.g. daemonize, pidfile,
@@ -173,13 +164,32 @@ module Flapjack
173
164
  end
174
165
 
175
166
  def pikelets(config_env)
176
- return {} unless config_env
177
- exec_cfg = config_env.has_key?('executive') && config_env['executive']['enabled'] ?
178
- {'executive' => config_env['executive']} :
179
- {}
180
- return exec_cfg unless config_env && config_env['gateways'] &&
167
+ config = {}
168
+ return config unless config_env
169
+
170
+ # backwards-compatible with config file for previous 'executive' pikelet
171
+ exec_cfg = nil
172
+ if config_env.has_key?('executive') && config_env['executive']['enabled']
173
+ exec_cfg = config_env['executive']
174
+ end
175
+ ['processor', 'notifier'].each do |k|
176
+ if exec_cfg
177
+ if config_env.has_key?(k)
178
+ # need to allow for new config fields to override old settings if both present
179
+ merged = exec_cfg.merge(config_env[k])
180
+ config.update(k => merged) if merged['enabled']
181
+ else
182
+ config.update(k => exec_cfg)
183
+ end
184
+ else
185
+ next unless (config_env.has_key?(k) && config_env[k]['enabled'])
186
+ config.update(k => config_env[k])
187
+ end
188
+ end
189
+
190
+ return config unless config_env && config_env['gateways'] &&
181
191
  !config_env['gateways'].nil?
182
- exec_cfg.merge( config_env['gateways'].select {|k, v|
192
+ config.merge( config_env['gateways'].select {|k, v|
183
193
  Flapjack::Pikelet.is_pikelet?(k) && v['enabled']
184
194
  } )
185
195
  end