From 14652e8d8422aaca1719f2550a6fa17ba8410b8c Mon Sep 17 00:00:00 2001 From: Vlad Spoiala Date: Tue, 21 Feb 2023 18:10:05 +0200 Subject: [PATCH] Add check_storage_configuration to Redfish code. Change-Id: Id604fdeb19e4dd571f6bad4e9b29276dc7001587 --- pyghmi/redfish/command.py | 10 ++++++++++ pyghmi/redfish/oem/generic.py | 4 ++++ pyghmi/redfish/oem/lenovo/xcc.py | 13 +++++++++++++ 3 files changed, 27 insertions(+) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index 740857bc..25cab8e9 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -1268,6 +1268,16 @@ class Command(object): """ return self.oem.apply_storage_configuration(cfgspec) + def check_storage_configuration(self, cfgspec=None): + """Evaluate a configuration for validity + + This will check if configuration is currently available and, if given, + whether the specified cfgspec can be applied. + :param cfgspec: A pyghmi.storage.ConfigSpec describing desired oonfig + :return: + """ + return self._oem.check_storage_configuration(cfgspec) + def attach_remote_media(self, url, username=None, password=None): """Attach remote media by url diff --git a/pyghmi/redfish/oem/generic.py b/pyghmi/redfish/oem/generic.py index 9f46550c..1462a5ea 100644 --- a/pyghmi/redfish/oem/generic.py +++ b/pyghmi/redfish/oem/generic.py @@ -672,6 +672,10 @@ class OEMHandler(object): raise exc.UnsupportedFunctionality( 'Remote storage configuration not supported on this platform') + def check_storage_configuration(self, cfgspec): + raise exc.UnsupportedFunctionality( + 'Remote storage configuration not supported on this platform') + def upload_media(self, filename, progress=None, data=None): raise exc.UnsupportedFunctionality( 'Remote media upload not supported on this platform') diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index 3e0b0d86..7c61772b 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -725,6 +725,19 @@ class OEMHandler(generic.OEMHandler): themap[raidname] = mapdata return themap + def check_storage_configuration(self, cfgspec=None): + rsp = self.wc.grab_json_response( + '/api/function/raid_conf?params=raidlink_GetStatus') + if rsp['items'][0]['status'] not in (2, 3): + raise pygexc.TemporaryError('Storage configuration unavailable in ' + 'current state (try boot to setup or ' + 'an OS)') + if not cfgspec: + return True + for pool in cfgspec.arrays: + self._parse_storage_cfgspec(pool) + return True + def _wait_storage_async(self): rsp = {'items': [{'status': 0}]} while rsp['items'][0]['status'] == 0: