[BMC] Align get_presence for the new infra#685
Conversation
Signed-off-by: Ben Levi <belevi@nvidia.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@judyjoseph Can you please help to merge? |
yxieca
left a comment
There was a problem hiding this comment.
Reviewed by AI agent on behalf of Ying.
Decision: Approve — clean, well-tested alignment change. CI green, zero regression on non-BMC platforms (old and new both return False there); the change is confined to Switch-Host/Switch-BMC platforms as intended. Two non-blocking suggestions:
-
Docstring (please consider updating):
get_presence()is an abstract-base method that platform implementations inherit, and its behavior changed, but the docstring still reads only "Check if the BMC device is present." Suggest documenting the new contract so it's the spec vendors rely on, e.g.:Returns
Trueonly on the Switch-Host side (is_switch_host()) when runtime BMC data (/etc/sonic/bmc.json) is available; returnsFalseon the Switch-BMC side or when BMC data is absent. -
Presence condition semantics: the old check required the
bmc_addrkey specifically (bmc_data.get('bmc_addr')); the newget_bmc_data()is truthy for any non-emptybmc.jsondict. So abmc.jsonpresent but missingbmc_addrwould now report present on a Switch-Host (previouslyFalse). In practiceget_bmc_data()returns a fully-populated dict, so this is inert — but if the intended invariant is specifically "a BMC address is known,"device_info.get_bmc_address()would preserve the stricter check. Otherwise, the docstring note in (1) documents "bmc.json present on host" as the intended signal. A test for thebmc_addr-less dict case would also lock in whichever semantic you choose.
Neither blocks merge.
Description
sonic_platform_base/bmc_base.pyto check:device_info.is_switch_host()device_info.get_bmc_data()bmc_addr-only presence condition.tests/bmc_base_test.pyto match the new behavior:Motivation and Context
BMCBase.get_presence()was aligned with the new host/BMC split (sonic-net/sonic-buildimage#26544)so BMC presence is reported only for Switch-Host platforms with runtime BMC data.
This avoids treating Switch-BMC side execution as BMC-present for host-only logic.
How Has This Been Tested?
pytest tests/bmc_base_test.pybmc.get_presence()returnsTrueonly on Switch-Host with valid/etc/sonic/bmc.jsonFalseon Switch-BMC side or when BMC data is unavailableAdditional Information (Optional)