Skip to content

chore(admin-cli): Implement detailed switch show#1814

Open
inf0rmatiker wants to merge 4 commits into
NVIDIA:mainfrom
inf0rmatiker:chore/1782_switch-show-output
Open

chore(admin-cli): Implement detailed switch show#1814
inf0rmatiker wants to merge 4 commits into
NVIDIA:mainfrom
inf0rmatiker:chore/1782_switch-show-output

Conversation

@inf0rmatiker
Copy link
Copy Markdown
Contributor

Description

This change fully implements both the list view (all switches) and the single-switch detail view, bringing it to parity with the existing machine show command.

Additionally: Moves switch ID to Switch details section for managed-switch show <id>.

Output format of switch show <id> before:

+-------------------------------------------------------------+--------------+-------------------------------------------------------------+------+------+---------+-------------+--------+---------------------+---------------------------------------------------------------------------+
| ID                                                          | Name         | Metadata Name                                               | Slot | Tray | Primary | Power State | Health | FabricManager(nmxc) | State                                                                     |
+=============================================================+==============+=============================================================+======+======+=========+=============+========+=====================+===========================================================================+
| sw100nskfd0k9in3fnt4va16ppqcjnupl6k4cp13io9r0c1l4uhr0045beg | MT2519600UD9 | sw100nskfd0k9in3fnt4va16ppqcjnupl6k4cp13io9r0c1l4uhr0045beg | 10   | 5    | No      | N/A         | N/A    | not_running         | {"state":"reprovisioning","reprovisioning_state":"WaitingForNVOSUpgrade"} |
+-------------------------------------------------------------+--------------+-------------------------------------------------------------+------+------+---------+-------------+--------+---------------------+---------------------------------------------------------------------------+

Output format after:

ID            : sw100ns3dce61l6ibclidaa3mtd7sp2n9d0afqdb137an3mjg0dpjkn9hd0
Rack ID       : ipp6-gb200-36x1
State Version : V12-T1778873105787903
Version       : V1-T1778792629597329
Primary       : No
Slot Number   : 7
Tray Index    : 2
Deleted At    : N/A

Config:
	Name       : MT2519600UD8
	Enable NMX-C : false

Status:
	Switch Name      : N/A
	Power State      : N/A
	Health Status    : N/A
	Controller State : {"state":"reprovisioning","reprovisioning_state":"WaitingForNVOSUpgrade"}
	Fabric Manager   : not_running
	Lifecycle:
		State   : {"STATE":"REPROVISIONING","REPROVISIONING_STATE":"WAITINGFORNVOSUPGRADE"}
		Version : V12-T1778873105787903
		Reason  : The object is in the state for longer than defined by the SLA. Handler outcome: Wait("waiting for current rack NVOS cycle")
		SLA Breached: true
	Fabric Manager Status:
		State  : 3
	Health Sources:
		mode=0 source=hardware-health.bmc-leak-detectors
		mode=0 source=hardware-health.bmc-sensors

BMC:
	None
METADATA:
	NAME: sw100ns3dce61l6ibclidaa3mtd7sp2n9d0afqdb137an3mjg0dpjkn9hd0
	DESCRIPTION:
	LABELS:

This roughly follows the structure of the gRPC Switch message - note that rearranging much more than this makes it a maintenance nightmare when the gRPC message undergoes changes.

For context, this is the output format of machine show <id>:

ID                  : fm100ht5ldjmk2g8d4reoopaqu3ec4gtp6n6ds02tdjvfpt23bbr88loj40
RACK_ID             : ipp6-gb200-36x1
STATE               : READY
STATE_VERSION       : V33-T1779132554336406
MACHINE TYPE        : Host
FAILURE             : None
VERSION             : V1-T1779037261562339
SKU                 :
SKU DEVICE TYPE     :
SLOT NUMBER         : 16
TRAY INDEX          : 6
VENDOR              : NVIDIA
PRODUCT NAME        : GB200 NVL
PRODUCT SERIAL      : 183XXXXXXXXXX
BOARD SERIAL        : 1322325035033
CHASSIS SERIAL      : 1932725000836
BIOS VERSION        : 02.04.14
BOARD VERSION       : AE.1
FIRMWARE AUTOUPDATE : Default
METADATA:
	NAME: fm100ht5ldjmk2g8d4reoopaqu3ec4gtp6n6ds02tdjvfpt23bbr88loj40
	DESCRIPTION:
	LABELS:
