Skip to content

Conversation

@haseebsyed12
Copy link
Contributor

@haseebsyed12 haseebsyed12 commented Dec 10, 2025

By leveraging Ironic's native notification system (documented at Ironic Notifications),
we can react to state changes to keep Nautobot in sync.

Subscribe to specific Ironic notification events:

Nodes:

baremetal.node.update.end / baremetal.node.create.end → create or update the node in Nautobot
baremetal.node.delete.end → remove the node from Nautobot
Ports:

baremetal.port.update.end / baremetal.port.create.end → create or update the port in Nautobot
baremetal.port.delete.end → remove the port from Nautobot
Portgroups:

baremetal.portgroup.update.end / baremetal.portgroup.create.end → create or update the portgroup in Nautobot
baremetal.portgroup.delete.end → remove the portgroup from Nautobot

We focus on .end events since those represent completed operations with consistent state, and handle create/update together since a newly created node may not have complete information initially.

Sync these Nautobot resources:

  1. Device(dcim.devices) - server identity, location, rack, tenant, status
  2. Interfaces(dcim.interfaces) - network ports with MAC, type, description
  3. iDRAC Interface(dcim.interfaces) - management interface with BMC MAC
  4. Cables(dcim.cables) - connections between server interfaces and switch ports
  5. IP Addresses(ipam.ip_addresses) - BMC IP address
  6. IP-to-Interface associations(ipam.ip_address_to_interface) - links BMC IP to iDRAC interface

Nautobot Device Sync Implementation Comparison

Overview

Comparison between old (nautobot_device.py) and new (nautobot_device_sync.py + nautobot_device_interface_sync.py) implementations.

Data Source

Old New
Fetches data directly from BMC via Redfish (ChassisInfo) Fetches data from Ironic APIs (node, inventory, ports)

Device Identification

Old New
Uses serial_number to find/create device Uses Ironic node uuid as device ID
Device name passed as parameter Device name generated from {manufacturer}-{service_tag}

Switch Lookup

Old New
Finds switches by cf_chassis_mac_address custom field via GraphQL Finds switches by name (switch_info) or interface MAC address via REST
Includes base MAC calculation fallback for Cisco switches No base MAC fallback

Interface Identification

Old New
Looks up interface by device + name Uses Ironic port uuid as interface ID

IP Address Handling

Old New
Assigns IP to any interface with ipv4_address Only assigns BMC IP to iDRAC interface
Creates IP with parent prefix specified Relies on Nautobot auto-assignment (no parent prefix)
Upgrades DHCP leases to permanent (type: dhcptype: host) No DHCP handling
Raises exception on IP/interface conflicts Logs warning and continues

API Approach

Old New
Uses GraphQL for rich queries (device + interfaces + cables + vlan_group in one call) Uses REST API calls

Additional Features in New Implementation

  • Handles interface name conflicts (deletes conflicting interface before update)
  • Maps Ironic provision_state to Nautobot status via ProvisionStateMapper
  • Syncs tenant from Ironic lessee field
  • Supports custom_fields on device
  • Event handlers for various Ironic events (provision, CRUD, power, maintenance)
  • Delete device handler

@haseebsyed12 haseebsyed12 force-pushed the nautobot-device-interface-sync branch 11 times, most recently from 1af7662 to 0cd0789 Compare December 17, 2025 18:41
@haseebsyed12 haseebsyed12 changed the title feat: using enriched data updated by inspect hooks from both agent and redfish interfaces feat: update nautobot with enriched data updated by inspect hooks Dec 17, 2025
@haseebsyed12 haseebsyed12 marked this pull request as ready for review December 17, 2025 18:43
@haseebsyed12 haseebsyed12 requested a review from a team December 17, 2025 18:44
@haseebsyed12 haseebsyed12 force-pushed the nautobot-device-interface-sync branch from 4ef1f91 to 2898164 Compare December 18, 2025 01:56
@cardoe
Copy link
Contributor

cardoe commented Dec 18, 2025

Can you describe the changes in the body of the PR?

@haseebsyed12 haseebsyed12 force-pushed the nautobot-device-interface-sync branch 2 times, most recently from 445cdf9 to f4691e2 Compare January 2, 2026 04:23
@haseebsyed12 haseebsyed12 force-pushed the nautobot-device-interface-sync branch from b769c2b to 834a825 Compare January 2, 2026 10:31
@haseebsyed12 haseebsyed12 requested a review from a team January 2, 2026 10:33
Copy link
Contributor

@stevekeay stevekeay left a comment

Choose a reason for hiding this comment

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

I like this, but I have some concerns that if we get a "partial" update, we would overwrite some nautobot data but potentially leave behind stale records or attributes. Like for instance, we don't seem to delete any old interfaces or cables.

I think we should get this merged. I have left a boatload of style suggestions.

@stevekeay
Copy link
Contributor

Just to be clear, I approved this because I think it will work, but we should still make the changes!

@haseebsyed12 haseebsyed12 force-pushed the nautobot-device-interface-sync branch from 834a825 to 7016c7e Compare January 5, 2026 14:19
@haseebsyed12 haseebsyed12 force-pushed the nautobot-device-interface-sync branch from 7016c7e to 54ad2da Compare January 5, 2026 14:38
@haseebsyed12 haseebsyed12 added this pull request to the merge queue Jan 5, 2026
Merged via the queue into main with commit 894b4fa Jan 5, 2026
46 checks passed
@haseebsyed12 haseebsyed12 deleted the nautobot-device-interface-sync branch January 5, 2026 14:39
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.

6 participants