Module: RSMP::SiteProxy::Modules::Alarms

Included in:
RSMP::SiteProxy
Defined in:
lib/rsmp/proxy/site/modules/alarms.rb

Overview

Handles alarm messages

Instance Method Summary collapse

Instance Method Details

#process_alarm(message) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 6

def process_alarm(message)
  component = find_component message.attribute('cId')
  status = %w[ack aS sS].map { |key| message.attribute(key) }.join(',')
  component.handle_alarm message
  alarm_code = message.attribute('aCId')
  asp = message.attribute('aSp')
  log "Received #{message.type}, #{alarm_code} #{asp} [#{status}]", message: message, level: :log
  acknowledge message
end

#resume_alarm(c_id:, a_c_id:, collect: false) ⇒ Object

Send an AlarmResume message and optionally collect the confirming response. Returns Result when collecting and Result otherwise.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 61

def resume_alarm(c_id:, a_c_id:, collect: false)
  message = RSMP::AlarmResume.new(
    'mId' => RSMP::Message.make_m_id,
    'cId' => c_id,
    'aCId' => a_c_id
  )
  if collect
    collector = RSMP::AlarmCollector.new(
      self,
      m_id: message.m_id,
      num: 1,
      matcher: {
        'cId' => c_id,
        'aCId' => a_c_id,
        'aSp' => 'Suspend',
        'sS' => /^notSuspended/i
      },
      timeout: node.supervisor_settings.dig('default', 'timeouts', 'alarm')
    )
    send_message_and_collect(message, collector)
  else
    send_message(message).map(&:message)
  end
end

#resume_alarm!Object



86
87
88
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 86

def resume_alarm!(...)
  resume_alarm(...).value!
end

#send_alarm_acknowledgement(component, alarm_code, options = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 16

def send_alarm_acknowledgement(component, alarm_code, options = {})
  message = RSMP::AlarmAcknowledged.new({
                                          'cId' => component,
                                          'aCId' => alarm_code
                                        })
  send_message(message, validate: options[:validate]).map(&:message)
end

#send_alarm_acknowledgement!Object



24
25
26
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 24

def send_alarm_acknowledgement!(...)
  send_alarm_acknowledgement(...).value!
end

#suspend_alarm(c_id:, a_c_id:, collect: false) ⇒ Object

Send an AlarmSuspend message and optionally collect the confirming response. Returns Result when collecting and Result otherwise.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 30

def suspend_alarm(c_id:, a_c_id:, collect: false)
  message = RSMP::AlarmSuspend.new(
    'mId' => RSMP::Message.make_m_id,
    'cId' => c_id,
    'aCId' => a_c_id
  )
  if collect
    collector = RSMP::AlarmCollector.new(
      self,
      m_id: message.m_id,
      num: 1,
      matcher: {
        'cId' => c_id,
        'aCId' => a_c_id,
        'aSp' => 'Suspend',
        'sS' => /^Suspended/i
      },
      timeout: node.supervisor_settings.dig('default', 'timeouts', 'alarm')
    )
    send_message_and_collect(message, collector)
  else
    send_message(message).map(&:message)
  end
end

#suspend_alarm!Object



55
56
57
# File 'lib/rsmp/proxy/site/modules/alarms.rb', line 55

def suspend_alarm!(...)
  suspend_alarm(...).value!
end