Skip to content

feat(adapters): add Cisco Catalyst SD-WAN source adapter (ciscosdwan) - #426

Draft
pcDamasceno wants to merge 2 commits into
mainfrom
017-cisco-sdwan-adapter
Draft

pcDamasceno wants to merge 2 commits into
mainfrom
017-cisco-sdwan-adapter

Conversation

@pcDamasceno

@pcDamasceno pcDamasceno commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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_USERNAME and CISCO_SDWAN_PASSWORD, and CISCO_SDWAN_URL replaces the url setting 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 pageInfo pagination (moreEntries, then startId set to the received endId). 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-name becomes host_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

  • diff and sync ran 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 second diff against that branch reported no differences.
  • The sandbox lists 30 router chassis numbers, 4 of them assigned to a site; the filter on configuredSiteId keeps 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.md and AGENTS.md list the adapter. .vale/styles/spelling-exceptions.txt adds vManage.
  • changelog/+cisco-sdwan-adapter.added.md records 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 Sdwan schema 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 generate reads the Infrahub address and token only from config.yml, and ignores INFRAHUB_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

View guided diff Turn on auto-fix

Read inventory from SD-WAN Manager with its form login and XSRF token,
pageInfo pagination, bounded retries and a logout at the end of the run.
The example maps the Manager, its sites, configuration groups and WAN
edge routers to the Sdwan schema.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pcDamasceno pcDamasceno added type/feature New feature or request changes/minor Bump minor version (new feature) labels Nov 16, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Deploying infrahub-sync with  Cloudflare Pages  Cloudflare Pages

Latest commit: 00cc63f
Status: ✅  Deploy successful!
Preview URL: https://44b3da35.infrahub-sync.pages.dev
Branch Preview URL: https://017-cisco-sdwan-adapter.infrahub-sync.pages.dev

View logs

Vale 3.13.0, the version pinned in the linter workflow, flags
"onboarded" in docs/docs/adapters/cisco-sdwan.mdx as a spelling error.
Newer Vale releases accept the word, so the check passed locally.
Cisco uses "onboard" for registering a WAN edge router with the Manager.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes/minor Bump minor version (new feature) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant