From 3fcc1d362e934ac1d06f973a13458bcbcd73ad06 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 11 Feb 2022 10:50:08 -0500 Subject: [PATCH] Add capping to the Lenovo dense servers Change-Id: I321a2eed0df49bfc1337af93961425b7f4cd0229 --- pyghmi/ipmi/oem/lenovo/nextscale.py | 91 ++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/pyghmi/ipmi/oem/lenovo/nextscale.py b/pyghmi/ipmi/oem/lenovo/nextscale.py index a84144cf..726798bd 100644 --- a/pyghmi/ipmi/oem/lenovo/nextscale.py +++ b/pyghmi/ipmi/oem/lenovo/nextscale.py @@ -483,6 +483,66 @@ class SMMClient(object): 'delivery is at the sustained capacity of the remaining ' 'supplies.') } + try: + numbays = 12 + try: + chassiscapinfo = self.ipmicmd.xraw_command( + 0x32, 0x9d, data=[13]) + except pygexc.IpmiException as e: + if e.ipmicode == 201: # this must be a 2U + numbays = 4 + chassiscapinfo = self.ipmicmd.xraw_command( + 0x32, 0x9d, data=[5]) + else: + raise + retoffset = 0 + if len(chassiscapinfo['data']) > 10: + retoffset = 1 + chassiscapstate = self.ipmicmd.xraw_command( + 0x32, 0xa0, data=[numbays + 1]) + capstate = bool(chassiscapstate['data'][retoffset]) + capmin, capmax, protcap, usercap, thermcap = struct.unpack( + '