2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-15 12:17:44 +00:00

Add OEM event fixup

Provide a facility for OEM plugins to modify events on the way
out of the event handling functions.

Change-Id: I24f31f7035dcba2c1f30810a6282c87ee987ddad
This commit is contained in:
Jarrod Johnson 2015-05-14 14:52:20 -04:00
parent 911762f0c5
commit 01980e40e9
4 changed files with 32 additions and 2 deletions

View File

@ -421,7 +421,8 @@ class Command(object):
:param clear: Whether to remove the SEL entries from the target BMC
"""
return sel.EventHandler(self.init_sdr()).fetch_sel(self, clear)
self.oem_init()
return sel.EventHandler(self.init_sdr(), self).fetch_sel(self, clear)
def get_inventory_descriptions(self):
"""Retrieve list of things that could be inventoried

View File

@ -367,8 +367,9 @@ class EventHandler(object):
:param sdr: An SDR object (per pyghmi.ipmi.sdr) matching the target BMC SDR
"""
def __init__(self, sdr):
def __init__(self, sdr, ipmicmd):
self._sdr = sdr
self._ipmicmd = ipmicmd
def _decode_standard_event(self, eventdata, event):
# Ignore the generator id for now..
@ -386,12 +387,14 @@ class EventHandler(object):
event['component'] = 'Sensor {0}'.format(eventdata[4])
event['deassertion'] = (eventdata[5] & 0b10000000 == 0b10000000)
event_data = eventdata[6:]
event['event_data_bytes'] = event_data
event_type = eventdata[5] & 0b1111111
byte2type = (event_data[0] & 0b11000000) >> 6
byte3type = (event_data[0] & 0b110000) >> 4
if byte2type == 1:
event['triggered_value'] = event_data[1]
evtoffset = event_data[0] & 0b1111
event['event_type_byte'] = event_type
if event_type <= 0xc:
event['component_type_id'] = sensor_type
event['event_id'] = '{0}.{1}'.format(event_type, evtoffset)
@ -449,6 +452,9 @@ class EventHandler(object):
# In this class of OEM message, all bytes are OEM, interpretation
# is wholly left up to the OEM layer, using the OEM ID of the BMC
event['oemdata'] = selentry[3:]
self._ipmicmd._oem.process_event(event)
del event['event_type_byte']
del event['event_data_bytes']
return event
def _fetch_entries(self, ipmicmd, startat, targetlist, rsvid=0):

View File

@ -27,6 +27,20 @@ class OEMHandler(object):
def __init__(self, oemid, ipmicmd):
pass
def process_event(self, event):
"""Modify an event according with OEM understanding.
Given an event, allow an OEM module to augment it. For example,
event data fields can have OEM bytes. Other times an OEM may wish
to apply some transform to some field to suit their conventions.
"""
event['oem_handler'] = None
evdata = event['event_data_bytes']
if evdata[0] & 0b11000000 == 0b10000000:
event['oem_byte2'] = evdata[1]
if evdata[0] & 0b110000 == 0b100000:
event['oem_byte3'] = evdata[2]
def process_fru(self, fru):
"""Modify a fru entry with OEM understanding.

View File

@ -25,6 +25,15 @@ class OEMHandler(generic.OEMHandler):
# variations. For example System X versus Thinkserver
self.oemid = oemid
def process_event(self, event):
evdata = event['event_data_bytes']
# For HDD bay events, the event data 2 is the bay, modify
# the description to be more specific
if (event['event_type_byte'] == 0x6f and
(evdata[0] & 0b11000000) == 0b10000000 and
event['component_type_id'] == 13):
event['component'] += ' {0}'.format(evdata[1])
def process_fru(self, fru):
if fru is None:
return fru