From 5f63810884079e0dc80d77e151d6fa4414d4b614 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 20 May 2022 07:29:02 -0400 Subject: [PATCH] Allow virtualmedia on Systems instead of Managers Redfish now allows a system to opt to place virtual media on system rather than manager. The rational being that remote media has to be mapped to specific hosts, and the manager relationship to that media can be implicit. Try the system first (more specific) then fallback to traditional manager location for virtualmedia. Change-Id: I5d63b5e57572c6a753a2d86adb223335a15a71ea --- pyghmi/redfish/command.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pyghmi/redfish/command.py b/pyghmi/redfish/command.py index da168a97..15a8bf82 100644 --- a/pyghmi/redfish/command.py +++ b/pyghmi/redfish/command.py @@ -1485,9 +1485,12 @@ class Command(object): # identify the correct resource ahead of time. # As such it's OEM specific until the standard # provides a better way. - bmcinfo = self._do_web_request(self._bmcurl) - vmcoll = bmcinfo.get('VirtualMedia', {}).get('@odata.id', None) - vmurls = None + vmurls = [] + vmcoll = self.sysinfo.get( + 'VirtualMedia', {}).get('@odata.id', None) + if not vmcoll: + vmcoll = self.bmcinfo.get( + 'VirtualMedia', {}).get('@odata.id', None) if vmcoll: vmlist = self._do_web_request(vmcoll) vmurls = [x['@odata.id'] for x in vmlist.get('Members', [])] @@ -1517,12 +1520,14 @@ class Command(object): break def detach_remote_media(self): - bmcinfo = self._do_web_request(self._bmcurl) - vmcoll = bmcinfo.get('VirtualMedia', {}).get('@odata.id', None) try: self.oem.detach_remote_media() except exc.BypassGenericBehavior: return + vmcoll = self.sysinfo.get('VirtualMedia', {}).get('@odata.id', None) + if not vmcoll: + bmcinfo = self._do_web_request(self._bmcurl) + vmcoll = bmcinfo.get('VirtualMedia', {}).get('@odata.id', None) if vmcoll: vmlist = self._do_web_request(vmcoll) vmurls = [x['@odata.id'] for x in vmlist.get('Members', [])]