...

We want to move away from the ALL CAPS key/value representation for the "nice" human-readable text format - no need to scream at the user - but that's outside the scope of this PR.

Changes by file:

switch/show/args.rs:

  • Replace the untyped identifier: Option<String> field with a typed switch_id: Option<SwitchId>, matching the machine show pattern and enabling parse-time validation of the switch ID format.

switch/show/cmd.rs:

  • Add to_table to convert a SwitchList into a prettytable Table (columns: ID, Name, Metadata Name, Slot, Tray, Primary, Power State, Health, FabricManager(nmxc), State).
  • Add show_switches to fetch all switches with pagination, sort by primary ID or state, and render as ASCII table or CSV.
  • Add show_switch_information to fetch a single switch by ID and render it in the requested format.
  • Add switch_details_text to produce a human-readable key-value representation of all Switch RPC fields (config, status/lifecycle, fabric manager details, health sources, BMC info, metadata).
  • Rewrite handle_show to dispatch to the appropriate function and remove dead commented-out code.
  • Add a switch_details_text_smoke async unit test that constructs a representative Switch and prints the formatted output to stdout.

switch/show/mod.rs:

  • Thread page_size and sort_by through to handle_show, matching the signature expected by the new implementation.

switch/tests.rs:

  • Update parse_show_no_args and parse_show_with_identifier to reference the new switch_id field instead of identifier.

rpc/src/admin_cli.rs:

  • Add CarbideCliError::SwitchNotFound(SwitchId) variant.
  • Add OutputFormat::unimplemented_output_format_err() helper to reduce boilerplate at call sites.

managed_switch/show/cmd.rs:

  • Move the Switch ID from a standalone header line into the key-value data table so it is formatted consistently with other fields.

machine/show/cmd.rs:

  • Use output_format.unimplemented_output_format_err() for the YAML case instead of an inline CarbideCliError::NotImplemented.

async_write.rs / dpu/{status,versions}/cmd.rs:

  • Fix fully-qualified path for CarbideCliError in the async_write_table_as_csv! macro and remove unused imports.

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)

Closes #1782

Breaking Changes

  • This PR contains breaking changes

These changes only affects the CLI. Existing tooling built around expected CLI output formats may break.

  1. Users of the switch show command will no longer be allowed to input an empty string for the switch ID to display all switches. Instead, they must omit the arg altogether. This arg must be a valid switch ID - it will be immediately parsed and validated into a SwitchId so invalid formats will fail.
  2. The switch ID in the managed-switch show command has been moved into the core Switch: body, instead of the header. This is to maintain parity with the output format of managed-host show.
  3. switch show <id> no longer prints an ASCII table row, in the same format as switch show. Instead, it prints a more detailed ASCII text output similar to how machine show <id> does it.

All other changes are added functionality and do not change existing formats.

Testing

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

Manual CLI Tests

Switch ID format is validated - no longer allowing any String value:

colossus@forge-rack-manager-ipp6-2:~/cacarlson$ carbide-admin-cli sw show my-switch
error: invalid value 'my-switch' for '[SWITCH_ID]': The Switch ID has an invalid length of 9

colossus@forge-rack-manager-ipp6-2:~/cacarlson$ carbide-admin-cli sw show ""
error: invalid value '' for '[SWITCH_ID]': The Switch ID has an invalid length of 0

Omitting switch_id positional argument retains same behavior of listing all switches:

