Skip to content

feat: track rack and position in Ironic extra fields - #2227

Draft
cardoe wants to merge 3 commits into
mainfrom
rack-height
Draft

feat: track rack and position in Ironic extra fields#2227
cardoe wants to merge 3 commits into
mainfrom
rack-height

Conversation

@cardoe

@cardoe cardoe commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Refactor the code path of syncing devices from Ironic into Nautobot to utilize the extra.rack and extra.position data that would come from Ironic. To do this I first changed how we determine the Nautobot Location, which should always be equal to the OpenStack region and has not been respected before. So this updates the code to use the OpenStack region and perform a lookup of the Nautobot Location based on that value first and thread that through. There are more objects and item in Nautobot that we've treated globally unique but should be scoped to this Location but I've left that to a future update. Lastly (or first commit really) document the extra values that are used by scripts and code on an Ironic node.

cardoe added 3 commits August 20, 2026 17:38
The Ironic node `extra` dict carries UnderStack-specific metadata that the
Nautobot device sync consumes, but it was previously undocumented. Document
the `extra` field and the `external_cmdb_id` key as they exist today.
Resolve the OpenStack region this deployment manages to its Nautobot
Location once, up front, and thread that Location object down to
fetch_node_details so location-scoped Nautobot lookups can be scoped to
it (e.g. resolving a rack).

On the event path, handle_node_event now uses the OpenStack connection
it already receives (conn.config.region_name) instead of discarding it.
On the resync CLI path the region is derived from the same
clouds.yaml/env the IronicClient uses. In both cases
get_location_for_region looks up the Location and fails fast if the
region does not resolve to exactly one Nautobot Location.

No node-sync behavior change yet, but objects and lookups that should
be location-scoped can and should use this.
The Nautobot device sync previously derived a node's rack and location
only from the switches its ports are cabled to, and never set the
rack-unit position. Allow an explicit placement via the node's Ironic
extra field: rack (a Nautobot rack name) and position (the rack unit).

When both are present and the rack name resolves to a single Nautobot
rack, the sync uses them for rack, location, and position, overriding
the switch-based lookup. The lookup is scoped to the region's Nautobot
location (a rack name is only unique within a location), an ambiguous
match falls back cleanly, and the position is validated before any
state is mutated. If either field is missing or the rack can't be
resolved, the sync falls back to the existing switch-based behavior.
Also stop preserving the old device's position on re-enrollment when
extra supplies one, so extra stays authoritative.
@cardoe cardoe changed the title rack height feat: track rack and position in Ironic extra fields Aug 21, 2026
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