Skip to content

feat: per-machine BMC vendor override#2912

Open
s3rj1k wants to merge 1 commit into
NVIDIA:mainfrom
s3rj1k:feat/machine-bmc-vendor-override
Open

feat: per-machine BMC vendor override#2912
s3rj1k wants to merge 1 commit into
NVIDIA:mainfrom
s3rj1k:feat/machine-bmc-vendor-override

Conversation

@s3rj1k

@s3rj1k s3rj1k commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Pin a Redfish BMC vendor per machine, forced into libredfish instead of auto-detection. The value is a plain string matched against libredfish's RedfishVendor enum at client creation (an unknown name warns and falls back), so NICo keeps no vendor list. It rides on BmcAccessInfo so every client_by_info caller honors it, plus the direct instance-power and force-delete paths.

  • db: machines.bmc_vendor_override column + migration
  • api: UpdateMachineBmcVendorOverride RPC, field on Machine
  • redfish: client_by_info forces the override
  • cli: machine vendor-override set/clear/show

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

@s3rj1k s3rj1k requested a review from a team as a code owner June 26, 2026 10:49
@copy-pr-bot

copy-pr-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Pin a Redfish BMC vendor per machine, forced into libredfish instead of
auto-detection. The value is a plain string matched against libredfish's
RedfishVendor enum at client creation (an unknown name warns and falls back),
so NICo keeps no vendor list. It rides on BmcAccessInfo so every
client_by_info caller honors it, plus the direct instance-power and
force-delete paths.

- db: machines.bmc_vendor_override column + migration
- api: UpdateMachineBmcVendorOverride RPC, field on Machine
- redfish: client_by_info forces the override
- cli: machine vendor-override set/clear/show

Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
@s3rj1k s3rj1k force-pushed the feat/machine-bmc-vendor-override branch from d38e985 to 04c592a Compare June 26, 2026 10:49
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features

    • Added a new machine vendor override command with options to set, clear, and view the Redfish BMC vendor used for a machine.
    • Machine records now remember an optional vendor override so the chosen Redfish vendor can be pinned per machine.
  • Bug Fixes

    • Redfish client selection now respects the saved vendor override during machine operations, improving consistency when automatic detection is not desired.
  • Documentation

    • Added command reference pages and updated the machine command index to include the new vendor override workflow.

Walkthrough

Adds a machine-level Redfish BMC vendor override through the RPC, database, Redfish client, and admin CLI paths. The override can now be set, cleared, shown, and passed into Redfish client creation during power and BIOS-unlock flows.

Changes

Vendor override flow

Layer / File(s) Summary
Contract and shared model
crates/rpc/proto/forge.proto, crates/api-model/src/machine/*, crates/rpc/src/model/machine/mod.rs, crates/utils/src/redfish.rs
Adds bmc_vendor_override to the Forge machine RPC, the API machine model, snapshot JSON conversion, RPC conversion, and BmcAccessInfo.
Update RPC and storage
crates/api-db/migrations/20260625120000_machine_bmc_vendor_override.sql, crates/admin-cli/src/rpc.rs, crates/api-core/src/api.rs, crates/api-core/src/handlers/machine.rs, crates/api-db/src/machine.rs
Adds the machine update RPC handler, database update helper, schema column, and CLI client wrapper for setting or clearing the override.
Redfish vendor resolution
crates/api-db/src/machine_interface.rs, crates/redfish/src/libredfish/conv.rs, crates/redfish/src/libredfish/mod.rs, crates/api-core/src/handlers/instance.rs, crates/api-core/src/handlers/machine.rs
Returns bmc_vendor_override from BMC access lookup, parses override values into RedfishVendor, and passes the computed vendor into Redfish client creation in instance and machine flows.
Admin CLI command and docs
crates/admin-cli/src/machine/mod.rs, crates/admin-cli/src/machine/vendor_override/*, docs/manuals/nico-admin-cli/commands/machine/machine-vendor-override*.md, docs/manuals/nico-admin-cli/commands/machine/machine.md
Adds the machine vendor-override subcommand with set, clear, and show handlers and adds the matching manual pages and command index entry.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as Cmd::vendor_override
  participant Client as ApiClient::update_machine_bmc_vendor_override
  participant Api as Api::update_machine_bmc_vendor_override
  participant Handler as machine::update_machine_bmc_vendor_override
  participant DB as db::machine::update_bmc_vendor_override
  participant Tables as machines

  CLI->>Client: machine_id, bmc_vendor_override
  Client->>Api: UpdateMachineBmcVendorOverride request
  Api->>Handler: Request<MachineBmcVendorOverrideUpdateRequest>
  Handler->>DB: normalized override, machine_id
  DB->>Tables: UPDATE bmc_vendor_override
  Tables-->>DB: ok
  DB-->>Handler: ok
  Handler-->>Api: Response<()>
  Api-->>Client: success
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.94% 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: adding a per-machine BMC vendor override.
Description check ✅ Passed The description accurately describes the change set and matches the implementation scope.
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.

@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: 2

🤖 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/admin-cli/src/machine/vendor_override/args.rs`:
- Around line 43-47: The `vendor` argument on `VendorOverrideArgs` currently
accepts any string and only fails back to auto-detection later, so invalid
values slip through parse time. Update the `clap` field in `VendorOverrideArgs`
to validate against the exact `RedfishVendor` variant names (case-sensitive) by
using a `ValueEnum` or a custom parser/validator. Ensure `--vendor` is rejected
immediately for typos and only the supported vendor names are accepted.

In `@crates/api-core/src/handlers/machine.rs`:
- Around line 325-333: Validate the incoming bmc_vendor_override in
machine::update before calling db::machine::update_bmc_vendor_override: reject
any non-empty value that redfish_vendor_from_str does not accept and return
NicoError::InvalidArgument instead of persisting it. Keep the existing
empty/absent handling, but only pass through vendor names that map to a known
Redfish vendor so typos cannot be stored and later silently ignored when the
client is built.
🪄 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: 97cbfb50-bbec-4b40-8551-a3ed7fcd7472

📥 Commits

Reviewing files that changed from the base of the PR and between 52a0a54 and 04c592a.

📒 Files selected for processing (23)
  • crates/admin-cli/src/machine/mod.rs
  • crates/admin-cli/src/machine/vendor_override/args.rs
  • crates/admin-cli/src/machine/vendor_override/cmd.rs
  • crates/admin-cli/src/machine/vendor_override/mod.rs
  • crates/admin-cli/src/rpc.rs
  • crates/api-core/src/api.rs
  • crates/api-core/src/handlers/instance.rs
  • crates/api-core/src/handlers/machine.rs
  • crates/api-db/migrations/20260625120000_machine_bmc_vendor_override.sql
  • crates/api-db/src/machine.rs
  • crates/api-db/src/machine_interface.rs
  • crates/api-model/src/machine/json.rs
  • crates/api-model/src/machine/mod.rs
  • crates/redfish/src/libredfish/conv.rs
  • crates/redfish/src/libredfish/mod.rs
  • crates/rpc/proto/forge.proto
  • crates/rpc/src/model/machine/mod.rs
  • crates/utils/src/redfish.rs
  • docs/manuals/nico-admin-cli/commands/machine/machine-vendor-override-clear.md
  • docs/manuals/nico-admin-cli/commands/machine/machine-vendor-override-set.md
  • docs/manuals/nico-admin-cli/commands/machine/machine-vendor-override-show.md
  • docs/manuals/nico-admin-cli/commands/machine/machine-vendor-override.md
  • docs/manuals/nico-admin-cli/commands/machine/machine.md

Comment thread crates/admin-cli/src/machine/vendor_override/args.rs
Comment thread crates/api-core/src/handlers/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