Skip to content

feat(machine-a-tron): register expected switches and power shelves#2320

Open
poroh wants to merge 1 commit into
NVIDIA:mainfrom
poroh:mat-expected-switch-and-powershelf
Open

feat(machine-a-tron): register expected switches and power shelves#2320
poroh wants to merge 1 commit into
NVIDIA:mainfrom
poroh:mat-expected-switch-and-powershelf

Conversation

@poroh

@poroh poroh commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

Register LiteOn power shelves and NVIDIA switches as their expected inventory types instead of expected machines. Preserve switch NVOS MAC/serial data across persistence and adjust mock BMC handling for BMC-only hardware.

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Related Issues (Optional)

#1864

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Additional Notes

Register LiteOn power shelves and NVIDIA switches as their expected
inventory types instead of expected machines. Preserve switch NVOS
MAC/serial data across persistence and adjust mock BMC handling for
BMC-only hardware.

Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0cf87ede-c50e-4129-919b-e143c8bd1b51

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@poroh poroh marked this pull request as ready for review June 9, 2026 03:03
@poroh poroh requested a review from a team as a code owner June 9, 2026 03:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
crates/machine-a-tron/src/machine_a_tron.rs (1)

114-130: ⚡ Quick win

Consider documenting the serial number fallback behavior.

The switch registration falls back to host_info.serial when switch_serial_number is absent (lines 119-122). While this fallback is reasonable, the implicit behavior may not be obvious to future maintainers or when debugging inventory mismatches.

📝 Add a comment documenting the fallback
                     HostHardwareType::NvidiaSwitchNd5200Ld => {
                         self.app_context
                             .api_client()
                             .add_expected_switch(
                                 host_info.bmc_mac_address.to_string(),
+                                // Fall back to host serial if switch-specific serial is unavailable
                                 host_info
                                     .switch_serial_number
                                     .clone()
                                     .unwrap_or_else(|| host_info.serial.clone()),
                                 host_info
                                     .nvos_mac_addresses
                                     .iter()
                                     .map(|mac| mac.to_string())
                                     .collect(),
                             )
                             .await
                     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/machine-a-tron/src/machine_a_tron.rs` around lines 114 - 130, Document
that when registering switches for HostHardwareType::NvidiaSwitchNd5200Ld the
call to app_context.api_client().add_expected_switch uses
host_info.switch_serial_number and falls back to host_info.serial if
switch_serial_number is None; add a concise inline comment above that block (or
adjacent to the .unwrap_or_else call) stating the fallback rationale and any
assumptions (e.g., host serial represents switch serial when explicit
switch_serial_number is missing) and note any implications for inventory
matching/debugging.
crates/machine-a-tron/src/api_client.rs (1)

564-589: Keep bmc_retain_credentials differing for power shelf vs switch (it matches mock + rotation semantics)

bmc_retain_credentials is used by site-explorer to skip BMC password rotation and persist the current credentials as-is. The BMC-mock permits factory-default password access only for LiteOnPowerShelf; factory-default credentials are forbidden for other hosts (including NvidiaSwitchNd5200Ld). That’s why add_expected_power_shelf sets bmc_retain_credentials: Some(true) while add_expected_switch leaves it as None (so the switch path rotates/falls back instead of persisting credentials that the BMC won’t accept).

Optional: add a short comment near these two constructor blocks in crates/machine-a-tron/src/api_client.rs explaining the coupling between bmc_retain_credentials, mock factory-default permission, and the rotation skip behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/machine-a-tron/src/api_client.rs` around lines 564 - 589, The
add_expected_switch constructor must leave bmc_retain_credentials as None (so
switches follow rotation/fallback) while add_expected_power_shelf must set
bmc_retain_credentials: Some(true) (so LiteOnPowerShelf retains factory creds);
update these two constructors in api_client.rs (functions/methods
add_expected_switch and add_expected_power_shelf) to ensure those exact values
and add a short comment near each constructor explaining the coupling between
bmc_retain_credentials, the BMC mock’s factory-default permission, and the
credential-rotation/skip behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/machine-a-tron/src/api_client.rs`:
- Around line 564-589: The add_expected_switch constructor must leave
bmc_retain_credentials as None (so switches follow rotation/fallback) while
add_expected_power_shelf must set bmc_retain_credentials: Some(true) (so
LiteOnPowerShelf retains factory creds); update these two constructors in
api_client.rs (functions/methods add_expected_switch and
add_expected_power_shelf) to ensure those exact values and add a short comment
near each constructor explaining the coupling between bmc_retain_credentials,
the BMC mock’s factory-default permission, and the credential-rotation/skip
behavior.

In `@crates/machine-a-tron/src/machine_a_tron.rs`:
- Around line 114-130: Document that when registering switches for
HostHardwareType::NvidiaSwitchNd5200Ld the call to
app_context.api_client().add_expected_switch uses host_info.switch_serial_number
and falls back to host_info.serial if switch_serial_number is None; add a
concise inline comment above that block (or adjacent to the .unwrap_or_else
call) stating the fallback rationale and any assumptions (e.g., host serial
represents switch serial when explicit switch_serial_number is missing) and note
any implications for inventory matching/debugging.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: c22ddcb1-4acb-4c38-9384-9a6fb7369e2f

📥 Commits

Reviewing files that changed from the base of the PR and between 50141a3 and e8b013f.

📒 Files selected for processing (8)
  • crates/bmc-mock/src/auth_router.rs
  • crates/bmc-mock/src/machine_info.rs
  • crates/bmc-mock/src/mock_machine_router.rs
  • crates/machine-a-tron/src/api_client.rs
  • crates/machine-a-tron/src/config.rs
  • crates/machine-a-tron/src/host_machine.rs
  • crates/machine-a-tron/src/machine_a_tron.rs
  • crates/machine-a-tron/src/machine_state_machine.rs

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.

1 participant