colossus@forge-rack-manager-ipp6-2:~/cacarlson$ carbide-admin-cli sw show
+-------------------------------------------------------------+--------------+-------------------------------------------------------------+------+------+---------+-------------+--------+---------------------+---------------------------------------------------------------------------+
| ID                                                          | Name         | Metadata Name                                               | Slot | Tray | Primary | Power State | Health | FabricManager(nmxc) | State                                                                     |
+=============================================================+==============+=============================================================+======+======+=========+=============+========+=====================+===========================================================================+
| sw100ns3dce61l6ibclidaa3mtd7sp2n9d0afqdb137an3mjg0dpjkn9hd0 | MT2519600UD8 | sw100ns3dce61l6ibclidaa3mtd7sp2n9d0afqdb137an3mjg0dpjkn9hd0 | 7    | 2    | No      | N/A         | N/A    | not_running         | {"state":"reprovisioning","reprovisioning_state":"WaitingForNVOSUpgrade"} |
+-------------------------------------------------------------+--------------+-------------------------------------------------------------+------+------+---------+-------------+--------+---------------------+---------------------------------------------------------------------------+
...

Additional Notes

N/A.

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 19, 2026

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.

@inf0rmatiker inf0rmatiker force-pushed the chore/1782_switch-show-output branch from a2fa186 to aa9771e Compare May 19, 2026 17:44
@inf0rmatiker inf0rmatiker marked this pull request as ready for review May 19, 2026 17:48
@inf0rmatiker inf0rmatiker requested a review from a team as a code owner May 19, 2026 17:48
@inf0rmatiker inf0rmatiker added admin tools Issue related to admin tools (CLI/UI) rack lifecycle Issues that relate to managing the lifecycle of a full rack (compute, switches and powershelves) labels May 19, 2026
@Matthias247
Copy link
Copy Markdown
Contributor

looks good to me. But would be nice to also get the JSON output working. It should usually be the most simple thing, because we only have to call serde_json::to_string() on the gRPC response.

@inf0rmatiker inf0rmatiker force-pushed the chore/1782_switch-show-output branch from db995e0 to d0adee8 Compare May 20, 2026 18:43
The `switch show` command previously had a stub implementation that did
not compile. This change fully implements both the list view (all
switches) and the single-switch detail view, bringing it to parity with
the existing `machine show` command.

Additionally: Move switch ID to Switch details section

Changes by file:

`switch/show/args.rs`:
- Replace the untyped `identifier: Option<String>` field with a typed
  `switch_id: Option<SwitchId>`, matching the machine show pattern and
  enabling parse-time validation of the switch ID format.

`switch/show/cmd.rs`:
- Add `to_table` to convert a `SwitchList` into a prettytable `Table`
  (columns: ID, Name, Metadata Name, Slot, Tray, Primary, Power State,
  Health, FabricManager(nmxc), State).
- Add `show_switches` to fetch all switches with pagination, sort by
  primary ID or state, and render as ASCII table or CSV.
- Add `show_switch_information` to fetch a single switch by ID and
  render it in the requested format.
- Add `switch_details_text` to produce a human-readable key-value
  representation of all Switch RPC fields (config, status/lifecycle,
  fabric manager details, health sources, BMC info, metadata).
- Rewrite `handle_show` to dispatch to the appropriate function and
  remove dead commented-out code.
- Add a `switch_details_text_smoke` async unit test that constructs a
  representative Switch and prints the formatted output to stdout.

`switch/show/mod.rs`:
- Thread `page_size` and `sort_by` through to `handle_show`, matching
  the signature expected by the new implementation.

`switch/tests.rs`:
- Update `parse_show_no_args` and `parse_show_with_identifier` to
  reference the new `switch_id` field instead of `identifier`.

`rpc/src/admin_cli.rs`:
- Add `CarbideCliError::SwitchNotFound(SwitchId)` variant.
- Add `OutputFormat::unimplemented_output_format_err()` helper to
  reduce boilerplate at call sites.

`managed_switch/show/cmd.rs`:
- Move the Switch ID from a standalone header line into the key-value
  data table so it is formatted consistently with other fields.

`machine/show/cmd.rs`:
- Use `output_format.unimplemented_output_format_err()` for the YAML
  case instead of an inline `CarbideCliError::NotImplemented`.

`async_write.rs` / `dpu/{status,versions}/cmd.rs`:
- Fix fully-qualified path for `CarbideCliError` in the
  `async_write_table_as_csv!` macro and remove unused imports.

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

Labels

admin tools Issue related to admin tools (CLI/UI) rack lifecycle Issues that relate to managing the lifecycle of a full rack (compute, switches and powershelves)

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

feat: CLI 'switch show' and 'machine show' need detail level parity

2 participants