From b5dc8a8b9d8c4ee21569fa5bf12946ecbca9bec3 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 30 Aug 2019 10:05:12 -0400 Subject: [PATCH] Add fanspeed to bmc config for SMM The D2 offers some fanspeed control. Expose this through extended bmc configuration. Change-Id: Ia744538f7d735f54aeaf0404add99c2dce15a1d9 --- pyghmi/ipmi/oem/lenovo/imm.py | 1 + pyghmi/ipmi/oem/lenovo/nextscale.py | 32 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 4889877a..125bb50d 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -818,6 +818,7 @@ class XCCClient(IMMClient): 'smm': { 'default': 'Disable', 'possible': ['Enable', 'Disable'], + 'help': 'Enables or disables the network of the D2 enclosure manager.', } } if enclosureinfo['data'][0] == '\x02': diff --git a/pyghmi/ipmi/oem/lenovo/nextscale.py b/pyghmi/ipmi/oem/lenovo/nextscale.py index 041795f4..44522d68 100644 --- a/pyghmi/ipmi/oem/lenovo/nextscale.py +++ b/pyghmi/ipmi/oem/lenovo/nextscale.py @@ -263,6 +263,15 @@ class SMMClient(object): 'password_lockout_period': 'passwordLockoutTimePeriod', } + fanmodes = { + 1: 'Capped_20%', + 2: 'Capped_25%', + 3: 'Capped_30%', + 4: 'Capped_45%', + 0: 'Normal', + 5: 'Boosted', + } + def get_bmc_configuration(self): settings = {} self.wc.request( @@ -276,6 +285,17 @@ class SMMClient(object): for rule in self.rulemap: settings[rule] = {'value': int( accountinfo.find(self.rulemap[rule]).text)} + rsp = self.ipmicmd.xraw_command(0x34, 3) + fanmode = self.fanmodes[ord(rsp['data'][0])] + settings['fanspeed'] = { + 'value': fanmode, 'default': 'Normal', + 'help': ('Adjust the fan speed of the D2 Chassis. Capped settings ' + 'will reduce fan speed for better acoustic experience at ' + 'the expense of performance. Normal is using the Lenovo ' + 'engineered cooling adjustments across the full range. ' + 'Boosted adds fanspeed to the Normal response to ' + 'provide more aggressive cooling.'), + 'possible': [self.fanmodes[x] for x in self.fanmodes]} return settings @@ -288,6 +308,18 @@ class SMMClient(object): if key.lower() in self.rulemap: rules.append('{0}:{1}'.format( self.rulemap[key.lower()], changeset[key]['value'])) + if key.lower() == 'fanspeed': + for mode in self.fanmodes: + byteval = mode + mode = self.fanmodes[mode] + if changeset[key]['value'].lower() == mode.lower(): + self.ipmicmd.xraw_command( + 0x32, 0x9b, data=[byteval]) + break + else: + raise pygexc.InvalidParameterValue( + '{0} not a valid mode for fanspeed'.format( + changeset[key]['value'])) if rules: rules = 'set={0}'.format(','.join(rules)) self.wc.request('POST', '/data', rules)