Skip to content

fix: add support to bmc-explorer for Delta powershelves#3455

Merged
spydaNVIDIA merged 2 commits into
NVIDIA:mainfrom
spydaNVIDIA:bmc-mock-delta
Jul 14, 2026
Merged

fix: add support to bmc-explorer for Delta powershelves#3455
spydaNVIDIA merged 2 commits into
NVIDIA:mainfrom
spydaNVIDIA:bmc-mock-delta

Conversation

@spydaNVIDIA

Copy link
Copy Markdown
Contributor

fix: add support to bmc-explorer for Delta powershelves

Related issues

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.)

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

@spydaNVIDIA spydaNVIDIA requested a review from poroh July 13, 2026 22:18
@spydaNVIDIA spydaNVIDIA requested a review from a team as a code owner July 13, 2026 22:18
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features
    • Added support for discovering and identifying Delta power shelves.
    • Reports synthesized system details when Delta shelves do not expose standard computer-system data.
    • Aggregates individual PSU power states into an overall shelf status.
    • Supports Delta shelf registration and configuration in mock environments.
  • Bug Fixes
    • Prevents exploration failures when Delta shelves omit the standard systems endpoint.
    • Avoids unnecessary PCIe and system discovery requests for Delta shelves.
  • Tests
    • Added coverage for all-on, all-off, mixed, and unknown PSU power states.

Walkthrough

Adds Delta power shelf support across mock Redfish services, chassis exploration, synthesized system reports, hardware classification, PSU power-state aggregation, integration tests, and expected inventory registration.

Changes

Delta power shelf support

