From 964224e3068cb40573feb16762dbd92bb3d5760f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 8 Feb 2021 11:04:38 -0500 Subject: [PATCH] Port fast media list from XCC IPMI plugin The redfish support may be unacceptably slow for media list. Add an accelerator for that function in the redfish oem extension as well. Change-Id: I066e4e469b6b2a3d534e79cdc8bd061a12b10af0 --- pyghmi/redfish/oem/lenovo/xcc.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pyghmi/redfish/oem/lenovo/xcc.py b/pyghmi/redfish/oem/lenovo/xcc.py index a88ecef4..3631b086 100644 --- a/pyghmi/redfish/oem/lenovo/xcc.py +++ b/pyghmi/redfish/oem/lenovo/xcc.py @@ -24,6 +24,7 @@ import time import pyghmi.exceptions as pygexc import pyghmi.ipmi.private.util as util +import pyghmi.media as media import pyghmi.redfish.oem.generic as generic import pyghmi.storage as storage from pyghmi.util.parse import parse_time @@ -556,6 +557,23 @@ class OEMHandler(generic.OEMHandler): wc.set_header('X-XSRF-TOKEN', wc.cookies['_csrf_token']) return wc + def list_media(self, fishclient): + rt = self.wc.grab_json_response('/api/providers/rp_vm_remote_getdisk') + if 'items' in rt: + for mt in rt['items']: + url = mt['remotepath'] + if url.startswith('//'): + url = 'smb:' + url + elif (not url.startswith('http://') + and not url.startswith('https://')): + url = url.replace(':', '') + url = 'nfs://' + url + yield media.Media(mt['filename'], url) + rt = self.wc.grab_json_response('/api/providers/rp_rdoc_imagelist') + if 'items' in rt: + for mt in rt['items']: + yield media.Media(mt['filename']) + def attach_remote_media(self, url, user, password, vmurls): for vmurl in vmurls: if 'EXT' not in vmurl: