Skip to content

[3/3] fix(nautobot): round-trip location types by key and stop inventing locations - #258

Merged
jacobsalmela merged 1 commit into
fix/export-skipped-interface-accountingfrom
fix/nautobot-location-type-roundtrip
Oct 2, 2026
Merged

jacobsalmela merged 1 commit into
fix/export-skipped-interface-accountingfrom
fix/nautobot-location-type-roundtrip

Conversation

@jacobsalmela

@jacobsalmela jacobsalmela commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor
  • Location types survive a round trip and the exporter stops inventing locations.
  • Export writes location types by display name (dc becomes "Data Center"); import previously stored the raw API URL in place of the key, so a re-imported datastore could not be exported again. Import now maps the Nautobot type back to the cani key, and the mapping guide documents the rule.
  • A rack or device with no resolvable location used to fall back to a synthetic "Default" location that existed nowhere in cani (and, for racks, that Nautobot rejected outright, failing the whole export). Both paths now fail with an error naming the object and the remedy instead.
  • Verified live against Nautobot 3.2.4: the new location-type spec passes 8/8 and the existing Nautobot specs 28/28; make utest and make ftest pass.

Stack

Merge in order. Each PR targets the one before it, and GitHub retargets the next onto main as each merges.

Order PR Branch Base
1 #256 fix/export-module-interface-attributes main
2 #257 fix/export-skipped-interface-accounting fix/export-module-interface-attributes
3 this PR fix/nautobot-location-type-roundtrip fix/export-skipped-interface-accounting

…cations

Export creates Nautobot location types by the registered definition's
display name ("dc" becomes "Data Center"), but import stored the
reference URL of the Nautobot type in LocationType, so a re-imported
location carried "http://.../dcim/location-types/<uuid>/" instead of its
key and could not be resolved again on export.

Fetch location types during import and map each Nautobot type back to
the cani key through the registry (display name or slug, case-
insensitive), slugifying names cani has no definition for. Document the
display-name rule in the mapping guide.

Racks and devices with no resolvable location used to fall back to a
synthetic "Default" location that has no datastore counterpart; for
racks it was a Section-typed location Nautobot rejects for lacking a
parent, which failed the whole export. Both paths now fail with an
error naming the object and the remedies (a located rack or
--default-location) and never create a location the inventory does not
describe. Container-only types (dc, level) keep descending to a child
that holds racks, as before.

Unit tests cover the key resolution and the import of the type
reference; a new integration spec exports a dc > level > section tree,
re-imports it and reads the keys back, and proves a rack placed directly
under a dc location fails by name without a synthetic location.

Assisted-by: GitHub Copilot
Signed-off-by: Jacob Salmela <jacob.salmela@hpe.com>
@jacobsalmela
jacobsalmela added this pull request to stack #259 October 2, 2026 16:17
@jacobsalmela
jacobsalmela merged commit 547c900 into main Oct 2, 2026
10 checks passed
@jacobsalmela
jacobsalmela deleted the fix/nautobot-location-type-roundtrip branch October 2, 2026 19:23
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