Layer / File(s) Summary
Delta contracts and hardware types
Cargo.toml, crates/bmc-explorer/Cargo.toml, crates/bmc-explorer/src/hw/mod.rs, crates/bmc-mock/src/lib.rs, crates/bmc-mock/src/redfish/oem/mod.rs
Updates the Redfish dependency and introduces Delta hardware and vendor classifications.
Delta Redfish hardware model
crates/bmc-mock/src/hw/delta_power_shelf.rs, crates/bmc-mock/src/hw/mod.rs, crates/bmc-mock/src/redfish/power_supply.rs
Models Delta managers, chassis, power supplies, OEM PSU state, and update services.
Systems-less mock routing
crates/bmc-mock/src/bmc_state.rs, crates/bmc-mock/src/machine_info.rs, crates/bmc-mock/src/mock_machine_router.rs, crates/bmc-mock/src/redfish/*, crates/bmc-mock/src/test_support/mod.rs, crates/machine-a-tron/src/host_machine.rs
Propagates Delta configuration through mock state and returns no Systems collection for Delta shelves.
Delta chassis exploration and reporting
crates/bmc-explorer/src/chassis.rs, crates/bmc-explorer/src/hw/mod.rs, crates/bmc-explorer/src/lib.rs
Reads and aggregates Delta PSU states, synthesizes a ComputerSystem, classifies Delta shelves, and builds their exploration reports.
Integration validation and registration
crates/bmc-explorer/tests/integration/powershelf_explore.rs, crates/machine-a-tron/src/machine_a_tron.rs
Tests on, off, and mixed PSU states and routes Delta shelves through expected power-shelf registration.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DeltaPowerShelfBmc
  participant ChassisExplorer
  participant ExplorationReporter
  participant SiteExplorer
  DeltaPowerShelfBmc->>ChassisExplorer: expose chassis and Delta PSU OEM states
  ChassisExplorer->>ChassisExplorer: aggregate PSU states
  ChassisExplorer->>ExplorationReporter: classify DeltaPowerShelf
  ExplorationReporter->>SiteExplorer: build synthesized ComputerSystem report
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.95% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: Delta powershelf support in bmc-explorer.
Description check ✅ Passed The description is related to the changeset and matches the Delta powershelf support work.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@github-actions

Copy link
Copy Markdown

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/bmc-explorer/src/chassis.rs (1)

489-505: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consolidate the power-shelf aggregation with the Lite-On path.

powershelf_power_state reproduces the exact on/off/unknown collapse already implemented by LiteOnSuppliesState::to_model (chassis.rs:520-535). Two copies of the same rule invite divergence over time. Consider having the Lite-On path delegate to this generic helper (both operate on Option<bool> per-supply flags), keeping a single source of truth for shelf-state aggregation.

As per coding guidelines: "Duplicate code (copy/paste, similar logic, abstractions)."

🤖 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/bmc-explorer/src/chassis.rs` around lines 489 - 505, Consolidate the
duplicated power-state aggregation by updating LiteOnSuppliesState::to_model to
delegate its per-supply Option<bool> flags to powershelf_power_state. Preserve
the existing On, Off, and Unknown behavior while making powershelf_power_state
the single implementation of the collapse rule.
🤖 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.

Inline comments:
In `@crates/bmc-mock/src/machine_info.rs`:
- Around line 825-833: Update delta_power_shelf to validate
delta_psu_power.len() against DEFAULT_PSU_POWER.len() before constructing the
DeltaPowerShelf or its PSU Cow, rejecting empty, short, and oversized vectors so
only the documented six-bay shape is produced; ensure the public helper path
also fails early through this validation.

---

Nitpick comments:
In `@crates/bmc-explorer/src/chassis.rs`:
- Around line 489-505: Consolidate the duplicated power-state aggregation by
updating LiteOnSuppliesState::to_model to delegate its per-supply Option<bool>
flags to powershelf_power_state. Preserve the existing On, Off, and Unknown
behavior while making powershelf_power_state the single implementation of the
collapse rule.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fe2f9b5c-21d0-42d3-a80b-e0edff8fb079

📥 Commits

Reviewing files that changed from the base of the PR and between f70eada and 350133b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • Cargo.toml
  • crates/bmc-explorer/Cargo.toml
  • crates/bmc-explorer/src/chassis.rs
  • crates/bmc-explorer/src/hw/mod.rs
  • crates/bmc-explorer/src/lib.rs
  • crates/bmc-explorer/tests/integration/powershelf_explore.rs
  • crates/bmc-mock/src/bmc_state.rs
  • crates/bmc-mock/src/hw/delta_power_shelf.rs
  • crates/bmc-mock/src/hw/mod.rs
  • crates/bmc-mock/src/lib.rs
  • crates/bmc-mock/src/machine_info.rs
  • crates/bmc-mock/src/mock_machine_router.rs
  • crates/bmc-mock/src/redfish/computer_system.rs
  • crates/bmc-mock/src/redfish/oem/mod.rs
  • crates/bmc-mock/src/redfish/power_supply.rs
  • crates/bmc-mock/src/redfish/service_root.rs
  • crates/bmc-mock/src/test_support/mod.rs
  • crates/machine-a-tron/src/host_machine.rs
  • crates/machine-a-tron/src/machine_a_tron.rs

Comment on lines +825 to +833
fn delta_power_shelf(&self) -> hw::delta_power_shelf::DeltaPowerShelf<'_> {
hw::delta_power_shelf::DeltaPowerShelf {
bmc_mac_address: self.bmc_mac_address,
product_serial_number: Cow::Borrowed(&self.serial),
psu_power: self.delta_psu_power.as_deref().map_or(
Cow::Borrowed(hw::delta_power_shelf::DEFAULT_PSU_POWER),
Cow::Borrowed,
),
}

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Enforce the documented Delta PSU cardinality.

Because delta_psu_power is a public Vec<bool>, this code currently creates one PowerSupplyUnit per arbitrary entry. Empty, short, or oversized vectors therefore produce a mock that is not the documented six-bay Delta shelf and can let exploration tests exercise an invalid resource shape. Validate the length against DEFAULT_PSU_POWER.len() before constructing the Cow (the public helper should then fail early as well).

Proposed fix
 fn delta_power_shelf(&self) -> hw::delta_power_shelf::DeltaPowerShelf<'_> {
+    let default_psu_power: &[bool] = hw::delta_power_shelf::DEFAULT_PSU_POWER;
+    let psu_power = self
+        .delta_psu_power
+        .as_deref()
+        .unwrap_or(default_psu_power);
+    assert_eq!(
+        psu_power.len(),
+        default_psu_power.len(),
+        "Delta power shelf PSU state count must match the default shelf",
+    );
+
     hw::delta_power_shelf::DeltaPowerShelf {
         bmc_mac_address: self.bmc_mac_address,
         product_serial_number: Cow::Borrowed(&self.serial),
-        psu_power: self.delta_psu_power.as_deref().map_or(
-            Cow::Borrowed(hw::delta_power_shelf::DEFAULT_PSU_POWER),
-            Cow::Borrowed,
-        ),
+        psu_power: Cow::Borrowed(psu_power),
     }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fn delta_power_shelf(&self) -> hw::delta_power_shelf::DeltaPowerShelf<'_> {
hw::delta_power_shelf::DeltaPowerShelf {
bmc_mac_address: self.bmc_mac_address,
product_serial_number: Cow::Borrowed(&self.serial),
psu_power: self.delta_psu_power.as_deref().map_or(
Cow::Borrowed(hw::delta_power_shelf::DEFAULT_PSU_POWER),
Cow::Borrowed,
),
}
fn delta_power_shelf(&self) -> hw::delta_power_shelf::DeltaPowerShelf<'_> {
let default_psu_power: &[bool] = hw::delta_power_shelf::DEFAULT_PSU_POWER;
let psu_power = self
.delta_psu_power
.as_deref()
.unwrap_or(default_psu_power);
assert_eq!(
psu_power.len(),
default_psu_power.len(),
"Delta power shelf PSU state count must match the default shelf",
);
hw::delta_power_shelf::DeltaPowerShelf {
bmc_mac_address: self.bmc_mac_address,
product_serial_number: Cow::Borrowed(&self.serial),
psu_power: Cow::Borrowed(psu_power),
}
}
🤖 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/bmc-mock/src/machine_info.rs` around lines 825 - 833, Update
delta_power_shelf to validate delta_psu_power.len() against
DEFAULT_PSU_POWER.len() before constructing the DeltaPowerShelf or its PSU Cow,
rejecting empty, short, and oversized vectors so only the documented six-bay
shape is produced; ensure the public helper path also fails early through this
validation.

@github-actions

Copy link
Copy Markdown

🔍 Container Scan Summary

Service Total Critical High Medium Low Other
boot-artifacts-aarch64 3 0 0 3 0 0
boot-artifacts-x86_64 3 0 0 3 0 0
forge-admin-cli-x86_64 255 13 30 79 7 126
machine-validation-runner 800 40 234 292 36 198
machine_validation 800 40 234 292 36 198
machine_validation-aarch64 800 40 234 292 36 198
nvmetal-carbide 800 40 234 292 36 198
TOTAL 3461 173 966 1253 151 918

Per-CVE detail lives in the per-service grype-* artifacts (JSON + SARIF). Severity counts only — no CVE IDs published here.

@spydaNVIDIA spydaNVIDIA merged commit 21a6430 into NVIDIA:main Jul 14, 2026
60 checks passed
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.

3 participants