Skip to content

feat(ironic): add a cisco_nxos hardware type for Nexus switches - #2825

Merged
cardoe merged 2 commits into
mainfrom
cisco-nxos-driver
Nov 30, 2026
Merged

cardoe merged 2 commits into
mainfrom
cisco-nxos-driver

Conversation

@cardoe

@cardoe cardoe commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Adds a cisco_nxos Ironic hardware type for Cisco Nexus switches. It's a netdev with inspect and firmware interfaces that read the switch over NX-API (JSON-RPC over HTTPS, feature nxapi). Both interfaces only run show commands and never change the switch.

Commits

  1. refactor(ironic): share firmware component syncing between drivers. Moves the code that stores reported versions as firmware components out of panos_firmware into utils/firmware_components.sync(). Behaviour is unchanged.
  2. feat(ironic): add a cisco_nxos hardware type for Nexus switches.

Inspect

  • Creates a baremetal port named <node>:<EthernetX/Y> for each physical Ethernet interface, carrying the interface's burned-in MAC. A server's LLDP data from its iDRAC can then be matched to switch ports.
  • Never deletes ports. A port whose MAC or name is already taken is logged and skipped, so it doesn't fail inspection.
  • Records the switch MAC from show vdc detail as properties['chassis_mac']. NX-OS sends each interface's MAC as the LLDP chassis ID by default, and the switch MAC when lldp chassis-id switch is configured.
  • Stores inspection data. The plugin data includes lldp_chassis_id (switch or interface, read from show running-config lldp), so you can tell which MAC to match against.
  • The inventory's system_vendor holds manufacturer, product_name (the chassis model) and serial_number from show version, shaped like redfish inspection's, with any field the switch doesn't report left out. Inspect doesn't write them to the node, so inspection rules can copy them (e.g. to extra.serial).
  • show version, show interface and show vdc detail go to the switch in one batched request, and show running-config lldp in a second.

Firmware

Records the running NX-OS release as the nxos firmware component. The switch's make, model and serial aren't part of it; they're in the inspection data. This runs as a verify, clean and service step. Updating firmware isn't implemented.

Configuration

  • driver_info takes nxos_address, nxos_username, nxos_password and nxos_verify_ca, named like the redfish driver's.
  • The credentials and verify_ca fall back to the new [cisco_nxos] config group.
  • The ironic component enables cisco_nxos as a hardware type and as a firmware and inspect interface.
  • The design guide has a new section for the driver.

Testing

  • Unit tests cover the NX-API client, output parsing, validation, port sync edge cases (MAC swaps, conflicts, duplicate names, null addresses) and partial failures. The new modules have 100% coverage.
  • Not yet run against a real switch. To check on a lab switch:
    • the MAC field name in show vdc detail;
    • the cli_ascii reply format;
    • how NX-API reports a batch where one command fails.

Move the code that stores a driver's reported versions as Ironic
firmware components out of panos_firmware into
utils/firmware_components.sync() so other out-of-band firmware
interfaces can reuse it. A component whose version changed also has the
new version recorded as last_version_flashed, as before.
@cardoe
cardoe enabled auto-merge November 26, 2026 17:28
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Python test results

875 tests   875 ✅  9s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 9143cf2.

♻️ This comment has been updated with latest results.

@cardoe
cardoe disabled auto-merge November 26, 2026 18:01
@cardoe
cardoe enabled auto-merge November 26, 2026 19:59
Add a `cisco_nxos` hardware type: a netdev with inspect and firmware
interfaces that read the switch over NX-API (JSON-RPC over HTTPS). Both
only run `show` commands and never change the switch.

