2
0
mirror of https://opendev.org/x/pyghmi synced 2026-01-10 02:02:30 +00:00

Add recognition of AMI convention of 'Self'

Recognize that in an ambiguous situation, that AMI considers 'Self' to
be 'the' primary element of systems and managers collections.

Change-Id: Ia33fb2b8da357c08b3cf5ce1e5a8550846215a06
This commit is contained in:
Jarrod Johnson
2025-12-02 14:04:49 -05:00
parent 9a2edebea5
commit d5ce67d08a
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
# Copyright 2025 Lenovo Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pyghmi.redfish.oem.generic as generic
def get_handler(sysinfo, sysurl, webclient, cache, cmd, rootinfo={}):
if not sysinfo:
systems, status = webclient.grab_json_response_with_status('/redfish/v1/Systems')
if status == 200:
for system in systems.get('Members', []):
if system.get('@odata.id', '').endswith('/Self'):
sysurl = system['@odata.id']
sysinfo, status = webclient.grab_json_response_with_status(sysurl)
break
return generic.OEMHandler(sysinfo, sysurl, webclient, cache,
gpool=cmd._gpool)

View File

@@ -15,10 +15,12 @@
import pyghmi.redfish.oem.dell.main as dell
import pyghmi.redfish.oem.generic as generic
import pyghmi.redfish.oem.lenovo.main as lenovo
import pyghmi.redfish.oem.ami.main as ami
OEMMAP = {
'Lenovo': lenovo,
'Dell': dell,
'AMI': ami,
}