From 86845c4e2bd8ad1ad115d5fbdd826c919e0b6fc7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 3 Mar 2021 15:12:31 -0500 Subject: [PATCH] Add reseat to redfish command for XCC This will allow XCC users doing redfish to reseat using the HTTPS api. Change-Id: Ib0582f4aafb20cd94972f2080df673fbd3abbab3 --- pyghmi/redfish/command.py | 11 +++++++++++ pyghmi/redfish/oem/generic.py | 4 ++++ pyghmi/redfish/oem/lenovo/xcc.py | 10 ++++++++++ 3 files changed, 25 insertions(+) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 6801720c..36489ec7 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -527,6 +527,17 @@ class Command(object): currinfo = self._do_web_request(self.sysurl, cache=False) return {'powerstate': str(currinfo['PowerState'].lower())} + def reseat_bay(self, bay): + """Request the reseat of a bay + + Request the enclosure manager to reseat the system in a particular + bay. + + :param bay: The bay identifier to reseat + :return: + """ + self.oem.reseat_bay(bay) + def set_power(self, powerstate, wait=False): if powerstate == 'boot': oldpowerstate = self.get_power()['powerstate'] diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index cbfacd5d..8a3ab72d 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -398,3 +398,7 @@ class OEMHandler(object): def get_user_expiration(self, uid): return None + + def reseat_bay(self, bay): + raise exc.UnsupportedFunctionality( + 'Bay reseat not supported on this platform') diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 19be1e8d..c82b565e 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -95,6 +95,16 @@ class OEMHandler(generic.OEMHandler): self.updating = False self.datacache = {} + def reseat_bay(self, bay): + if bay != -1: + raise pygexc.UnsupportedFunctionality( + 'This is not an enclosure manager') + rsp = self.wc.grab_json_response_with_status( + '/api/providers/virt_reseat', '{}') + if rsp[1] != 200 or rsp[0].get('return', 1) != 0: + raise pygexc.UnsupportedFunctionality( + 'This platform does not support AC reseat.') + def get_cached_data(self, attribute, age=30): try: kv = self.datacache[attribute]