Skip to content

[Mellanox] Centralize BMC init gate in initialize_bmc()#2

Open
william8545 wants to merge 1 commit into
masterfrom
mellanox-centralize-bmc-init-gate
Open

[Mellanox] Centralize BMC init gate in initialize_bmc()#2
william8545 wants to merge 1 commit into
masterfrom
mellanox-centralize-bmc-init-gate

Conversation

@william8545

Copy link
Copy Markdown
Owner

Why I did it

The is_platform_with_bmc() gate was only in initialize_components(), but get_bmc()_initialize_bmc() calls initialize_bmc() directly, bypassing that gate. As a result, on non-BMC platforms the get_bmc() path still imports the bmc module and probes for a BMC. This is a cleanup; the externally observable behavior does not change.

Work item tracking
  • Microsoft ADO (number only):

How I did it

Moved the is_platform_with_bmc() check into initialize_bmc() itself (early return that leaves _bmc as None) and dropped the now-redundant gate in initialize_components(). All callers — get_bmc(), get_num_components(), get_all_components() — now go through one authoritative gate, so non-BMC platforms never import the bmc module. The chassis unit test is updated to match.

How to verify it

Run the chassis unit test:
pytest platform/mellanox/mlnx-platform-api/tests/test_chassis.py -k test_initialize_components_bmc

On a non-BMC Mellanox platform, config bmc and show platform still report the BMC as unavailable; on a BMC platform the behavior is unchanged.

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511
  • 202605

Tested branch (Please provide the tested image version)

Description for the changelog

[Mellanox] Centralize the BMC initialization gate in initialize_bmc()

Link to config_db schema for YANG module changes

N/A - no config_db or YANG model changes.

A picture of a cute animal (not mandatory but encouraged)

🦦

The is_platform_with_bmc() gate lived in initialize_components(), but
get_bmc() -> _initialize_bmc() also calls initialize_bmc() directly,
bypassing it. Move the gate into initialize_bmc() so every caller goes
through a single check and non-BMC platforms skip importing the bmc
module. No behavior change: get_bmc() still returns None on non-BMC.

Signed-off-by: William Tsai <willtsai@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants