feat(adapters): add Cisco Catalyst SD-WAN source adapter (ciscosdwan)
Summary
Network teams that run Cisco Catalyst SD-WAN can now compare the inventory in SD-WAN Manager with Infrahub and sync it with the usual configuration-driven workflow. The new ciscosdwan source adapter reads any JSON resource under /dataservice/. The example maps the Manager, its sites, its configuration groups and its WAN edge routers to the SdwanInstance, SdwanSite, SdwanConfigurationGroup and SdwanRouter kinds.
Adapter behavior
- Logs in with the SD-WAN Manager form login and XSRF token, as described in the Cisco SD-WAN authentication documentation. The username and password come from
CISCO_SDWAN_USERNAMEandCISCO_SDWAN_PASSWORD, andCISCO_SDWAN_URLreplaces theurlsetting when set. - Uses one session per run and logs out after the last mapping loads or when a request fails. The Cisco page states that the Manager limits concurrent sessions and invalidates the least recently used one at that limit.
- Works as a source only. Data requests use GET; the only POST requests are the login and the logout.
- Follows
pageInfopagination (moreEntries, thenstartIdset to the receivedendId). An endpoint that uses scroll pagination stops the run instead of loading part of the resource. - Retries rate limits, server errors, timeouts and connection failures a bounded number of times and honors
Retry-After. Logs in once more when the Manager rejects the session during a run. - Adds an underscore copy of each hyphenated field name (
host-namebecomeshost_name), so Jinja2 transforms can use those fields. - Requests an endpoint once per run when several mappings use it. Loads identical duplicate records once and stops on duplicates whose values differ.
- Keeps the password, the session cookie and the XSRF token out of errors, logs and tracebacks, including tracebacks rendered with local variables.
Part of the router mapping in the example:
- name: SdwanRouter
mapping: system/device/vedges
identifiers: ["chassis_id"]
filters:
- field: configuredSiteId
operation: is_not_empty
transforms:
- field: model
expression: "{{ deviceModel | replace('vedge-', '', 1) }}"
fields:
- name: chassis_id
mapping: chasisNumber # spelled this way by the API
- name: site
mapping: configuredSiteId
reference: SdwanSite
The change adds no dependencies and does not change infrahub-sync core. The example schema (examples/cisco_sdwan_to_infrahub/schema.yml) contains the four Sdwan node definitions from a complete SD-WAN schema, unchanged, without the relationships to nodes outside those four.
Lab validation
diffandsyncran against the Cisco DevNet SD-WAN sandbox (SD-WAN Manager 20.18.2.1) and an Infrahub 1.12.1 instance, into a dedicated Infrahub branch. The sync created 1 instance, 1 configuration group, 5 sites and 4 routers with their relationships. A seconddiffagainst that branch reported no differences.- The sandbox lists 30 router chassis numbers, 4 of them assigned to a site; the filter on
configuredSiteIdkeeps those 4. - The unit tests use trimmed responses recorded from that sandbox, in
tests/fixtures/ciscosdwan/.
Documentation updates
docs/docs/adapters/cisco-sdwan.mdx(new): authentication, the example mapping, connection settings, mapping other resources, and failure handling.docs/sidebars.ts,docs/docs/adapters/choosing-an-adapter.mdx,docs/docs/readme.mdx,README.mdandAGENTS.mdlist the adapter..vale/styles/spelling-exceptions.txtaddsvManage.changelog/+cisco-sdwan-adapter.added.mdrecords the adapter and the example.
The docs page passes rumdl, Vale and a Docusaurus build. Its statements were checked against the code, the lab and the Cisco authentication page. It did not go through the outline and review stops of the OpsMill docs-writing workflow.
Not covered by this change
- Interfaces and IP addresses. The
Sdwanschema has no kinds for them; the Manager provides them through the device state endpoints. - The device template of routers deployed with templates, because the sandbox only has routers deployed with configuration groups.
- Tenant selection on a multi-tenant Manager, scroll pagination and incremental sync.
- Observed separately and not changed here:
infrahub-sync generatereads the Infrahub address and token only fromconfig.yml, and ignoresINFRAHUB_ADDRESS.
Test plan
uv run invoke format
uv run invoke lint
uv run pytest -q tests/adapters/test_ciscosdwan.py tests/adapters/test_ciscosdwan_client.py
uv run infrahub-sync list --directory examples/
Results before opening: ruff passes, uv run ty check . exits 0, pylint rates the new modules 10.00/10, yamllint passes on the example, and the unit suite reports 432 passed and 5 skipped. For a live check, load the example schema, set the CISCO_SDWAN_* and INFRAHUB_API_TOKEN variables, then run generate and diff for from-cisco-sdwan.
š¤ Generated with Claude Code