Inspect creates a baremetal port named `<node>:<interface>` for each
physical Ethernet interface, carrying the interface's burned-in MAC, so
a server's LLDP data from its BMC can be matched to switch ports. It
never deletes ports, and a port whose MAC or name is already used by
another port is logged and skipped rather than failing inspection.
NX-OS sends each interface's MAC as the LLDP chassis ID by default and
the switch MAC with `lldp chassis-id switch`, so inspect also records
the switch MAC from `show vdc detail` as properties['chassis_mac'], and
stores inspection data whose plugin data says which mode the switch is
in (`lldp_chassis_id`, from `show running-config lldp`). Neither of
those, nor a missing firmware version, fails inspection.

The inventory's system_vendor holds the manufacturer, model and serial
number from `show version`, shaped like redfish inspection's; inspect
does not write them to the node, leaving that to inspection rules.

The structured commands are sent as one JSON-RPC batch, so inspection
makes two requests to the switch.

The firmware interface records the running NX-OS release as a firmware
component, without the switch's make, model or serial; updating is not
implemented.

driver_info takes `nxos_address`, `nxos_username`, `nxos_password` and
`nxos_verify_ca`, named like the redfish driver's. The credentials and
verify_ca fall back to the new [cisco_nxos] config group.

Enable `cisco_nxos` for the ironic component's hardware types, firmware
and inspect interfaces.
@khackworth

Copy link
Copy Markdown
Contributor

@cardoe -

  • Creds are imported via undercloud-deploy. We have a netdev-common in there that loads some tacacs creds. Those should probably be mirrored over int a cisco_nxos grouping in case we ever need to split off "switch tacacs" from "netdev common". ?

  • nxapi port: our switches we do not default 443 on the nxapi, so driver_info should probably include some attribute to override that connection to a customized port per device.

  • other ports: Only fetches Ethernet*, which is seemingly fine, depending on what the end goal is though. If maintaining infra, perhaps, mgmt is one to grab as well? Also, we typically leave downlinks as RX off. Uplinks have RX on. Uplinks also have port-channels associated with them, but if filtering on those, they would get a bit more dynamic. I guess this is merely an observation bullet here than a critique / suggestion.

@cardoe

cardoe commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

@khackworth so with regards to the ports, my initial attempt here is to do away with the data collection we need to do to import these into Nautobot. I'm game for changing all of this to how it makes sense.

from ironic_understack.utils import nxos_api

REQUIRED_PROPERTIES = {
"nxos_address": "Address of the switch's management interface, "

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.

Suggested change
"nxos_address": "Address of the switch's management interface, "
"nxos_address": "IP address of the switch's management interface, "



def components_from_show_version(version: dict) -> list[dict]:
"""Return the ``nxos`` component, or nothing if no release is reported."""

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.

Suggested change
"""Return the ``nxos`` component, or nothing if no release is reported."""
"""Return the ``nxos`` component, or the empty list if no release is reported."""

@cardoe
cardoe added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit d57f91d Nov 30, 2026
73 checks passed
@cardoe
cardoe deleted the cisco-nxos-driver branch November 30, 2026 17:16
@stevekeay

Copy link
Copy Markdown
Contributor

I'm worried that we are collecting data with no automatic way to "refresh" it periodically. I'd be worried that we're adding steps to the process, except we have promised if we add switches here, we will no longer need to add those switches to nautobot. Also, the discovery piece here means we need to enter less data than we did before.

cardoe added a commit that referenced this pull request Nov 30, 2026
driver_info nxos_address is now a URL, so a switch whose NX-API is not
on 443 can be reached: the port goes in the URL. https is assumed when
the scheme is missing, a bare IPv6 address is bracketed, and the path
defaults to /ins (NX-API's endpoint) unless one is given. A bare
address such as 192.0.2.20 still works as before.

An address that is not an http or https URL, has an invalid port, or
carries credentials, a query or a fragment fails validate(). The
address is parsed with rfc3986, now a direct dependency (it was already
installed through ironic).

NxosClient now takes the endpoint URL rather than building it from the
address.

Also reword the nxos_address and components_from_show_version
descriptions per review on #2825.
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