Filter out DPU from systems collection if ambiguous

DPUs may manifest in a Systems collection.

If the caller does not specify sysurl, they are almost certainly wanting
to manage the 'main' system,
not an adapter.

Provide for this expectation by
retrying the collection with DPU
filtered out,
so that if there's exactly one non-DPU
system, then it will still be functional.

Change-Id: I300c47245111121440ae0f037d202b074407c45d
This commit is contained in:
Jarrod Johnson 2023-10-02 08:58:24 -04:00
parent 8ac115a8a7
commit 3c5b03c35f
1 changed files with 4 additions and 2 deletions

View File

@ -194,13 +194,15 @@ class Command(object):
systems = members['Members']
if sysurl:
for system in systems:
if system['@odata.id'] == sysurl:
self.sysurl = sysurl
if system['@odata.id'] == sysurl or system['@odata.id'].split('/')[-1] == sysurl:
self.sysurl = system['@odata.id']
break
else:
raise exc.PyghmiException(
'Specified sysurl not found: {0}'.format(sysurl))
else:
if len(systems) != 1:
systems = [x for x in systems if 'DPU' not in x['@odata.id']]
if len(systems) != 1:
raise exc.PyghmiException(
'Multi system manager, sysurl is required parameter')