mirror of
https://opendev.org/x/pyghmi
synced 2025-04-14 01:02:36 +00:00
FRU data may return 0x81 on not-present devices and also provide some rough event description in the case of an unknown OEM SEL format. Change-Id: Ia99c4981c06ed8e067a584896fde3880f08f8baa
74 lines
3.0 KiB
Python
74 lines
3.0 KiB
Python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright 2015 Lenovo
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import pyghmi.ipmi.oem.generic as generic
|
|
import pyghmi.ipmi.private.util as util
|
|
|
|
|
|
class OEMHandler(generic.OEMHandler):
|
|
# noinspection PyUnusedLocal
|
|
def __init__(self, oemid, ipmicmd):
|
|
# will need to retain data to differentiate
|
|
# variations. For example System X versus Thinkserver
|
|
self.oemid = oemid
|
|
|
|
def process_event(self, event):
|
|
if 'oemdata' in event:
|
|
event['event'] = 'OEM event: {0}'.format(repr(event['oemdata']))
|
|
return
|
|
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] & 0b11111)
|
|
|
|
def process_fru(self, fru):
|
|
if fru is None:
|
|
return fru
|
|
if (self.oemid['manufacturer_id'] == 19046 and
|
|
self.oemid['device_id'] == 32):
|
|
fru['oem_parser'] = 'lenovo'
|
|
# Thinkserver lays out specific interpretation of the
|
|
# board extra fields
|
|
_, _, wwn1, wwn2, mac1, mac2 = fru['board_extra']
|
|
if wwn1 not in ('0000000000000000', ''):
|
|
fru['WWN 1'] = wwn1
|
|
if wwn2 not in ('0000000000000000', ''):
|
|
fru['WWN 2'] = wwn2
|
|
if mac1 not in ('00:00:00:00:00:00', ''):
|
|
fru['MAC Address 1'] = mac1
|
|
if mac2 not in ('00:00:00:00:00:00', ''):
|
|
fru['MAC Address 2'] = mac2
|
|
try:
|
|
# The product_extra field is UUID as the system would present
|
|
# in DMI. This is different than the two UUIDs that
|
|
# it returns for get device and get system uuid...
|
|
byteguid = fru['product_extra'][0]
|
|
# It can present itself as claiming to be ASCII when it
|
|
# is actually raw hex. As a result it triggers the mechanism
|
|
# to strip \x00 from the end of text strings. Work around this
|
|
# by padding with \x00 to the right if the string is not 16 long
|
|
byteguid.extend('\x00' * (16 - len(byteguid)))
|
|
fru['UUID'] = util.decode_wireformat_uuid(byteguid)
|
|
except (AttributeError, KeyError):
|
|
pass
|
|
return fru
|
|
else:
|
|
fru['oem_parser'] = None
|
|
return fru
|