Skip to content

Include WAN edge inventory in device lookup#199

Open
sashiv20 wants to merge 1 commit into
mainfrom
fix/device-inventory-lookup-only
Open

Include WAN edge inventory in device lookup#199
sashiv20 wants to merge 1 commit into
mainfrom
fix/device-inventory-lookup-only

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.

This is the replacement for #197 with the CI-only commits removed, per the maintainer comment on #197 after #198 merged the CI fixes into main.

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/test_devices_api.py catalystwan/tests/test_templates.py -> 55 passed, 1 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
  • uv run mypy --show-error-codes --show-error-context --pretty --install-types --non-interactive catalystwan --cache-dir=.mypy_cache/ --disable-error-code override
  • git diff --check origin/main...HEAD

@sbasan sbasan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

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