Skip to content

[codex] Include WAN edge inventory in device lookup#197

Closed
sashiv20 wants to merge 5 commits into
mainfrom
fix/include-wan-edge-inventory
Closed

[codex] Include WAN edge inventory in device lookup#197
sashiv20 wants to merge 5 commits into
mainfrom
fix/include-wan-edge-inventory

Conversation

@sashiv20

Copy link
Copy Markdown
Collaborator

Summary

Fix DevicesAPI.get() so callers can resolve WAN edge devices that are present in configuration inventory but absent from the monitored /dataservice/device response on newer vManage trains.

Root Cause

In the failing vTest run, mtt_aaa.test_create_attach_device_template looked up vm81 with DevicesAPI(provider_session).get().filter(hostname=mt_edge.name).single_or_default(). On vManage 27.1.991-1, /dataservice/device returned only controllers before template attach, so the lookup returned None. TemplatesAPI.attach() then dereferenced device.uuid, producing a raw AttributeError.

Changes

  • Preserve the existing monitored-device flow through /dataservice/device and /dataservice/device/system/info.
  • Add a best-effort fallback that merges missing WAN edges from configuration device inventory (vedges).
  • Broaden DeviceDetailsResponse aliases for newer/older inventory payload field names.
  • Raise explicit SDK errors when TemplatesAPI.attach() is called with a missing template or device.
  • Add unit tests for inventory-backed device discovery and template attach error handling.

Validation

  • uv run pytest catalystwan/tests -> 524 passed, 10 skipped
  • uv run flake8 catalystwan/api/basic_api.py catalystwan/api/template_api.py catalystwan/endpoints/configuration_device_inventory.py catalystwan/tests/test_devices_api.py catalystwan/tests/test_templates.py
  • git diff --check

Note: repo pre-commit was attempted, but local hook tooling is stale on this machine: pycln fails under Python 3.12 with ast.Str, and the mypy hook expects poetry to be installed.

@sashiv20 sashiv20 marked this pull request as ready for review May 27, 2026 17:09
@nikhilkp93 nikhilkp93 requested review from PrzeG, cicharka and sbasan May 27, 2026 17:27
@sbasan

sbasan commented May 28, 2026

Copy link
Copy Markdown
Collaborator

@sashiv20
We have recently picked a poetry CI fix from dev branch #198
In order not to de-sync these branches and keep changes clean:
I suggest to create a new PR containing only device inventory lookup improvements 4ba80d2 or revert CI changes and rebase. Thanks

@sashiv20

Copy link
Copy Markdown
Collaborator Author

Thanks, done. I created a clean replacement PR from current main that contains only the device inventory lookup changes and leaves the CI fixes to #198: #199

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