Class: Bosh::Director::DeploymentPlan::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/deployment_plan/notifier.rb

Defined Under Namespace

Modules: Severity

Instance Method Summary collapse

Constructor Details

#initialize(name, nats_rpc, logger) ⇒ Notifier

Returns a new instance of Notifier.



11
12
13
14
15
# File 'lib/bosh/director/deployment_plan/notifier.rb', line 11

def initialize(name, nats_rpc, logger)
  @name = name
  @logger = logger
  @nats_rpc = nats_rpc
end

Instance Method Details

#send_end_eventObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/bosh/director/deployment_plan/notifier.rb', line 31

def send_end_event
  payload = {
    'id' => SecureRandom.uuid,
    'severity' => Severity::WARNING,
    'source' => 'director',
    'title' => 'director - finish update deployment',
    'summary' => "Finish update deployment for '#{@name}' against Director '#{Bosh::Director::Config.uuid}'",
    'created_at' => Time.now.to_i
  }

  @logger.info('sending update deployment end event')
  @nats_rpc.send_message('hm.director.alert', payload)
end

#send_error_event(exception) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/bosh/director/deployment_plan/notifier.rb', line 45

def send_error_event(exception)
  payload = {
    'id' => SecureRandom.uuid,
    'severity' => Severity::ERROR,
    'source' => 'director',
    'title' => 'director - error during update deployment',
    'summary' => "Error during update deployment for '#{@name}' against Director '#{Bosh::Director::Config.uuid}': #{exception.inspect}",
    'created_at' => Time.now.to_i
  }

  @logger.info('sending update deployment error event')
  @nats_rpc.send_message('hm.director.alert', payload)
end

#send_start_eventObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bosh/director/deployment_plan/notifier.rb', line 17

def send_start_event
  payload = {
    'id' => SecureRandom.uuid,
    'severity' => Severity::WARNING,
    'source' => 'director',
    'title' => 'director - begin update deployment',
    'summary' => "Begin update deployment for '#{@name}' against Director '#{Bosh::Director::Config.uuid}'",
    'created_at' => Time.now.to_i
  }

  @logger.info('sending update deployment start event')
  @nats_rpc.send_message('hm.director.alert', payload)
end