diff --git a/CHANGELOG.md b/CHANGELOG.md index 191f10d..3549331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,8 +27,8 @@ producer behavior versions shipped under each module tag. [`osiris/network/cisco/iosxe/CHANGELOG.md`](osiris/network/cisco/iosxe/CHANGELOG.md) - OSIRIS JSON producer for Cisco NX-OS: [`osiris/network/cisco/nxos/CHANGELOG.md`](osiris/network/cisco/nxos/CHANGELOG.md) -- OSIRIS JSON producer for Cisco vManage: - [`osiris/network/cisco/vmanage/CHANGELOG.md`](osiris/network/cisco/vmanage/CHANGELOG.md) +- OSIRIS JSON producer for Cisco Catalyst SD-WAN Manager: + [`osiris/network/cisco/catalyst-sd-wan-manager/CHANGELOG.md`](osiris/network/cisco/catalyst-sd-wan-manager/CHANGELOG.md) - OSIRIS JSON producer for HPE Aruba Networking Central: [`osiris/network/hpe/arubacentral/CHANGELOG.md`](osiris/network/hpe/arubacentral/CHANGELOG.md) @@ -41,8 +41,51 @@ OSIRIS JSON core schema itself, see the [OSIRIS JSON Repository](https://github. ## [Unreleased] -Repository test data policy and its CI gate. No OSIRIS JSON producer's -emitted documents changed and no behavior version changed. +## [0.13.0] - 2026-11-21 + +Repository test data policy and its CI gate and the Cisco Catalyst +SD-WAN Manager OSIRIS JSON producer behavior version 0.2.0 (formerly +vManage). No other OSIRIS JSON producer's emitted documents or behavior +version changed. + +| Producer | Behavior version | +|----------|------------------| +| Amazon Web Services OSIRIS JSON producer | 0.1.1 (no change) | +| Microsoft Azure OSIRIS JSON producer | 0.6.0 (no change) | +| Cisco APIC OSIRIS JSON producer | 0.4.0 (no change) | +| Cisco IOS-XE OSIRIS JSON producer | 0.2.0 (no change) | +| Cisco NX-OS OSIRIS JSON producer | 0.2.1 (no change) | +| Cisco Catalyst SD-WAN Manager OSIRIS JSON producer (formerly vManage) | [0.2.0](osiris/network/cisco/catalyst-sd-wan-manager/CHANGELOG.md#020---2026-11-19) | +| HPE Aruba Networking Central OSIRIS JSON producer | 0.1.0 (no change) | + +### Highlights (Cisco Catalyst SD-WAN Manager 0.2.0) +- **Rename:** `cisco catalyst-sdwan-manager` replaces `cisco vmanage` + (no alias) with new provider, namespace, generator and file names. +- **Cross-site graph:** each site document keeps its cross-site OMP + sessions and tunnels through neighbor resources whose IDs match + their own site documents, so an OSIRIS JSON Consumer can analyze and + merge the documents by ID. +- **Security:** documentation allowlist, redacted raw export, private + atomic publication, bounded and classified API errors, same-origin + redirects, a coverage record in every document and a strict exit + contract (`--require-complete`). +- **Breaking:** Cisco Catalyst SD-WAN Manager OSIRIS JSON Producer + behavior version 0.2.0. The vManage OSIRIS JSON Producer is renamed: + `cisco catalyst-sdwan-manager` replaces `cisco vmanage` (no alias), + the package moves to `osiris/network/cisco/catalyst-sd-wan-manager`, + and documents use `provider.name` `cisco.catalystsdwanmanager`, the + `osiris.cisco.catalystsdwanmanager` extension namespace and the + `osirisjson-producer-cisco-catalyst-sdwan-manager` generator name. + Each site document now keeps its cross-site OMP sessions and tunnels + by carrying the remote endpoints as neighbor resources with the same + IDs as in their own site documents; sites are `logical.site` groups; + `--purpose documentation` keeps an explicit field allowlist; + `--include-raw-body` redacts every row; documents are published + privately and atomically; diagnostics carry no response bodies; + redirects stay on the controller origin; every document records its + discovery coverage; and a run fails when a selected site is not + written (`--require-complete` also fails on partial documents). + See the producer [`CHANGELOG.md`](osiris/network/cisco/catalyst-sd-wan-manager/CHANGELOG.md#020---2026-11-21). ### Added - [OSIRIS JSON Producers Test Data Policy](docs/policies/OSIRIS-PRODUCER-TEST-DATA-POLICY.md): @@ -64,10 +107,11 @@ emitted documents changed and no behavior version changed. Recovery Services backup fabric name. - `test-data-policy.yml` workflow: a dedicated check on pushes, pull requests to `main` and `dev` and manual runs. -- Cisco vManage source-to-golden `/testdata` fixtures (`lab_sdwan`): - synthetic `/dataservice` response bodies for a control-plane site and - the expected documents at both `--purpose` levels, checked byte for - byte by `TestGolden`. The vManage behavior version is unchanged. +- Cisco Catalyst SD-WAN Manager source-to-golden `/testdata` fixtures: + `lab_sdwan` (a control-plane site) and `lab_cross_site` (two WAN edge + sites and a controller site joined by a cross-site tunnel and OMP + sessions), with the expected per-site documents at both `--purpose` + levels, checked byte for byte by `TestGolden`. - Cisco NX-OS source-to-golden `/testdata` fixtures (`n9k_c9300v`): synthetic NX-API command bodies for a Nexus 9300v and the expected documents at both `--purpose` levels, checked byte for byte by @@ -84,6 +128,8 @@ emitted documents changed and no behavior version changed. - Cisco command help no longer documents a `-p` password flag; the password is prompted for. +--- + ## [0.12.0] - 2026-11-15 Cisco APIC OSIRIS JSON producer behavior version 0.4.0: logical paths, @@ -912,7 +958,8 @@ Initial SDK release. No producers shipped under this tag. - Removed empty `common/` stubs (replaced by `pkg/sdk/`). - Updated `.gitignore` for Go. -[Unreleased]: https://github.com/osirisjson/osiris-producers/compare/v0.12.0...HEAD +[Unreleased]: https://github.com/osirisjson/osiris-producers/compare/v0.13.0...HEAD +[0.13.0]: https://github.com/osirisjson/osiris-producers/compare/v0.12.0...v0.13.0 [0.12.0]: https://github.com/osirisjson/osiris-producers/compare/v0.11.0...v0.12.0 [0.11.0]: https://github.com/osirisjson/osiris-producers/compare/v0.10.0...v0.11.0 [0.10.0]: https://github.com/osirisjson/osiris-producers/compare/v0.9.0...v0.10.0 diff --git a/INSTALL.md b/INSTALL.md index 429e5a5..c1c76b3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,138 +1,347 @@ -# Installing OSIRIS JSON Producers +# Installing OSIRIS JSON Producers + +OSIRIS JSON Producers discover infrastructure resources and export +vendor-neutral OSIRIS JSON snapshots documents. Pre-built distributions +are provided for Linux, macOS and Windows, so **Go is not required** for +a normal installation. + +**Useful links:** [Latest releases](https://github.com/osirisjson/osiris-producers/releases), [Installation guide](https://docs.osirisjson.org/osiris-producers/installation/), [Getting started](https://docs.osirisjson.org/osiris-producers/getting-started/) + +## Table of content +- [1. Choose an installation method](#1-choose-an-installation-method) +- [2. Install using a package manager](#2-install-using-a-package-manager) + - [Linux .deb](#linux-deb) + - [Linux .rpm](#linux-rpm) + - [Apple macOS Homebrew](#apple-macos-homebrew) + - [Microsoft Windows WinGet (PowerShell)](#microsoft-windows-winget-powershell) + - [Microsoft Windows Scoop (PowerShell)](#microsoft-windows-scoop-powershell) +- [3. Install manually from a release archive](#3-install-manually-from-a-release-archive) + - [3.1 Select the correct archive](#31-select-the-correct-archive) + - [3.2 Verify the downloaded archive before installation](#32-verify-the-downloaded-archive-before-installation) + - [3.3 Linux extract and install](#33-linux-extract-and-install) + - [3.4 Apple macOS extract and install](#34-apple-macos-extract-and-install) + - [3.5 Microsoft Windows extract and add to PATH](#35-microsoft-windows-extract-and-add-to-path) +- [4. Install using Go](#4-install-using-go) +- [5. Verify the installation and get started](#5-verify-the-installation-and-get-started) +- [6. Updating an existing OSIRIS JSON Producer installation](#6-updating-an-existing-osiris-json-producer-installation) +- [7. Troubleshooting and security prompts](#7-troubleshooting-and-security-prompts) + - [Permission denied or wrong architecture](#permission-denied-or-wrong-architecture) + - [Apple macOS security prompts](#apple-macos-security-prompts) + - [Microsoft Windows SmartScreen prompts](#microsoft-windows-smartscreen-prompts) + - [Package not found in Microsoft WinGet Scoop or Homebrew](#package-not-found-in-microsoft-winget-scoop-or-homebrew) +- [8. Documentation and support](#8-documentation-and-support) + + +## 1. Choose an installation method + +| Platform | Recommended method | Alternative | +|---|---|---| +| **Debian-based Linux** (Debian, Ubuntu, Linux Mint, Kali Linux, Parrot OS, Raspberry Pi OS, Zorin OS) | Release `.deb` | Release `.tar.gz` | +| **RPM-based Linux** (RHEL, Fedora, CentOS, Rocky Linux, AlmaLinux, openSUSE, SLES, Oracle Linux, Amazon Linux) | Release `.rpm` | Release `.tar.gz` | +| **Other supported Linux distributions** | Release `.tar.gz` | Build/install with Go | +| **macOS** (Apple Silicon / Intel) | Homebrew | Release `.tar.gz` | +| **Windows** (x86-64) | WinGet or Scoop | Release `.zip` | + +## 2. Install using a package manager + +### Linux .deb + +Download the matching `.deb` file from [GitHub Releases](https://github.com/osirisjson/osiris-producers/releases) and run the following from its +download directory. -Pre-built binaries are available on the -[Releases page](https://github.com/osirisjson/osiris-producers/releases) for Linux, -macOS and Windows. No Go toolchain required. +```bash +# Install or upgrade +sudo apt install ./osiris-producers__linux_amd64.deb -## Download +# Verify +osirisjson-producer --version +``` -Pick the archive for your OS and architecture: +The example is for x86-64 (`amd64`). For other architectures, use a +matching release package only if it is published. -| OS | Architecture | File | -|---------|-------------|--------------------------------------------------| -| Linux | x86-64 | `osiris-producers__linux_amd64.tar.gz` | -| Linux | ARM 64 | `osiris-producers__linux_arm64.tar.gz` | -| macOS | Intel | `osiris-producers__darwin_amd64.tar.gz` | -| macOS | Apple M1/M2 | `osiris-producers__darwin_arm64.tar.gz` | -| Windows | x86-64 | `osiris-producers__windows_amd64.zip` | +### Linux .rpm -Linux users can also install via the `.deb` or `.rpm` packages listed on the release page. +Download the matching `.rpm` from [GitHub Releases](https://github.com/osirisjson/osiris-producers/releases), then: -## Linux +```bash +# Install or upgrade RHEL / Fedora and DNF-based distributions +sudo dnf install ./osiris-producers__linux_amd64.rpm -**Archive:** +# Install or upgrade openSUSE / SUSE Linux Enterprise +sudo zypper install ./osiris-producers__linux_amd64.rpm -```bash -tar -xzf osiris-producers__linux_amd64.tar.gz -sudo mv osirisjson-producer /usr/local/bin/ +# Alternative RPM directly +sudo rpm -Uvh ./osiris-producers__linux_amd64.rpm + +# Verify osirisjson-producer --version ``` -**Debian / Ubuntu (.deb):** +The example is for x86-64 (`amd64`). For other architectures, use a +matching release package only if it is published. + +### Apple macOS Homebrew + +**Prerequisite:** Homebrew must be installed and available in your +terminal. If you haven't installed it yet, follow the official +[Homebrew installation guide](https://brew.sh/). +After installation, follow the instructions displayed by Homebrew to +configure your `PATH`, if required. ```bash -sudo dpkg -i osiris-producers__linux_amd64.deb +# Verify Homebrew is available +brew --version + +# Install OSIRIS JSON Producers +brew tap osirisjson/osiris-producers +brew install osirisjson-producer + +# Verify installation osirisjson-producer --version ``` -**RHEL / Fedora / CentOS (.rpm):** +### Microsoft Windows WinGet (PowerShell) -```bash -sudo rpm -i osiris-producers__linux_amd64.rpm +**Prerequisite:** WinGet is included with Microsoft **App Installer** on +supported Windows versions. If `winget` is not recognized, install or +update App Installer from the Microsoft Store. See the official +[Microsoft WinGet installation guide](https://learn.microsoft.com/en-us/windows/package-manager/winget/). + +```powershell +# Verify WinGet is available +winget --version + +# Install OSIRIS JSON Producers +winget install --id osirisjson.osirisjson-producer --exact + +# Verify installation osirisjson-producer --version ``` -## macOS +### Microsoft Windows Scoop (PowerShell) -**Homebrew (recommended):** +**Prerequisite:** Scoop must be installed before using this method. +If it is not available, follow the official [Scoop installation instructions](https://scoop.sh/). Scoop is typically installed in a regular, non-administrator PowerShell +session and may require configuring the current user's PowerShell +execution policy. -```bash -brew tap osirisjson/osiris-producers -brew install osirisjson-producer +```powershell +# Verify Scoop is available +scoop --version + +# Add the OSIRIS Producers bucket +scoop bucket add osiris-producers https://github.com/osirisjson/scoop-osiris-producers + +# Install OSIRIS JSON Producers +scoop install osirisjson-producer + +# Verify installation +osirisjson-producer --version ``` -Homebrew handles quarantine automatically - no Gatekeeper warning, no extra steps. -**Archive (alternative):** +## 3. Install manually from a release archive + +Manual installation does not require Homebrew, WinGet, Scoop or Go. + +### 3.1 Select the correct archive + +On the [Releases page](https://github.com/osirisjson/osiris-producers/releases) +choose the archive that matches your operating system and CPU +architecture: + +| Operating system | Architecture | Asset filename pattern | +| --- | --- | --- | +| Linux | x86-64 | `osiris-producers__linux_amd64.tar.gz` | +| Linux | ARM64 | `osiris-producers__linux_arm64.tar.gz` | +| macOS | Intel (x86-64) | `osiris-producers__darwin_amd64.tar.gz` | +| macOS | Apple Silicon (ARM64) | `osiris-producers__darwin_arm64.tar.gz` | +| Windows | x86-64 | `osiris-producers__windows_amd64.zip` | + +Check your architecture with `uname -m` on Linux/macOS (`x86_64` means +`amd64`; `aarch64`/`arm64` means `arm64`). On Windows, open +**Settings -> System -> About -> System type**. + +### 3.2 Verify the downloaded archive before installation + +Download the release's `osiris-producers__checksums.txt` +alongside the archive. +Compare the result with the matching entry in `checksums.txt`. +**Do not install or run a downloaded file if its checksum does not match.** +Checksums detect changes relative to the published manifest; they do not +independently establish publisher identity. + +**Linux:** ```bash -tar -xzf osiris-producers__darwin_arm64.tar.gz -sudo mv osirisjson-producer /usr/local/bin/ +sha256sum --check --ignore-missing "osiris-producers_${VERSION}_checksums.txt" ``` -### Gatekeeper warning (archive installs only) +**macOS:** (`shasum` is included with macOS) -macOS Gatekeeper will block the binary on first run because it is not yet -notarized with an Apple Developer certificate. You will see: +```bash +shasum -a 256 "osiris-producers_${VERSION}_darwin_arm64.tar.gz" +``` + +**Windows (PowerShell):** + +```powershell +(Get-FileHash ".\osiris-producers_${Version}_windows_amd64.zip" -Algorithm SHA256).Hash +``` -> "osirisjson-producer" cannot be opened because the developer cannot be verified. -**Fix - command line (one-time, recommended):** +### 3.3 Linux extract and install + +For x86-64: ```bash -xattr -d com.apple.quarantine /usr/local/bin/osirisjson-producer +tar -xzf "osiris-producers_${VERSION}_linux_amd64.tar.gz" +sudo install -m 0755 osirisjson-producer /usr/local/bin/osirisjson-producer +osirisjson-producer --version ``` -**Fix - Finder:** +For ARM64, use `linux_arm64` in the archive filename. If the archive +contains a subdirectory, use the actual extracted path to +`osirisjson-producer` in the `install` command. -Right-click the binary -> Open -> click "Open" in the dialog. -macOS remembers the exception after the first run. +### 3.4 Apple macOS extract and install -After applying either fix, the binary runs normally with no further prompts. +For Apple Silicon: -## Windows +```bash +tar -xzf "osiris-producers_${VERSION}_darwin_arm64.tar.gz" +sudo install -m 0755 osirisjson-producer /usr/local/bin/osirisjson-producer +osirisjson-producer --version +``` -Extract the `.zip` archive and move `osirisjson-producer.exe` to a directory -on your `%PATH%`. A user-writable location that works without admin rights: +For Intel Macs, use `darwin_amd64` in the archive filename. +If the archive contains a subdirectory, use the actual extracted binary +path. See [macOS security prompts](#macos-security-prompts) if macOS +blocks a manually installed executable. -```text -%LOCALAPPDATA%\Programs\osirisjson\ -``` +### 3.5 Microsoft Windows extract and add to PATH -To add it to your PATH permanently (no admin required): +1. Download and verify the Windows `.zip` archive. +2. Extract the archive. Copy `osirisjson-producer.exe` to `%LOCALAPPDATA%\Programs\osirisjson\` (create the directory if needed). +3. In **PowerShell**, add that directory to your **user** PATH without + overwriting the system PATH: ```powershell -[Environment]::SetEnvironmentVariable("PATH", $env:PATH + ";$env:LOCALAPPDATA\Programs\osirisjson", "User") +$Bin = Join-Path $env:LOCALAPPDATA 'Programs\osirisjson' +$UserPath = [Environment]::GetEnvironmentVariable('Path', 'User') +$UserEntries = @($UserPath -split ';' | Where-Object { $_ }) +if ($UserEntries -notcontains $Bin) { + [Environment]::SetEnvironmentVariable('Path', (($UserEntries + $Bin) -join ';'), 'User') +} +$env:Path += ";$Bin" # Make the executable available in this PowerShell session +osirisjson-producer --version ``` -### Windows SmartScreen warning +Open a new terminal for the permanent PATH change to take effect. +This example assumes the executable is directly inside the directory, +not a nested extraction folder. + +## 4. Install using Go -Windows SmartScreen may show "Windows protected your PC" on first run because -the binary is not yet signed with a commercial certificate. +If you already have **Go 1.22 or later** you can install the packages +from the Go module: -**Fix:** +```bash +go install go.osirisjson.org/producers/cmd/...@latest +``` -1. Click **More info** -2. Click **Run anyway** +This installs the command packages provided by the selected module +version. The binaries are placed in `GOBIN`, or in `$(go env GOPATH)/bin` +if `GOBIN` is not set. Add that directory to your PATH if necessary. +To reproduce an installation, replace `@latest` with a specific +published module version. -Alternatively, right-click `osirisjson-producer.exe` -> Properties -> -check the **Unblock** box at the bottom -> OK. After that the binary runs -without any prompt. +The Go toolchain is **not** required for any of the pre-built release +methods above. -## Verify the download (optional) +## 5. Verify the installation and get started -Each release includes a `osiris-producers__checksums.txt` file. -Verify the archive before extracting: +From your terminal run: ```bash -# Linux / macOS -sha256sum -c osiris-producers__checksums.txt --ignore-missing - -# Windows (PowerShell) -Get-FileHash osiris-producers__windows_amd64.zip -Algorithm SHA256 +osirisjson-producer --version +osirisjson-producer --help ``` -Compare the output against the matching line in `checksums.txt`. +The first command should display the installed producer release version, +the second should display the supported command interface. +For OSIRIS JSON producer-specific usage see [Getting started](https://docs.osirisjson.org/osiris-producers/getting-started/). + +> [!NOTE] +> **OSIRIS JSON specification format vs. OSIRIS JSON Producer version:** +> The installed executable's version is not the OSIRIS JSON document +> specification version. The latter is defined separately by the [OSIRIS JSON v1.0 specification](https://github.com/osirisjson/osiris/blob/main/specification/v1.0/OSIRIS-JSON-v1.0.md) and [schema](https://osirisjson.org/schema/v1.0/osiris.schema.json). + +## 6. Updating an existing OSIRIS JSON Producer installation + +Use the same installation method you originally selected: -## Install via Go (if you have Go 1.22+) +| Installation method | Typical update command or action | +| --- | --- | +| Homebrew | `brew update && brew upgrade osirisjson-producer` | +| WinGet | `winget upgrade --id osirisjson.osirisjson-producer --exact` | +| Scoop | `scoop update osirisjson-producer` | +| Manual archive | Download, verify and replace with the newer release binary | +| `.deb` / `.rpm` | Download and install the newer package using your distribution's upgrade procedure | +| Go | Re-run `go install` with a chosen module version | + +After updating, run `osirisjson-producer --version` again. + +## 7. Troubleshooting and security prompts ```bash -go install go.osirisjson.org/producers/cmd/...@latest +osirisjson-producer: command not found or not recognized ``` -This installs all binaries at once: `osirisjson-producer` (bundled dispatcher), -`osirisjson-producer-aws`, `osirisjson-producer-azure`, and `osirisjson-producer-cisco`. +Check that the executable is in a directory on PATH. Reopen the terminal +after changing PATH. For Go installs, check `go env GOPATH` and +`go env GOBIN`. On Linux/macOS, use `command -v osirisjson-producer`, on +Windows, use `Get-Command osirisjson-producer` in PowerShell. + +### Permission denied or wrong architecture + +Ensure the binary is executable and that the downloaded archive matches +the operating system and CPU architecture. On managed machines, use an +approved user-writable location rather than changing system-wide +installation permissions. + +### Apple macOS security prompts + +A release installed manually from a `.tar.gz` may prompt macOS +Gatekeeper if the executable is not notarized. Verify the download's +source and checksum first. If you trust the release, use the +macOS-provided **Open** / **Open Anyway** workflow for that specific +application. Do not disable Gatekeeper system-wide. + +If required by your organization's policies, an administrator may +instead authorize the specific verified executable. Homebrew is +generally the simpler installation path. + +### Microsoft Windows SmartScreen prompts + +Windows may warn about an unfamiliar or unsigned application. +Verify the download and publisher first do not bypass a warning for an +unexpected file. If your security policy permits it and you trust the +verified release, follow Windows application-specific +**More info -> Run anyway** flow, or use the file's +**Properties -> Unblock** option when available. +Do not disable SmartScreen globally. + +### Package not found in Microsoft WinGet Scoop or Homebrew + +Confirm the package name and configured repository or bucket. +Package availability can lag behind a GitHub release. Use the matching, +checksum-verified archive if the package is not currently available. -## Quick start +## 8. Documentation and support -Full documentation: https://osirisjson.org/en/docs/producers/getting-started +- [Online installation guide](https://docs.osirisjson.org/osiris-producers/installation/) +- [OSIRIS JSON Producer getting started](https://docs.osirisjson.org/osiris-producers/getting-started/) +- [Releases and checksums](https://github.com/osirisjson/osiris-producers/releases) +- [Open Issues and support](https://github.com/osirisjson/osiris-producers/issues) \ No newline at end of file diff --git a/README.md b/README.md index 15aa300..cd759aa 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,129 @@ # The OSIRIS JSON Producers -[![GitHub license](https://img.shields.io/badge/license-Apache2.0-blue.svg)](https://raw.githubusercontent.com/osirisjson/osiris-producers/master/LICENSE) -[![Go Reference](https://pkg.go.dev/badge/github.com/osirisjson/osiris-producers.svg)](https://pkg.go.dev/go.osirisjson.org/producers) -[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=osirisjson_osiris-producers&metric=security_rating&token=341158228074a961caa8700b5b8ab74f7ac963b2)](https://sonarcloud.io/component_measures?metric=new_security_rating&id=osirisjson_osiris-producers) - - -An **OSIRIS JSON Producer** is a lightweight, read-only program written in Go that runs on your workstation or server. - -It connects directly to supported infrastructure environments, discovers resources and relationships, normalizes vendor-specific data, redacts sensitive values, and generates a portable OSIRIS JSON document representing the infrastructure at a specific point in time. +[![GitHub License](https://img.shields.io/github/license/osirisjson/osiris-producers?style=flat-square&color=142C49&labelColor=23355F)](https://github.com/osirisjson/osiris-producers/blob/main/LICENSE) +[![Go Reference](https://img.shields.io/badge/Go-Reference-142C49?style=flat-square&labelColor=23355F&logo=go&logoColor=white)](https://pkg.go.dev/go.osirisjson.org/producers) +[![GitHub Release](https://img.shields.io/github/v/release/osirisjson/osiris-producers?style=flat-square&color=142C49&labelColor=23355F)](https://github.com/osirisjson/osiris-producers/releases/latest) +[![GitHub Downloads](https://img.shields.io/github/downloads/osirisjson/osiris-producers/total?style=flat-square&color=142C49&labelColor=23355F)](https://github.com/osirisjson/osiris-producers/releases) +[![Docs](https://img.shields.io/badge/Docs_OSIRIS_JSON-142C49?style=flat-square&labelColor=23355F&logo=readthedocs&logoColor=white)](https://docs.osirisjson.org/osiris-producers/getting-started/) +[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=osirisjson_osiris-producers&metric=security_rating)](https://sonarcloud.io/component_measures?metric=security_rating&id=osirisjson_osiris-producers) + +An **OSIRIS JSON Producer** is a lightweight, **read-only** +infrastructure discovery software written in Go that **transforms** +proprietary, vendor-specific infrastructure data into **portable, vendor-neutral [OSIRIS JSON](https://github.com/osirisjson/osiris)** snapshots +documents. + +It connects to supported public platforms and private on-premises +environments, discovers resources and their relationships, normalizes +vendor-specific data, applies sensitive-data redaction and generates a +structured representation of the infrastructure at a specific point in +time. + +**OSIRIS JSON Producers run under your control, without requiring proprietary intermediary platforms, separate SaaS services, external consultancy, or AI integration.**

- The OSIRIS JSON producer for Cisco APIC + OSIRIS JSON Producer discovering a Cisco ACI fabric
- In this demo we are running the OSIRIS JSON Producer for Cisco APIC and generating an OSIRIS JSON document + OSIRIS JSON Cisco APIC Producer generating a vendor-neutral OSIRIS JSON infrastructure snapshot using the Cisco DevNet always-on ACI simulator.

+## Installation + +OSIRIS JSON Producers are available as pre-built binaries for +**Linux, macOS, and Windows**. See [INSTALL](INSTALL.md) for more +informations. + +| OS | Quick install | +|---|---| +| **Linux** | Download the `.deb` or `.rpm` package from [GitHub Releases](https://github.com/osirisjson/osiris-producers/releases), then install using `sudo apt install` or `sudo dnf install` or `sudo zypper install`. | +| **macOS** | `brew tap osirisjson/osiris-producers && brew install osirisjson-producer` | +| **Windows** | `winget install osirisjson.osirisjson-producer` | + +**Verify your installation:** + +```bash +osirisjson-producer --version +``` + +For alternative installation methods (Scoop, manual archives, Go), +supported architectures, checksum verification, and troubleshooting, +see [INSTALL.md](INSTALL.md). +Once installed, follow the [Getting Started Guide](https://docs.osirisjson.org/osiris-producers/getting-started/) to generate your first OSIRIS JSON +snapshot. + + +### Try the OSIRIS JSON Cisco APIC Producer on Cisco DevNet + +The demo above was conducted on [Cisco ACI Simulator Always On](https://developer.cisco.com/sandbox/detail/aci-simulator-always-on) sandbox. + +```bash +# Show available Cisco APIC options +osirisjson-producer cisco apic --help + +# Discover infrastructure from the Cisco DevNet sandbox +# --insecure is used for the sandbox's self-signed certificate. +# Use trusted certificate verification in production. +osirisjson-producer cisco apic -h sandboxapicdc.cisco.com --insecure + +# Generate an audit-purpose snapshot +osirisjson-producer cisco apic -h sandboxapicdc.cisco.com --insecure --purpose audit +``` + +## Supported IT infrastructure environments + +| OSIRIS JSON Producer | Category | Status | +|---|---|---| +| **Amazon AWS** | Hyperscaler | [Available](https://docs.osirisjson.org/osiris-producers/hyperscalers/amazon-aws/) | +| **Cloudflare** | Hyperscaler | Planned | +| **Google Cloud** | Hyperscaler | [Under development](https://osirisjson.org/en/commitments/roadmap) | +| **Microsoft Azure** | Hyperscaler | [Available](https://docs.osirisjson.org/osiris-producers/hyperscalers/microsoft-azure/) | +| **Arista EOS** | Network | Planned | +| **Ciena SAOS** | Network | Planned | +| **Cisco (APIC, NX-OS, IOS-XE, Catalyst SD-WAN Manager)** | Network | [Available](https://docs.osirisjson.org/osiris-producers/network/cisco) | +| **F5 BIG-IP** | Network | Planned | +| **HPE Aruba Networking Central** | Network | [Available](https://docs.osirisjson.org/osiris-producers/network/hpe-aruba-networking-central) | +| **HPE Aruba AOS** | Network | Planned | +| **MikroTik RouterOS** | Network | Planned | +| **Nokia SR** | Network | Planned | +| **SONiC** | Network | Planned | +| **Ubiquiti UniFi (ui.com)** | Network | Planned | +| **Check Point** | Security | Planned | +| **Palo Alto** | Security | Planned | +| **Proxmox VE** | Hypervisor | Planned | +| **VMware vSphere** | Hypervisor | Planned | + +## Supported OT infrastructure environments + +| OSIRIS JSON Producer | Category | Status | +|---|---|---| +| **Zebra PPME LinkOS** | Industrial Printers | Planned | -### The OSIRIS JSON Manifesto in practice +*For the complete roadmap, visit [osirisjson.org/en/commitments/roadmap](https://osirisjson.org/en/commitments/roadmap).* + +--- -End-to-end infrastructure visibility should not depend on tribal knowledge, expensive consultancy, or closed and proprietary external platforms. +## The OSIRIS JSON Manifesto in practice -When you run an OSIRIS JSON Producer: +End-to-end infrastructure visibility should not depend on tribal +knowledge, expensive consultancy, or closed, proprietary platforms. -* No AI platform, MCP server, or external agent is required. -* No SaaS subscription or intermediary service is required. -* The OSIRIS JSON producer runs within an environment you fully control. -* Credentials and authentication material are excluded from the generated document. -* Operational logs provide clear visibility into discovery, normalization, redaction, and emission. +With OSIRIS JSON: -*The generated OSIRIS JSON document remains local unless you decide to move, integrate, or share it. **You alone determine how it is used**.* +- **Your infrastructure knowledge belongs to you without paying any fees.** +- **One portable, vendor-neutral snapshot. Multiple use cases.** +- **Automation first. AI when needed.** +- No AI platform, MCP server, or external agent is required. +- No additional SaaS subscription or hosted intermediary is required by OSIRIS. +- OSIRIS JSON Producers operate within an environment you control. +- Credentials and authentication secrets are excluded from generated documents. +- Operational logs provide visibility into discovery, normalization, redaction, validation and emission. + +*Generated OSIRIS JSON documents remain local by default, unless explicitly configured for another destination. **You decide how they are used.*** [Read the OSIRIS JSON Manifesto](https://osirisjson.org/en/commitments/manifesto) --- -### Architecture workflow +## Architecture workflow ```mermaid flowchart TD @@ -79,7 +168,7 @@ flowchart TD P -->|"Generates"| J - J -->|"Validated by"| V + J -->|"Can be validated with"| V J -->|"Consumed by"| C C -->|"Generates"| AD @@ -100,27 +189,19 @@ flowchart TD style UC fill:transparent,stroke:#555,stroke-width:1px,color:inherit ``` ---- - -### Available producers - -| OSIRIS JSON Producer | Category | Status | -|---|---|---| -| **Amazon AWS** | Hyperscaler | [Available](https://docs.osirisjson.org/osiris-producers/hyperscalers/amazon-aws/) | -| **Microsoft Azure** | Hyperscaler | [Available](https://docs.osirisjson.org/osiris-producers/hyperscalers/microsoft-azure/) | -| **Google Cloud** | Hyperscaler | [Under development](https://osirisjson.org/en/commitments/roadmap) | -| **Cloudflare** | Hyperscaler | Planned | -| **HPE Aruba Central** | Network | [Available](https://docs.osirisjson.org/osiris-producers/network/hpe-aruba-networking-central) | -| **Cisco (APIC, NXOS, IOS-XE, SD-WAN Manager formerly vManage)** | Network | [Available](https://docs.osirisjson.org/osiris-producers/network/cisco) | -| **Proxmox VE** | Hypervisor | [Under development](https://osirisjson.org/en/commitments/roadmap) | - -*For the complete roadmap, visit [osirisjson.org/en/commitments/roadmap](https://osirisjson.org/en/commitments/roadmap).* +## Security -### Installation +OSIRIS JSON Producers are designed to exclude credentials and +authentication secrets from generated OSIRIS JSON documents. +Snapshots may still contain sensitive infrastructure information, +including internal addresses, resource identifiers, network topology and +asset names. Review generated documents before sharing them publicly. -See the official guidelines available on [docs.osirisjson.org/osiris-producers/installation](https://docs.osirisjson.org/osiris-producers/installation/) +Additional security resources: +- [The OSIRIS JSON Security Policy](https://osirisjson.org/en/commitments/security) +- [SECURITY.md](SECURITY.md) -### Documentation and contribution +## Documentation and contribution - [OSIRIS JSON Producer Development Guidelines](https://docs.osirisjson.org/developer-guidelines/producers/producer-guidelines/) - [Community & contribution guidelines](https://docs.osirisjson.org/community/contributing/) \ No newline at end of file diff --git a/internal/policies/testdatapolicy/hyperscalers_test.go b/internal/policies/testdatapolicy/hyperscalers_test.go index dce78f1..4194333 100644 --- a/internal/policies/testdatapolicy/hyperscalers_test.go +++ b/internal/policies/testdatapolicy/hyperscalers_test.go @@ -117,7 +117,7 @@ func TestHyperscalerKeysAndScope(t *testing.T) { } // GUIDs outside Azure files and fields are not hyperscaler identities. other := guidOf("11111111", "1111", "1111", "1111", "111111111111") - if got := hyperscalerRules(t, "osiris/network/cisco/vmanage/x_test.go", fmt.Sprintf(`{"uuid": %q}`, other)); len(got) != 0 { + if got := hyperscalerRules(t, "osiris/network/cisco/catalyst-sd-wan-manager/x_test.go", fmt.Sprintf(`{"uuid": %q}`, other)); len(got) != 0 { t.Errorf("unrelated UUID reported: %v", got) } if got := hyperscalerRules(t, "osiris/hyperscalers/azure/x_test.go", fmt.Sprintf(`{"uuid": %q}`, other)); len(got) != 1 { diff --git a/internal/policies/testdatapolicy/inventory.go b/internal/policies/testdatapolicy/inventory.go index 32b339e..8ab3fe6 100644 --- a/internal/policies/testdatapolicy/inventory.go +++ b/internal/policies/testdatapolicy/inventory.go @@ -2,7 +2,8 @@ // scanner. // // The authoritative inventory is the Git index, read with -// "git ls-files -z -s" through exec.CommandContext (no shell). Files +// "git ls-files -z -s" through exec.CommandContext (no shell), with +// git resolved from fixed system directories rather than PATH. Files // are read through an os.Root confined to the repository root, so a // path can never resolve outside it, and symlinks are never followed. // Any enumeration or read failure is returned as an error: the scanner @@ -18,6 +19,8 @@ import ( "io/fs" "os" "os/exec" + "path/filepath" + "runtime" "slices" "strings" ) @@ -136,8 +139,61 @@ func (g *GitSource) ReadFile(path string) ([]byte, error) { return data, nil } +// trustedGitDirs are the only directories git is run from. They are +// fixed system install locations that ordinary users cannot write, +// so the scanner never depends on the caller's PATH: a writable PATH +// entry could otherwise put a different git in front of the real +// one. The same list is the PATH handed to git itself. +var trustedGitDirs = map[string][]string{ + "windows": {`C:\Program Files\Git\cmd`, `C:\Program Files\Git\bin`}, + "darwin": {"/usr/bin", "/usr/local/bin", "/opt/homebrew/bin"}, + "": {"/usr/bin", "/bin", "/usr/local/bin"}, +} + +// gitBinary returns the absolute path of the first git executable +// found in trustedGitDirs for the running OS. Outside Windows a +// candidate that is group or world writable is skipped. +func gitBinary() (path string, dirs []string, err error) { + dirs, ok := trustedGitDirs[runtime.GOOS] + if !ok { + dirs = trustedGitDirs[""] + } + name := "git" + if runtime.GOOS == "windows" { + name = "git.exe" + } + for _, d := range dirs { + p := filepath.Join(d, name) + fi, err := os.Stat(p) + if err != nil || !fi.Mode().IsRegular() { + continue + } + if runtime.GOOS != "windows" && (fi.Mode().Perm()&0o111 == 0 || fi.Mode().Perm()&0o022 != 0) { + continue + } + return p, dirs, nil + } + return "", nil, fmt.Errorf("git not found in %s", strings.Join(dirs, string(filepath.ListSeparator))) +} + +// gitCommand returns a command running the trusted git with args, +// with PATH reduced to the trusted directories. The rest of the +// environment (GIT_INDEX_FILE, HOME) is kept. +func gitCommand(ctx context.Context, args ...string) (*exec.Cmd, error) { + bin, dirs, err := gitBinary() + if err != nil { + return nil, err + } + cmd := exec.CommandContext(ctx, bin, args...) + cmd.Env = append(os.Environ(), "PATH="+strings.Join(dirs, string(filepath.ListSeparator))) + return cmd, nil +} + func runGit(ctx context.Context, dir string, args ...string) ([]byte, error) { - cmd := exec.CommandContext(ctx, "git", append([]string{"-C", dir}, args...)...) + cmd, err := gitCommand(ctx, append([]string{"-C", dir}, args...)...) + if err != nil { + return nil, err + } var stderr bytes.Buffer cmd.Stderr = &stderr out, err := cmd.Output() diff --git a/internal/policies/testdatapolicy/scanner_test.go b/internal/policies/testdatapolicy/scanner_test.go index ad91a38..6fa8512 100644 --- a/internal/policies/testdatapolicy/scanner_test.go +++ b/internal/policies/testdatapolicy/scanner_test.go @@ -14,7 +14,6 @@ import ( "errors" "fmt" "os" - "os/exec" "path/filepath" "slices" "strings" @@ -457,7 +456,10 @@ func TestGitSourceRealRepository(t *testing.T) { } git := func(args ...string) { t.Helper() - cmd := exec.CommandContext(t.Context(), "git", append([]string{"-C", dir}, args...)...) + cmd, err := gitCommand(t.Context(), append([]string{"-C", dir}, args...)...) + if err != nil { + t.Fatal(err) + } if out, err := cmd.CombinedOutput(); err != nil { t.Fatalf("git %v: %v\n%s", args, err, out) } @@ -512,3 +514,33 @@ func TestGitSourceRealRepository(t *testing.T) { t.Errorf("entries with untracked %v, want new.md included", entries) } } + +// TestGitBinaryIsTrusted checks that git is resolved to an absolute +// path inside a trusted directory and that the child PATH holds only +// trusted directories, whatever the caller's PATH is. +func TestGitBinaryIsTrusted(t *testing.T) { + t.Setenv("PATH", t.TempDir()) + bin, dirs, err := gitBinary() + if err != nil { + t.Skip(err) + } + if !filepath.IsAbs(bin) || !slices.Contains(dirs, filepath.Dir(bin)) { + t.Errorf("git = %s, want a file in %v", bin, dirs) + } + cmd, err := gitCommand(t.Context(), "version") + if err != nil { + t.Fatal(err) + } + var path string + for _, kv := range cmd.Environ() { + if v, ok := strings.CutPrefix(kv, "PATH="); ok { + path = v + } + } + if want := strings.Join(dirs, string(filepath.ListSeparator)); path != want { + t.Errorf("child PATH = %q, want %q", path, want) + } + if out, err := cmd.Output(); err != nil || !strings.HasPrefix(string(out), "git version") { + t.Errorf("git version = %q, %v", out, err) + } +} diff --git a/osiris/network/cisco/vmanage/CHANGELOG.md b/osiris/network/cisco/catalyst-sd-wan-manager/CHANGELOG.md similarity index 52% rename from osiris/network/cisco/vmanage/CHANGELOG.md rename to osiris/network/cisco/catalyst-sd-wan-manager/CHANGELOG.md index 0c70568..c62b13c 100644 --- a/osiris/network/cisco/vmanage/CHANGELOG.md +++ b/osiris/network/cisco/catalyst-sd-wan-manager/CHANGELOG.md @@ -1,8 +1,8 @@ -# Changelog - Cisco Catalyst SD-WAN Manager vManage OSIRIS JSON Producer +# Changelog - Cisco Catalyst SD-WAN Manager OSIRIS JSON Producer All notable behavioral changes to the **`osirisjson-producer-cisco`** -producer's vManage (Cisco Catalyst SD-WAN Manager) backend are -documented in this file. +producer's Cisco Catalyst SD-WAN Manager (formerly vManage) backend +are documented in this file. The format follows: - [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). @@ -10,7 +10,7 @@ Producer versioning follows: - [Semantic Versioning](https://semver.org/spec/v2.0.0.html). To maintain a consistent line width across `CHANGELOG.md` and all file -comments (excluding links, code examples, and tables), we adhere to: +comments (excluding links, code examples and tables), we adhere to: - [RFC 7994](https://datatracker.ietf.org/doc/html/rfc7994#section-4.3) This file tracks the **producer's behavior version** @@ -23,53 +23,258 @@ the release-level index of which producers shipped under each tag. ## [Unreleased] -### Added -- Source-to-golden test (`TestGolden`): an in-memory HTTPS vManage - serves synthetic `/dataservice` response bodies for a control-plane - site (Manager, Controller and Validator) and the emitted document is - compared byte for byte with the expected documents at both - `--purpose` levels. `TestGolden_PurposeContract` and - `TestGolden_GraphIntegrity` check the audit-only fields and that - every connection endpoint and group member is an emitted resource. - Emitted documents are unchanged. +## [0.2.0] - 2026-11-21 + +> [!WARNING] +> **Breaking release:** the OSIRIS JSON Producer is renamed from vManage +> to Cisco Catalyst SD-WAN Manager aligning to Cisco re-branding. ### Changed +- **Breaking:** every user-visible and emitted identifier changes there + is no compatibility alias. Regenerate OSIRIS JSON snapshot documents + exports and update any of your workflows that matches on the old + vManage exports strings: + + | Item | Before | Now | + |---|---|---| + | CLI subcommand | `osirisjson-producer cisco vmanage` | `osirisjson-producer cisco sdwan` | + | Go import path | `osiris/network/cisco/vmanage` | `osiris/network/cisco/catalyst-sd-wan-manager` | + | Go package | `vmanage` | `catalystsdwanmanager` | + | `provider.name` | `cisco.vmanage` | `cisco.catalystsdwanmanager` | + | Resource ID prefix | `cisco.vmanage::` | `cisco.catalystsdwanmanager::` | + | Extension namespace | `osiris.cisco.vmanage` | `osiris.cisco.catalystsdwanmanager` | + | `metadata.generator.name` | `osirisjson-producer-cisco-vmanage` | `osirisjson-producer-cisco-catalyst-sdwan-manager` | + | Default output directory | `osirisjson-cisco-vmanage` | `osirisjson-cisco-catalyst-sdwan-manager` | + | Output file name | `cisco-vmanage--.json` | `cisco-catalyst-sdwan-manager--.json` | + | Secrets templates | `cisco-vmanage-secrets*.json` | `cisco-catalyst-sdwan-manager-secrets*.json` | + + Connection IDs derived from resource IDs change accordingly. Cisco + API values are untouched: the `vmanage` device personality still maps + to `osiris.cisco.controller`. Topology content is otherwise unchanged. +- **Breaking:** `--purpose documentation` (the default) now keeps an + explicit field allowlist per OSIRIS JSON section 13.1.3: device + `model`, `manufacturer`, `version`, `site_id`, `health`; interface + `interface_name`, `interface_type`, `admin_status`, `oper_status`, + `speed_mbps`, `vpn_id` and transport `color`; connection `color`. + Addresses, MAC addresses, management IPs, site coordinates, device + groups, connected managers, timestamps, state text, duplex, MTU, + encapsulation, NAT type, quality scores, serial and chassis numbers + move to `--purpose audit` only. Identity, names, descriptions, + connections and group membership are unchanged. Documentation is + minimized, not anonymized. +- `--include-raw-body` no longer attaches unmodified API bodies. Every + row is decoded and redacted recursively (values under sensitive keys + and secret-shaped strings become `[REDACTED]`), rows that are not + valid JSON or exceed 256 KiB are withheld, all rows of one document + are capped at 16 MiB and every withheld row is counted in + `raw_omitted` on its device resource by endpoint and reason. Site + topology rows are matched to their device by Manager device-id or + system IP (including their circuits system IP); a row no device + owns is counted as `unowned` instead of being dropped silently. +- Documents are published privately and atomically: directories this + producer creates are `0700`, documents `0600` regardless of umask, + a document is written to a temporary file and published under its + final name only when complete and an existing file is never + overwritten (the site fails with an explicit error instead). +- Site labels are made safe before use as a path component: control + characters and whitespace become `-` and leading/trailing dots are + trimmed, so a label can never be `.` or `..`. Two sites of one run + whose labels sanitize to the same component get distinct + directories (the later one is suffixed with its site-id). +- **Breaking:** cross-site relationships are kept. OMP sessions and + transport tunnels with one end in another site were silently dropped + from every site document; each site document now carries the remote + endpoints it needs as neighbor resources (extension `site_role: + "neighbor"`): a remote device keeps only its identity, type, name and + provider fields and a remote transport interface its name, color + and `contains` connection. Neighbors are never site group members. + Remote endpoints are resolved against the whole controller inventory, + so a peer outside the selected `--site` list is resolved too; the WAN + interface listing of such a tunnel peer is fetched once + (`neighbor_wan_interface` in coverage), by a pool of 8 workers capped + at `--site-name-rate` requests per second with progress logged every + 25 devices, since a hub site can peer with hundreds of devices; each + lookup counts in the coverage of the site documents that need it. A + neighbor has exactly the ID of the full resource in its own site + document and a relationship carried by several site documents has the + same connection ID, source and target in each, so an OSIRIS JSON + Consumer analyzing and merging the documents by ID obtains one + end-to-end graph. Endpoints that are unknown or ambiguous (a system IP + shared by several devices, a color on several interfaces) are never + guessed and are counted in `metadata["osiris.cisco.catalystsdwanmanager"].graph`. +- **Breaking:** OMP sessions are one bidirectional `network` connection + per device pair, with endpoints in canonical order and extension + `protocol: "omp"`, built from every observation of the pair (the + global OMP link list and each device's peer list, from either end). + The connection ID is protocol-qualified, so every OMP connection ID + changes. `sources` lists which operations reported the session; + disagreeing observed states leave the state unset and are listed in + `observed_states` instead of the first observation winning. + Previously the per-device peer form was emitted `forward` under a + bidirectional ID. +- Tunnels are emitted with endpoints in canonical order, disagreeing + observations are listed in `observed_states`, several colors in + `colors` and a quality score of `0` is no longer dropped. +- **Breaking:** the site group is `logical.site` (was + `physical.room`): the API carries no room, building or rack evidence. + Its members are the site's devices and their interfaces (previously + devices only), its ID is derived from the raw site-id (group IDs + change) and it carries extension `site_id` (or `unsited` for the + bucket of devices without a site-id). Coordinates outside the valid + latitude/longitude ranges are ignored. +- **Breaking:** the device system IP moves from + `properties.management_ip` to extension `system_ip` (audit only): it + is the SD-WAN overlay identifier, not a proven management address. +- Every resource carries `provider.site` (the site name) and + `provider.system` (the Manager host the run collected from). +- **Breaking:** interface reconciliation. Rows of the same interface + name in different VPNs are separate interfaces (previously merged + into one): the lowest VPN keeps the existing ID and every other VPN + gets an `@vpn` suffix. Address-family rows of one interface are + reconciled, keeping a description (or MAC address, status, speed) + that only the IPv6 row carries. A WAN color carried by several + interfaces of one device is ambiguous and no longer attached to the + last one listed. +- An interface address is `public_ip` only when it is globally routable, + shared (RFC 6598), loopback and link-local addresses are `private_ip`. +- `device_groups` and `connected_manager` are sorted and documents do + not depend on Cisco API row order. +- Devices without a native identity (no serial, uuid or deviceId) are + skipped and counted instead of being emitted with an empty ID. +- **Breaking:** run outcome. A run now exits with an error when any + selected site's document could not be built or written (after every + other site is written) previously it succeeded as long as one site + was written. A failed optional API operation leaves its document + partial and the run still succeeds the new `--require-complete` + flag turns any partial document into an error, for CI. +- **Breaking:** `metadata.scope.accounts` is no longer populated and + `GET /dataservice/tenant` is no longer called: the tenants a + credential can see are not the accounts the run collected from. +- Collection runs every selected site before any document is built, + through an injectable API interface and optional operations are + independent: a failed interface listing for a device no longer + skips that device's WAN interfaces and OMP peers. +- Every document carries a discovery coverage record in + `metadata["osiris.cisco.catalystsdwanmanager"]`: per operation its + status (`succeeded`, `empty`, `partial`, `failed`, `skipped`), + attempts, row count and failure categories (`denied`, `not_found`, + `rate_limited`, `server_error`, `http_error`, `malformed`, + `too_large`, `redirect`, `timeout`, `canceled`, `transport`), plus + `complete` and `api_profile`. `api_profile` is `unverified`: the + Manager release is not discovered and the reply shapes documented + for 20.18, 26.1 and 26.2 are all accepted. +- Every document of one run carries the same `metadata.timestamp` + and file-name timestamp. - `--secrets-file` now loads through the shared `osiris/network/cisco/run` credential-file loader (also used by - apic/iosxe/nxos's `--secrets-file`), which rejects symlinks, - group/other permission bits, and files not owned by the invoking + apic/iosxe/nxos `--secrets-file`), which rejects symlinks, + group/other permission bits and files not owned by the invoking user. Previously loaded via a local, unchecked `os.ReadFile` + `json.Unmarshal` pair with none of those guarantees. -- `template --generate`'s file-writing now goes through the same - shared helper apic/iosxe/nxos use (`run.WriteTemplateFile`); the - written file (`cisco-vmanage-secrets.json`) and its `{host, username, - password}` shape are unchanged. -- `--secrets-file` now also accepts the "rules" shape apic/iosxe/nxos's - for multi-host targets. vManage has exactly one target host per +- `template --generate`'s file-writing now goes through the same shared + helper apic/iosxe/nxos use (`run.WriteTemplateFile`); the written file + (`cisco-catalyst-sdwan-manager-secrets.json`) and its `{host, username, password}` + shape are unchanged. +- `--secrets-file` now also accepts the "rules" shape apic/iosxe/nxos + for multi-host targets. SD-WAN Manager has exactly one target host per run, so this is most useful for reusing one `--secrets-file` across multiple controllers (matched by host/CIDR) rather than for a per-target batch, but the resolution logic and the file shape is now identical to every other Cisco producer. +### Added +- `--require-complete` (see Changed). +- Per-release API contract fixtures for SD-WAN Manager API 20.18, 26.1 + and 26.2 (`testdata/.../contract_`): every endpoint answered + with the keys of that release's documented example response and + synthetic values; the contract test requires the same complete graph + for all three releases. +- Source-to-golden test (`TestGolden`): an in-memory HTTPS SD-WAN + Manager serves synthetic `/dataservice` response bodies for a + control-plane site (Manager, Controller and Validator) and the emitted + document is compared byte for byte with the expected documents at both + `--purpose` levels. `TestGolden_PurposeContract` and + `TestGolden_GraphIntegrity` check the audit-only fields and that + every connection endpoint and group member is an emitted resource. + Emitted documents are unchanged. + ### Fixed +- A `200` reply that is empty, carries an error object or lacks the + documented `data` member is reported as `malformed` or + `server_error` instead of being read as an empty listing. +- Inventory `lastupdated` and `uptime-date` are accepted as numbers or + numeric strings (the published schema types them as strings and its + example as integers); previously a string value failed the whole + inventory and aborted the run. +- Response bodies are capped at 64 MiB, `Retry-After` waits are + capped at 8 seconds and Ctrl-C cancels in-flight requests and + retry waits. +- The per-request timeout is 60 seconds (was 15): the site topology + monitor of a large site could time out and leave its document + without tunnels. A read that times out or answers HTTP 5xx is + retried once with backoff, denials, missing endpoints and malformed + replies are never retried. +- An expired Manager session (HTTP 401, or the login page re-served + with HTTP 200) is renewed with one new login per run and the request + retried; concurrent requests share that renewal. A session that + cannot be renewed is reported as `denied` and the login page is + never read as an empty or malformed listing. +- A positional argument is now rejected instead of silently ending + flag parsing. Previously a stray value such as + `--include-raw-body true` made every later flag, including + `--site`, be ignored, so the run fell back to the interactive site + picker and resolved the name of every site on the controller. Use + boolean flags bare (`--include-raw-body`) or as `--flag=false`. - Every documentation-only example host across this producer (CLI help - text, doc comments, the generated `cisco-vmanage-secrets.json` - template, and test fixtures) changed from `acme.sdwan.cisco.com` to - `vmanage.example.com` the former was not an RFC 2606 reserved + text, doc comments, the generated `cisco-catalyst-sdwan-manager-secrets.json` + template and test fixtures) changed from `acme.sdwan.cisco.com` to + `sdwan-manager.example.com` the former was not an RFC 2606 reserved domain and could collide with a real registered domain; the latter uses the `example.com` domain RFC 2606 reserves for exactly this purpose. No behavioral change. - `template --generate` now also writes - `cisco-vmanage-secrets-multihost.json` (the rules shape) alongside - the existing `cisco-vmanage-secrets.json` (the flat single host shape)+ - each carrying its own explanatory `"$comment"` field. - Unlike apic/iosxe/nxos (whose example "hosts" patterns are RFC 5737 - CIDR/exact-IP blocks), vmanage's `cisco-vmanage-secrets-multihost.json` - uses two example RFC 2606 FQDNs (`vmanage01.example.com`, - `vmanage02.example.com`), matching how vmanage targets are actually - addressed a controller hostname, not a bare IP. - Both example files use the same plain - `user`/`changeme` credential placeholders everywhere. + `cisco-catalyst-sdwan-manager-secrets-multihost.json` (the rules + shape) alongside `cisco-catalyst-sdwan-manager-secrets.json` (the + flat single-host shape), each carrying its own explanatory + `"$comment"` field. Unlike apic/iosxe/nxos (whose example "hosts" + patterns are RFC 5737 CIDR/exact-IP blocks), the multi-host file + uses two example RFC 2606 FQDNs (`sdwan-manager01.example.com`, + `sdwan-manager02.example.com`), matching how SD-WAN Manager targets + are actually addressed: a controller hostname, not a bare IP. Both + example files use the same plain `user`/`changeme` credential + placeholders. + +### Security +- `--safe-failure-mode log-and-redact` and `off` now replace every + detected secret in names, descriptions, properties and extensions + before the document is built; previously `log-and-redact` only + logged findings and marked the document redacted while leaving the + values in place. `log-and-redact` also refuses to write a document + in which any finding remains. `fail-closed` (default) is unchanged. +- Error messages and logs no longer include HTTP response bodies + (which can carry credentials or tokens), request query parameters + or request URLs; they report the endpoint path and HTTP status only. +- Redirects are followed only within the controller origin (`https`, + same host and port, at most 5). A redirect to any other origin is + refused, so the login form and the `X-XSRF-TOKEN` header can never + be sent elsewhere. + +### Known limitations +- The Cisco SD-WAN Manager release is not discovered; documents are + labelled `api_profile: "unverified"` and the reply shapes documented + for 20.18, 26.1 and 26.2 are all accepted. Exact patch-level behavior + is not certified. +- Sessions are not logged out at the end of a run (the session is + renewed at most once if it expires) and JWT authentication is not + supported. +- Interface IPv6 addresses are not emitted; IPv6 rows only complete + fields their IPv4 row lacks. +- Tunnel endpoints are resolved by system IP and color only; two + interfaces of one device on the same color, or parallel tunnels + that differ only by encapsulation, stay unresolved or merged. +- Only IPv4 system IPs are recognized in tunnel names. +- A neighbor device from a site outside the run carries no + `provider.site` (its name is unknown); its `site_id` extension is set. ## [0.1.0] - 2026-08-09 @@ -91,7 +296,7 @@ Initial Cisco vManage producer release. `manufacturer` (constant `"Cisco"`, vManage only manages Cisco/Viptela hardware), `model`, `version`, `management_ip` (the device's system-ip, no separate `ip_addresses` object since it would - just duplicate this single value), and, `audit` purpose only, + just duplicate this single value) and, `audit` purpose only, `serial_number` (`board-serial`). `routing_protocol` is not included (no vManage endpoint reports it without new per-device BGP/OSPF calls). `provider.site`/`provider.version` are not set 7.5.2's own @@ -216,7 +421,7 @@ Initial Cisco vManage producer release. owning device resource under `extensions["osiris.cisco.vmanage"]` the device's own `GET /dataservice/device` object (`raw`), `interfaces_raw`, `wan_interfaces_raw` (when non-empty), - `omp_peers_raw`, and `site_topology_raw` (matched back to the device + `omp_peers_raw` and `site_topology_raw` (matched back to the device by vManage's own device-id) a lossless fallback for fields not yet modeled by this producer. - Best-effort tenant listing (`GET /dataservice/tenant`) feeds @@ -244,7 +449,7 @@ Initial Cisco vManage producer release. `GET /dataservice/topology/device/site/{siteId}` (`site_name` field the spec itself documents no fields for this endpoint): shown as a "Site name" column (No / Site name / Devices) in the interactive - picker, and used in `metadata.scope.sites` for the emitted document + picker and used in `metadata.scope.sites` for the emitted document (falls back to the numeric site-id if the lookup fails or the credential lacks access best-effort, never blocks collection). Resolved with a bounded concurrent worker pool (8 at a time) and @@ -265,7 +470,7 @@ Initial Cisco vManage producer release. `speed-mbps` fields decode via a type tolerant of both a quoted string and a bare JSON number some controllers return `speed-mbps` as a number, not the quoted string the vManage OpenAPI spec's own - example documents, and Go's default JSON decoding into a + example documents and Go's default JSON decoding into a string-typed field would reject that outright, failing the *entire* interface response's unmarshal. HTTP 429 (Too Many Requests) responses are retried with backoff (honoring a `Retry-After` header @@ -305,4 +510,5 @@ Initial Cisco vManage producer release. extra per-device calls did not add new modeled fields. [Unreleased]: ../../../../CHANGELOG.md +[0.2.0]: ../../../../CHANGELOG.md#0130---2026-11-21 [0.1.0]: ../../../../CHANGELOG.md#070---2026-08-29 diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/apierror.go b/osiris/network/cisco/catalyst-sd-wan-manager/apierror.go new file mode 100644 index 0000000..ab3cd0c --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/apierror.go @@ -0,0 +1,116 @@ +// apierror.go - Classified API errors for the Cisco Catalyst SD-WAN +// Manager OSIRIS JSON Producer. +// +// Every failed request or decode is an apiError carrying the endpoint +// path (never its query string), the HTTP status when there was one, +// and a fixed failure category. The category drives the discovery +// coverage record (coverage.go) and lets an OSIRIS JSON consumer tell a +// permission gap from an unsupported endpoint, a malformed reply or a +// transport problem. Categories are fixed labels and never carry +// response or transport text: +// +// denied HTTP 401 or 403 +// not_found HTTP 404 (the endpoint or object does not exist on +// this Manager release) +// rate_limited HTTP 429 after the bounded retries +// server_error HTTP 5xx, or a 200 reply carrying an error object +// http_error any other non-200 status +// malformed a 200 reply that is not the documented shape +// too_large a reply larger than maxResponseBytes +// redirect a redirect refused by the origin policy +// timeout the per-request timeout expired +// canceled the run job was canceled (for example Ctrl-C) +// transport any other connection or TLS failure +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "context" + "errors" + "fmt" + "net" + "net/http" +) + +// Failure categories, see the file comment. +const ( + categoryDenied = "denied" + categoryNotFound = "not_found" + categoryRateLimited = "rate_limited" + categoryServerError = "server_error" + categoryHTTPError = "http_error" + categoryMalformed = "malformed" + categoryTooLarge = "too_large" + categoryRedirect = "redirect" + categoryTimeout = "timeout" + categoryCanceled = "canceled" + categoryTransport = "transport" +) + +// apiError is a classified failure of one API operation. +type apiError struct { + Op string // endpoint path without query string. + Status int // HTTP status, 0 when no response was received. + Category string + Err error // underlying cause, never response content. +} + +func (e *apiError) Error() string { + if e.Status != 0 && e.Category != categoryMalformed && e.Category != categoryTooLarge { + return fmt.Sprintf("SD-WAN Manager %s failed (HTTP %d)", e.Op, e.Status) + } + if e.Err != nil { + return fmt.Sprintf("SD-WAN Manager %s: %s: %v", e.Op, e.Category, e.Err) + } + return fmt.Sprintf("SD-WAN Manager %s: %s", e.Op, e.Category) +} + +func (e *apiError) Unwrap() error { return e.Err } + +// statusCategory maps a non-200 HTTP status to its category. +func statusCategory(status int) string { + switch { + case status == http.StatusUnauthorized || status == http.StatusForbidden: + return categoryDenied + case status == http.StatusNotFound: + return categoryNotFound + case status == http.StatusTooManyRequests: + return categoryRateLimited + case status >= 500: + return categoryServerError + } + return categoryHTTPError +} + +// transportError classifies an error from http.Client.Do or a body +// read, with the request URL already stripped by transportCause. +func transportError(op string, err error) *apiError { + cause := transportCause(err) + cat := categoryTransport + var ne net.Error + switch { + case errors.Is(err, context.Canceled): + cat = categoryCanceled + case errors.Is(err, context.DeadlineExceeded), errors.As(err, &ne) && ne.Timeout(): + cat = categoryTimeout + case errors.Is(err, errCrossOriginRedirect), errors.Is(err, errTooManyRedirects): + cat = categoryRedirect + } + return &apiError{Op: op, Category: cat, Err: cause} +} + +// failureCategory returns the category of err, categoryTransport for an +// unclassified error. +func failureCategory(err error) string { + var ae *apiError + if errors.As(err, &ae) { + return ae.Category + } + if errors.Is(err, context.Canceled) { + return categoryCanceled + } + return categoryTransport +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/catalystsdwanmanager.go b/osiris/network/cisco/catalyst-sd-wan-manager/catalystsdwanmanager.go new file mode 100644 index 0000000..31399e6 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/catalystsdwanmanager.go @@ -0,0 +1,255 @@ +// Package catalystsdwanmanager implements the Cisco Catalyst SD-WAN +// Manager OSIRIS JSON Producer. +// +// A single SD-WAN Manager login fans out into one document per +// selected site (logical.site group of the devices sharing a site-id). +// Each document also carries neighbor stubs for the devices and +// transport interfaces of other sites that its tunnels and OMP +// sessions reach, with the same IDs in every document, so an OSIRIS +// JSON consumer merges the per-site documents by ID. It is dispatched +// directly by osiris/network/cisco/cisco.go's Run function. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "context" + "fmt" + "log/slog" + "os" + "os/signal" + "path/filepath" + "strings" + "time" + + "go.osirisjson.org/producers/osiris/network/cisco/run" + "go.osirisjson.org/producers/pkg/sdk" +) + +const ( + generatorName = "osirisjson-producer-cisco-catalyst-sdwan-manager" + generatorVersion = "0.2.0" + generatorURL = "https://docs.osirisjson.org/osiris-producers/network/cisco" +) + +// Run is the CLI entry point for the SD-WAN Manager producer. +// It receives the arguments after "catalyst-sdwan-manager". +func Run(args []string) error { + // Only the long form is checked here: -h is the documented short + // flag for --host (see flags.go), so it must reach ParseFlags + // instead of being intercepted as a help request. This mirrors + // osiris/network/cisco/cisco.go's runSubProducer, which has the + // same -h/--host vs. -h/help ambiguity for apic/nxos/iosxe. + if len(args) > 0 { + switch args[0] { + case "--help": + printHelp() + return nil + case "template": + return runTemplate(args[1:]) + } + } + + cfg, err := ParseFlags(args, promptVisible, run.PromptPassword) + if err != nil { + return err + } + + return runExport(cfg) +} + +// runTemplate writes both --secrets-file shapes, flat +// (cisco-catalyst-sdwan-manager-secrets.json) and multi-host +// (cisco-catalyst-sdwan-manager-secrets-multihost.json) via the shared +// run.WriteTemplateFile SD-WAN Manager has no CSV batch mode, so unlike +// apic/iosxe/nxos it does not call run.GenerateTemplates only the two +// --secrets-file variants apply here, not a CSV template. +func runTemplate(args []string) error { + if len(args) == 0 || (args[0] != "--generate" && args[0] != "-g") { + fmt.Println("Usage: osirisjson-producer cisco sdwan template --generate") + return nil + } + if err := run.WriteTemplateFile("cisco-catalyst-sdwan-manager-secrets.json", run.CredentialFileTemplate("sdwan-manager.example.com")); err != nil { + return err + } + return run.WriteTemplateFile("cisco-catalyst-sdwan-manager-secrets-multihost.json", run.CredentialRulesFileTemplate("sdwan-manager01.example.com", "sdwan-manager02.example.com")) +} + +// runExport authenticates once against the controller, collects the +// device inventory and every selected site (collect.go), then builds +// and publishes one OSIRIS JSON document per site (document.go, +// output.go). Every document of a run carries the same timestamp. +// +// Outcome contract: +// +// - authentication, inventory or site selection failure: error. +// - any selected site whose document could not be built or written: +// error, after every other site has been written. +// - an optional operation failed (recorded in each affected +// document's coverage): success, unless --require-complete is set. +func runExport(cfg *Config) error { + logger := defaultLogger() + + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt) + defer stop() + + client := NewClient(cfg, logger) + client.ctx = ctx + return export(client, cfg, logger, time.Now().UTC()) +} + +// export is runExport after client construction: login when the API is +// a *Client, collect, build and publish. now is the run timestamp. +func export(api managerAPI, cfg *Config, logger *slog.Logger, now time.Time) error { + if c, ok := api.(*Client); ok { + if err := c.Login(cfg.Username, cfg.Password); err != nil { + return fmt.Errorf("SD-WAN Manager authentication failed: %w", err) + } + } + + col, err := collect(api, cfg, logger) + if err != nil { + return err + } + + outputDir := cfg.OutputDir + if abs, err := filepath.Abs(outputDir); err == nil { + outputDir = abs + } + timestamp := run.FormatTimestamp(now) + + var succeeded int + var failures, incomplete []string + var segments siteSegments + for _, s := range col.sites { + label := siteLabel(s.id, s.name) + log := logger.With("site_id", s.id, "site", label) + + doc, err := buildSiteDocument(col, s, cfg, now, log) + var data []byte + if err == nil { + data, err = sdk.MarshalDocument(doc) + } + if err != nil { + log.Error("document build failed (continuing with remaining sites)", "err", err) + failures = append(failures, fmt.Sprintf("%s: %v", label, err)) + continue + } + + // outPath is keyed by site name, not site-id (see OutputPath): + // an existing directory under this name is reused and the new + // timestamped file is added alongside whatever is already + // there. writeDocument publishes privately and atomically and + // never overwrites an existing file (see output.go). + outPath := OutputPath(outputDir, timestamp, segments.segment(s.id, s.name)) + if err := writeDocument(outputDir, outPath, data); err != nil { + log.Error("write failed (continuing with remaining sites)", "err", err, "path", outPath) + failures = append(failures, fmt.Sprintf("%s: %v", label, err)) + continue + } + fmt.Fprintf(os.Stderr, "Saved to %s\n", outPath) + succeeded++ + + if cov := col.siteCoverage(s); !cov.complete() { + log.Warn("document is partial", "gaps", strings.Join(cov.gaps(), "; ")) + incomplete = append(incomplete, label) + } + } + + if len(failures) > 0 { + return fmt.Errorf("%d of %d site(s) not written: %s", len(failures), len(col.sites), strings.Join(failures, "; ")) + } + if len(incomplete) > 0 { + if cfg.RequireComplete { + return fmt.Errorf("--require-complete: %d of %d document(s) partial: %s", len(incomplete), len(col.sites), strings.Join(incomplete, ", ")) + } + logger.Warn("export complete with partial documents", "written", succeeded, "partial", len(incomplete), "output_dir", outputDir) + return nil + } + logger.Info("export complete", "succeeded", succeeded, "output_dir", outputDir) + return nil +} + +// siteLabel returns a human-readable label for a site, matching the +// resolved name OutputPath used for this site's directory segment +// (siteName) when available, falling back to the raw site-id and then +// to the unclaimed segment name. +func siteLabel(siteID, siteName string) string { + if siteName != "" { + return siteName + } + if siteID == "" { + return unsitedSegment + } + return siteID +} + +func defaultLogger() *slog.Logger { + return slog.New(slog.NewTextHandler(os.Stderr, nil)) +} + +func printHelp() { + fmt.Print(`osirisjson-producer cisco sdwan - Cisco Catalyst SD-WAN Manager OSIRIS JSON producer + +Usage: + osirisjson-producer cisco sdwan [flags] + +Site selection: when neither --site nor --all is given, the sites +discovered on the controller are listed interactively (pick by number, +e.g. "1,3,5" or "1-4" or "all"). Use --all (or --site all, an alias) +for non-interactive runs (cron/CI), it does not wait on a bulk +site-name resolution pass. --site also accepts either the raw numeric +site-id (matches instantly without waiting for name resolution) or the +resolved site name (e.g. --site MXP); a name that doesn't match any raw +site-id triggers a full site-name resolution pass to find it, since the +SD-WAN Manager API this producer uses has no lookup of a site-id by +name. + +Bulk site-name resolution (only triggered by the interactive picker or +a --site value that falls back to name matching) is capped at +--site-name-rate (default 10/s) since SD-WAN Manager's own rate limit is +typically shared across many tools frequently polling same controller +(monitoring systems, other automation, not just this producer). Raise +or lower it based on how much headroom your environment actually has, +from 1 (very conservative) up to your controller's full observed limit. + +Authentication: there is deliberately no -p/--password flag, CLI flag +values are visible to any local user (e.g. via ps) and get written to +shell history. host/username/password are each resolved in this order: +their own -h/-u flag, then --secrets-file, then (for whichever is still +missing) an interactive prompt on the controlling terminal so a bare +"osirisjson-producer cisco sdwan" with no flags at all asks for +host, username and password one at a time, and nothing entered there +is written to disk unless --secrets-file was also given. + +Collection and outcome: every selected site is collected first, then +one document per site is written with the run's single timestamp. +Each document records the API operations behind it in +metadata["osiris.cisco.catalystsdwanmanager"] (status, attempts, rows +and failure categories such as denied or malformed, plus "complete"). +The run exits with an error when authentication, the device inventory +or site selection fails, or when any selected site's document could +not be built or written. A failed optional operation leaves its +document partial but the run succeeds, unless --require-complete is +given. + +Flags: +`) + fmt.Print(FlagsUsage()) + fmt.Print(` +Other commands: + template --generate Write --secrets-file skeletons: cisco-catalyst-sdwan-manager-secrets.json + (single host) and cisco-catalyst-sdwan-manager-secrets-multihost.json + (per-host/CIDR rules) + +Examples: + osirisjson-producer cisco sdwan + osirisjson-producer cisco sdwan -h sdwan-manager.example.com -u admin + osirisjson-producer cisco sdwan --secrets-file ./cisco-catalyst-sdwan-manager-secrets.json + osirisjson-producer cisco sdwan --secrets-file ./cisco-catalyst-sdwan-manager-secrets.json --purpose audit --site "MXP,Branch-1" + osirisjson-producer cisco sdwan --secrets-file ./cisco-catalyst-sdwan-manager-secrets.json --all -o ./output + osirisjson-producer cisco sdwan template --generate +`) +} diff --git a/osiris/network/cisco/vmanage/vmanage_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/catalystsdwanmanager_test.go similarity index 86% rename from osiris/network/cisco/vmanage/vmanage_test.go rename to osiris/network/cisco/catalyst-sd-wan-manager/catalystsdwanmanager_test.go index e84535b..f1db8f2 100644 --- a/osiris/network/cisco/vmanage/vmanage_test.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/catalystsdwanmanager_test.go @@ -1,12 +1,12 @@ -// vmanage_test.go - Integration tests for the vManage producer's -// end-to-end export: login, device fetch, per-site document split and -// file layout. +// catalystsdwanmanager_test.go - Integration tests for the Cisco +// Catalyst SD-WAN Manager OSIRIS JSON Producer end-to-end export: login +// device fetch, per-site document split and file layout. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import ( "encoding/json" @@ -30,11 +30,11 @@ var fixtureSiteNames = map[string]string{ "200": "TEST-SITE-TWO", } -// fixtureHandler serves canned vManage responses: two WAN edge sites -// plus one unclaimed device, one tenant. +// fixtureHandler serves canned SD-WAN Manager responses: two WAN edge +// sites plus one unclaimed device, one tenant. func fixtureHandler(w http.ResponseWriter, r *http.Request) { devicesJSON := `[ - {"deviceId":"192.0.2.1","system-ip":"192.0.2.1","host-name":"TEST-VMANAGE1","uuid":"11111111-1111-1111-1111-111111111111","site-id":"100","personality":"vmanage","device-type":"vmanage","device-model":"vmanage","reachability":"reachable","status":"normal","validity":"valid","version":"20.9.1","platform":"x86_64"}, + {"deviceId":"192.0.2.1","system-ip":"192.0.2.1","host-name":"TEST-SDWANMGR1","uuid":"11111111-1111-1111-1111-111111111111","site-id":"100","personality":"vmanage","device-type":"vmanage","device-model":"vmanage","reachability":"reachable","status":"normal","validity":"valid","version":"20.9.1","platform":"x86_64"}, {"deviceId":"192.0.2.10","system-ip":"192.0.2.10","host-name":"TEST-CEDGE1","uuid":"22222222-2222-2222-2222-222222222222","site-id":"200","personality":"cedge","device-type":"cedge","device-model":"C8000v","reachability":"reachable","status":"normal","validity":"valid","version":"17.09.01","platform":"x86_64"}, {"deviceId":"192.0.2.20","system-ip":"192.0.2.20","host-name":"TEST-VEDGE-UNSITED","uuid":"33333333-3333-3333-3333-333333333333","site-id":"","personality":"vedge","device-type":"vedge","device-model":"vedge-cloud","reachability":"reachable","status":"normal","validity":"valid","version":"20.9.1","platform":"x86_64"} ]` @@ -157,7 +157,10 @@ func TestRunExport_EndToEnd(t *testing.T) { } } -func TestRunExport_AccountsPopulatedFromTenants(t *testing.T) { +// TestRunExport_VisibleTenantsAreNotCollectedAccounts proves tenants +// the credential can see never populate metadata.scope.accounts: they +// are not the accounts the run collected from. +func TestRunExport_VisibleTenantsAreNotCollectedAccounts(t *testing.T) { ts := httptest.NewTLSServer(http.HandlerFunc(fixtureHandler)) defer ts.Close() @@ -172,7 +175,7 @@ func TestRunExport_AccountsPopulatedFromTenants(t *testing.T) { Purpose: "documentation", InsecureTLS: true, AllSites: true, // avoid the interactive picker reading os.Stdin in tests. - SiteNameRateLimit: 1000, // fast, deterministic tests - not exercising throttling here. + SiteNameRateLimit: 1000, // fast, deterministic tests not exercising throttling here. } if err := runExport(cfg); err != nil { @@ -195,15 +198,13 @@ func TestRunExport_AccountsPopulatedFromTenants(t *testing.T) { if doc.Metadata.Scope == nil { return nil } - for _, a := range doc.Metadata.Scope.Accounts { - if a == "TEST-TENANT-1" { - found = true - } + if len(doc.Metadata.Scope.Accounts) > 0 { + found = true } return nil }) - if !found { - t.Error("expected metadata.scope.accounts to contain the fixture tenant label") + if found { + t.Error("metadata.scope.accounts must not be populated from visible tenants") } } @@ -231,12 +232,13 @@ func fixtureHandlerWithRawBody(w http.ResponseWriter, r *http.Request) { } } -// TestRunExport_IncludeRawBody confirms --include-raw-body (only -// active under --purpose audit, see wantRawBody in vmanage.go) attaches -// each collected endpoint's raw JSON response to the owning device -// resource under extensions["osiris.cisco.vmanage"], and that nothing -// is attached when either --purpose isn't audit or --include-raw-body -// is off - the two-flag gate documented on Config.IncludeRawBody. +// TestRunExport_IncludeRawBody confirms --include-raw-body (only active +// under --purpose audit, see wantRawBody in catalystsdwanmanager.go) +// attaches each collected endpoint's raw JSON response to the owning +// device resource under +// extensions["osiris.cisco.catalystsdwanmanager"], and that nothing is +// attached when either --purpose isn't audit or --include-raw-body is +// off the two-flag gate documented on Config.IncludeRawBody. func TestRunExport_IncludeRawBody(t *testing.T) { ts := httptest.NewTLSServer(http.HandlerFunc(fixtureHandlerWithRawBody)) defer ts.Close() @@ -287,18 +289,19 @@ func TestRunExport_IncludeRawBody(t *testing.T) { r := findSite200Resource(t, cfg.OutputDir) ext, _ := r.Extensions[extensionKey].(map[string]any) if ext == nil { - t.Fatal("expected extensions[osiris.cisco.vmanage] to be set") + t.Fatal("expected extensions[osiris.cisco.catalystsdwanmanager] to be set") } for _, key := range []string{"raw", "interfaces_raw", "omp_peers_raw", "site_topology_raw"} { if _, ok := ext[key]; !ok { - t.Errorf("expected extensions[osiris.cisco.vmanage][%q] to be set", key) + t.Errorf("expected extensions[osiris.cisco.catalystsdwanmanager][%q] to be set", key) } } - // wan_interfaces_raw is deliberately absent: the fixture returns - // an empty WAN interface list for this device, and setExtension - // is only called for a non-empty slice (see vmanage.go). + // wan_interfaces_raw is deliberately absent: the fixture + // returns an empty WAN interface list for this device, and + // setExtension is only called for a non-empty slice (see + // catalystsdwanmanager.go). if _, ok := ext["wan_interfaces_raw"]; ok { - t.Error("expected extensions[osiris.cisco.vmanage][wan_interfaces_raw] to be absent for an empty WAN interface list") + t.Error("expected extensions[osiris.cisco.catalystsdwanmanager][wan_interfaces_raw] to be absent for an empty WAN interface list") } }) @@ -393,7 +396,7 @@ func TestRunExport_DeviceFetchFailureIsFatal(t *testing.T) { // terminal being available to satisfy the interactive prompt fallback. func TestRun_ShortHostFlagNotMistakenForHelp(t *testing.T) { dir := t.TempDir() - secretsFile := filepath.Join(dir, "cisco-vmanage-secrets.json") + secretsFile := filepath.Join(dir, "cisco-catalyst-sdwan-manager-secrets.json") if err := os.WriteFile(secretsFile, []byte(`{"password":"changeme"}`), 0600); err != nil { t.Fatalf("writing token file: %v", err) } diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/client.go b/osiris/network/cisco/catalyst-sd-wan-manager/client.go new file mode 100644 index 0000000..c2d76e0 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/client.go @@ -0,0 +1,933 @@ +// client.go - SD-WAN Manager REST API client for the Cisco SD-WAN +// Manager OSIRIS JSON Producer. +// +// Authentication is the standard SD-WAN Manager session-cookie + XSRF +// flow: POST /j_security_check (form-encoded username/password) +// establishes a JSESSIONID session cookie (handled automatically by the +// cookie jar from run.NewHTTPClient), then GET +// /dataservice/client/token mints an XSRF token that must be sent as +// the X-XSRF-TOKEN header on every subsequent /dataservice call. +// /j_security_check is a servlet outside /dataservice and is not part +// of the SD-WAN Manager OpenAPI spec, so its failure heuristic (an HTML +// login page being re-served) follows the commonly documented SD-WAN +// Manager automation pattern rather than a spec definition. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification + +package catalystsdwanmanager + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "log/slog" + "net/http" + "net/url" + "strconv" + "strings" + "sync" + "time" + + "go.osirisjson.org/producers/osiris/network/cisco/run" +) + +// requestTimeout bounds every HTTP call this client makes, so a slow or +// silently dropped request cannot hang the run. run.NewHTTPClient sets +// no timeout (shared by apic/nxos/iosxe too), so it is applied here, +// scoped to SD-WAN Manager only. 60 seconds leaves room for the +// per-site monitoring endpoints of large sites, which can take well +// over 15 seconds to answer. +const requestTimeout = 60 * time.Second + +// maxTransientRetries is how many times a read request is retried after +// a timeout or an HTTP 5xx reply, with backoff from baseRetryDelay. +// Permission denials and malformed replies are never retried. +const maxTransientRetries = 1 + +// maxReauthentications bounds how many times one run logs in again +// after the Manager session expired (see reauthenticate). +const maxReauthentications = 1 + +// errSessionExpired marks a request rejected because the session ended +// and could not be renewed. +var errSessionExpired = errors.New("session expired") + +// maxResponseBytes bounds every response body read into memory (64 +// MiB). A larger reply is reported as too_large instead of being +// buffered without limit. A variable only so tests can lower it. +var maxResponseBytes = 64 << 20 + +// errResponseTooLarge reports a body over maxResponseBytes. +var errResponseTooLarge = errors.New("response exceeds the size limit") + +// readBounded reads at most maxResponseBytes from r. +func readBounded(r io.Reader) ([]byte, error) { + body, err := io.ReadAll(io.LimitReader(r, int64(maxResponseBytes)+1)) + if err != nil { + return nil, err + } + if len(body) > maxResponseBytes { + return nil, errResponseTooLarge + } + return body, nil +} + +// Client is a thin HTTP client for the SD-WAN Manager dataservice REST +// API. +type Client struct { + baseURL string + httpClient *http.Client + logger *slog.Logger + + // authMu guards the session state below, shared by concurrent + // site-name lookups. authGen counts logins, so concurrent requests + // that all saw an expired session renew it only once. + authMu sync.Mutex + xsrfToken string + authGen int + reauths int + username string + password string + + // ctx cancels every request and retry wait of this client (for + // example on Ctrl-C); nil means context.Background(). + ctx context.Context + + // siteNameMu/siteNameLastRequest/siteNameMinInterval throttle + // GetSiteName specifically (bulk site-name resolution in + // sites_select.go issues one call per discovered site across a + // worker pool concurrency alone does not bound requests/second). + // Every other endpoint on this client is unthrottled. + siteNameMu sync.Mutex + siteNameLastRequest time.Time + siteNameMinInterval time.Duration +} + +// Device is the subset of the GET /dataservice/device response fields +// (tag "Monitoring - Device Details") this producer maps to OSIRIS +// resources. Field names and shapes are taken verbatim from the +// SD-WAN Manager OpenAPI spec's documented example for this endpoint. +// +// Latitude/Longitude are typed any because the spec's own example +// mixes a string latitude ("37.666684") with a numeric longitude +// (-122.777023) for the same object. +// +// LastUpdated/UptimeDate are epoch milliseconds; the published schema +// types them as strings while the published example uses integers, so +// both are accepted (see flexInt64). +// +// HealthState ("state") is the dashboard health rollup +// (green/red/yellow), distinct from Reachability and Status. +type Device struct { + DeviceID string `json:"deviceId"` + SystemIP string `json:"system-ip"` + HostName string `json:"host-name"` + UUID string `json:"uuid"` + SiteID string `json:"site-id"` + Personality string `json:"personality"` + DeviceType string `json:"device-type"` + DeviceModel string `json:"device-model"` + Reachability string `json:"reachability"` + Status string `json:"status"` + Validity string `json:"validity"` + Version string `json:"version"` + Platform string `json:"platform"` + BoardSerial string `json:"board-serial"` + CertificateValidity string `json:"certificate-validity"` + DeviceGroups []string `json:"device-groups"` + Latitude any `json:"latitude"` + Longitude any `json:"longitude"` + LastUpdated flexInt64 `json:"lastupdated"` + HealthState string `json:"state"` + StateDescription string `json:"state_description"` + UptimeDate flexInt64 `json:"uptime-date"` + ConnectedManagers []string `json:"connectedVManages"` // API field name keeps still the Cisco vManage pre-rebrand spelling. +} + +// NewClient creates an SD-WAN Manager client targeting the given +// controller. +func NewClient(cfg *Config, logger *slog.Logger) *Client { + addr := cfg.Host + if strings.Contains(addr, ":") { + addr = "[" + addr + "]" + } + baseURL := fmt.Sprintf("https://%s:%d", addr, cfg.Port) + httpClient := run.NewHTTPClient(cfg.InsecureTLS) + httpClient.Timeout = requestTimeout + if origin, err := url.Parse(baseURL); err == nil { + httpClient.CheckRedirect = sameOriginRedirect(origin) + } + return &Client{ + baseURL: baseURL, + httpClient: httpClient, + logger: logger, + siteNameMinInterval: rateToInterval(cfg.SiteNameRateLimit), + } +} + +// maxRedirects bounds the same-origin redirects one request follows. +const maxRedirects = 5 + +// errCrossOriginRedirect is returned for a redirect that leaves the +// controller origin. +var errCrossOriginRedirect = errors.New("refusing redirect outside the controller origin") + +// errTooManyRedirects is returned after maxRedirects same-origin +// redirects. +var errTooManyRedirects = fmt.Errorf("stopped after %d redirects", maxRedirects) + +// sameOriginRedirect returns an http.Client CheckRedirect policy that +// follows a redirect only to the exact controller origin (https, same +// host and port) and at most maxRedirects times. net/http forwards the +// login form body (307/308) and custom headers such as X-XSRF-TOKEN to +// the redirect target, so a redirect to any other origin is refused +// rather than followed; the 3xx response then surfaces as an HTTP +// error. The redirect target is never included in the error. +func sameOriginRedirect(origin *url.URL) func(*http.Request, []*http.Request) error { + want := originKey(origin) + return func(req *http.Request, via []*http.Request) error { + if len(via) >= maxRedirects { + return errTooManyRedirects + } + if originKey(req.URL) != want { + return errCrossOriginRedirect + } + return nil + } +} + +// originKey returns scheme://host:port with the default https port +// made explicit and the host lower-cased, so equivalent origins compare +// equal. +func originKey(u *url.URL) string { + port := u.Port() + if port == "" && u.Scheme == "https" { + port = "443" + } + return strings.ToLower(u.Scheme) + "://" + strings.ToLower(u.Hostname()) + ":" + port +} + +// context returns the client's run context. +func (c *Client) context() context.Context { + if c.ctx == nil { + return context.Background() + } + return c.ctx +} + +// sleepContext waits d or until ctx is done, returning ctx's error in +// the latter case. +func sleepContext(ctx context.Context, d time.Duration) error { + t := time.NewTimer(d) + defer t.Stop() + select { + case <-ctx.Done(): + return ctx.Err() + case <-t.C: + return nil + } +} + +// rateToInterval converts a requests/second rate to the minimum +// interval between requests. perSecond <= 0 is treated as 1 (never +// fully disabled pass a large value instead if throttling genuinely +// isn't wanted). +func rateToInterval(perSecond int) time.Duration { + if perSecond <= 0 { + perSecond = 1 + } + return time.Second / time.Duration(perSecond) +} + +// throttleSiteName blocks until at least siteNameMinInterval has +// passed since the previous GetSiteName call, so concurrent bulk +// resolution (resolveSiteNamesConcurrently in sites_select.go) never +// exceeds --site-name-rate requests/second regardless of worker count. +func (c *Client) throttleSiteName() { + c.siteNameMu.Lock() + defer c.siteNameMu.Unlock() + wait := c.siteNameMinInterval - time.Since(c.siteNameLastRequest) + if wait > 0 { + _ = sleepContext(c.context(), wait) + } + c.siteNameLastRequest = time.Now() +} + +// Login authenticates against the SD-WAN Manager controller: +// session-cookie login via /j_security_check, followed by minting an +// XSRF token via GET /dataservice/client/token. The XSRF token is +// stored and attached as X-XSRF-TOKEN on every subsequent request. +func (c *Client) Login(username, password string) error { + c.authMu.Lock() + defer c.authMu.Unlock() + c.username, c.password = username, password + if err := c.loginLocked(); err != nil { + return err + } + c.logger.Info("SD-WAN Manager login successful", "url", c.baseURL) + return nil +} + +// loginLocked performs the session login and XSRF token request with +// authMu held, and bumps authGen on success. +func (c *Client) loginLocked() error { + const op = "/j_security_check" + form := url.Values{ + "j_username": {c.username}, + "j_password": {c.password}, + } + req, err := http.NewRequestWithContext(c.context(), http.MethodPost, c.baseURL+op, strings.NewReader(form.Encode())) + if err != nil { + return &apiError{Op: op, Category: categoryTransport} + } + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + + resp, err := c.httpClient.Do(req) + if err != nil { + return transportError(op, err) + } + defer resp.Body.Close() + + body, err := readBounded(resp.Body) + if err != nil { + if errors.Is(err, errResponseTooLarge) { + return &apiError{Op: op, Status: resp.StatusCode, Category: categoryTooLarge} + } + return transportError(op, err) + } + + if resp.StatusCode != http.StatusOK { + return &apiError{Op: op, Status: resp.StatusCode, Category: statusCategory(resp.StatusCode)} + } + // A re-served HTML login page is the commonly documented SD-WAN + // Manager indicator of a rejected username/password + // (j_security_check itself always answers 200 either way). + if isHTML(body) { + return &apiError{Op: op, Status: resp.StatusCode, Category: categoryDenied, Err: errInvalidCredentials} + } + + token, err := c.fetchXSRFToken() + if err != nil { + return err + } + c.xsrfToken = token + c.authGen++ + return nil +} + +// reauthenticate renews an expired session once per run. gen is the +// login generation the failed request was sent with: when another +// request already renewed the session since, the caller simply retries. +// It reports whether the caller should retry its request. +func (c *Client) reauthenticate(gen int) bool { + c.authMu.Lock() + defer c.authMu.Unlock() + if c.authGen != gen { + return true + } + if c.reauths >= maxReauthentications || c.username == "" { + return false + } + c.reauths++ + c.xsrfToken = "" + if err := c.loginLocked(); err != nil { + c.logger.Warn("SD-WAN Manager session renewal failed", "category", failureCategory(err), "err", err) + return false + } + c.logger.Info("SD-WAN Manager session renewed after expiry") + return true +} + +// session returns the current XSRF token and login generation. +func (c *Client) session() (string, int) { + c.authMu.Lock() + defer c.authMu.Unlock() + return c.xsrfToken, c.authGen +} + +// isHTML reports whether a reply body is an HTML page (the Manager +// re-serves its login page for a rejected login or an expired session). +func isHTML(body []byte) bool { + t := bytes.ToLower(bytes.TrimSpace(body)) + if len(t) > 512 { + t = t[:512] + } + return bytes.HasPrefix(t, []byte("= 500 && transient < maxTransientRetries: + transient++ + if werr := sleepContext(c.context(), baseRetryDelay<= 0 { + return min(time.Duration(secs)*time.Second, maxRetryDelay) + } + } + delay := baseRetryDelay * time.Duration(1< maxRetryDelay { + delay = maxRetryDelay + } + return delay +} + +// GetDevices fetches the full device inventory via GET +// /dataservice/device. +func (c *Client) GetDevices() ([]Device, error) { + devices, _, err := c.GetDevicesWithRaw() + return devices, err +} + +// GetDevicesWithRaw is GetDevices plus each device's own raw JSON +// object, aligned index-for-index with the returned []Device used for +// --include-raw-body (see wantRawBody in catalystsdwanmanager.go), a +// lossless fallback for fields this producer doesn't model yet. +func (c *Client) GetDevicesWithRaw() ([]Device, []json.RawMessage, error) { + body, err := c.get("/dataservice/device") + if err != nil { + return nil, nil, err + } + return decodeListResponseWithRaw[Device]("/dataservice/device", body) +} + +// decodeListResponse parses an SD-WAN Manager list endpoint response, +// trying the common {"data": [...]} envelope first (decided by the +// first non-whitespace byte) and falling back to a bare JSON array. +// Shared by every list endpoint on this client so the +// envelope-vs-bare-array defensiveness isn't duplicated per endpoint. +// Real SD-WAN Manager deployments commonly wrap list responses as +// {"data": [...]} instead, this handles either shape without guessing +// which one a given controller version actually returns. +func decodeListResponse[T any](path string, body []byte) ([]T, error) { + trimmed := bytes.TrimSpace(body) + malformed := func(err error) error { + return &apiError{Op: path, Status: http.StatusOK, Category: categoryMalformed, Err: err} + } + if len(trimmed) == 0 { + return nil, malformed(errors.New("empty reply")) + } + + if trimmed[0] == '{' { + var envelope map[string]json.RawMessage + if err := json.Unmarshal(trimmed, &envelope); err != nil { + return nil, malformed(err) + } + data, ok := envelope["data"] + if !ok { + // An error object on a 200 reply must never read as an + // empty, successful listing. + if _, isErr := envelope["error"]; isErr { + return nil, &apiError{Op: path, Status: http.StatusOK, Category: categoryServerError, Err: errors.New("error object in reply")} + } + return nil, malformed(errors.New("no data member")) + } + var items []T + if bytes.Equal(bytes.TrimSpace(data), []byte("null")) { + return nil, nil + } + if err := json.Unmarshal(data, &items); err != nil { + return nil, malformed(err) + } + return items, nil + } + + var items []T + if err := json.Unmarshal(trimmed, &items); err != nil { + return nil, malformed(err) + } + return items, nil +} + +// decodeListResponseWithRaw parses body exactly like decodeListResponse +// into []T, and additionally decodes the same body a second time into +// each item's own raw json.RawMessage (json.RawMessage's UnmarshalJSON +// just captures the original bytes, so this is a second cheap decode +// pass, not a second HTTP round-trip) used only when --include-raw-body +// is requested (see wantRawBody in catalystsdwanmanager.go), so a field +// this producer doesn't model yet is never silently lost. +func decodeListResponseWithRaw[T any](path string, body []byte) ([]T, []json.RawMessage, error) { + items, err := decodeListResponse[T](path, body) + if err != nil { + return nil, nil, err + } + raws, err := decodeListResponse[json.RawMessage](path, body) + if err != nil { + return nil, nil, err + } + return items, raws, nil +} + +// flexString unmarshals a JSON string or a bare JSON number into a Go +// string. SD-WAN Manager's OpenAPI spec documents fields like +// mtu/speed-mbps as quoted strings (e.g. "1500"), but some controllers +// return speed-mbps as a bare JSON number instead which a string-typed +// struct field rejects outright, failing the whole response's unmarshal +// and silently dropping every interface for the device, not just the +// one field. flexString tolerates either representation so one +// inconsistently-typed field can't take out the entire response. +type flexString string + +// flexInt64 unmarshals a JSON number or a JSON string holding an +// integer into an int64. An empty string, null, or a string that is not +// an integer decodes to 0 ("unknown") rather than failing the whole +// reply, since these fields are display enrichment, not identity. +type flexInt64 int64 + +func (f *flexInt64) UnmarshalJSON(data []byte) error { + data = bytes.TrimSpace(data) + if len(data) > 0 && data[0] == '"' { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + n, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64) + if err != nil { + *f = 0 + return nil + } + *f = flexInt64(n) + return nil + } + if bytes.Equal(data, []byte("null")) { + *f = 0 + return nil + } + var n json.Number + if err := json.Unmarshal(data, &n); err != nil { + return err + } + if i, err := n.Int64(); err == nil { + *f = flexInt64(i) + return nil + } + if fl, err := n.Float64(); err == nil { + *f = flexInt64(int64(fl)) + return nil + } + *f = 0 + return nil +} + +func (f *flexString) UnmarshalJSON(data []byte) error { + if len(data) > 0 && data[0] == '"' { + var s string + if err := json.Unmarshal(data, &s); err != nil { + return err + } + *f = flexString(s) + return nil + } + *f = flexString(bytes.TrimSpace(data)) + return nil +} + +// Interface is the subset of the GET /dataservice/device/interface +// response fields (tag "Monitoring - Interface") this producer maps to +// OSIRIS network.router.port/network.interface resources. Field names +// taken verbatim from the SD-WAN Manager OpenAPI spec's documented +// example. The endpoint returns one row per (interface, address-family) +// pair af-type distinguishes an interface's IPv4 row from its IPv6 row +// see mergeInterfaceRows in transform_interfaces.go for how these are +// reconciled. Mtu/SpeedMbps use flexString (not string) since SD-WAN +// Manager does not consistently type these as JSON strings across +// controller versions/platforms, see flexString's doc comment. +// Description is absent from the SD-WAN Manager OpenAPI spec's own +// documented example for this endpoint, but is present on real +// interfaces in practice, not every interface sets it, an unconfigured +// one simply omits the field. +type Interface struct { + VDeviceHostName string `json:"vdevice-host-name"` + IfName string `json:"ifname"` + AFType string `json:"af-type"` + IPAddress string `json:"ip-address"` + HWAddr string `json:"hwaddr"` + IfAdminStatus string `json:"if-admin-status"` + IfOperStatus string `json:"if-oper-status"` + VPNID string `json:"vpn-id"` + PortType string `json:"port-type"` + Duplex string `json:"duplex"` + Mtu flexString `json:"mtu"` + SpeedMbps flexString `json:"speed-mbps"` + EncapType string `json:"encap-type"` + Description string `json:"description"` +} + +// GetDeviceInterfaces fetches per-device interface details via GET +// /dataservice/device/interface?deviceId={system-ip}, used for the base +// network.interface resource (MAC, private IP, admin/oper state). +func (c *Client) GetDeviceInterfaces(systemIP string) ([]Interface, error) { + ifaces, _, err := c.GetDeviceInterfacesWithRaw(systemIP) + return ifaces, err +} + +// GetDeviceInterfacesWithRaw is GetDeviceInterfaces plus each row's own +// raw JSON object, for --include-raw-body (see wantRawBody in +// catalystsdwanmanager.go). +func (c *Client) GetDeviceInterfacesWithRaw(systemIP string) ([]Interface, []json.RawMessage, error) { + path := "/dataservice/device/interface?deviceId=" + url.QueryEscape(systemIP) + body, err := c.get(path) + if err != nil { + return nil, nil, err + } + return decodeListResponseWithRaw[Interface]("/dataservice/device/interface", body) +} + +// WANInterface is the subset of the GET +// /dataservice/device/control/waninterface response fields (tag +// "Monitoring - WAN Interface") used to enrich a transport-facing +// network.interface resource with its public/NAT address and color. +// Field names taken verbatim from the SD-WAN Manager OpenAPI spec's +// documented example. +type WANInterface struct { + VDeviceHostName string `json:"vdevice-host-name"` + Interface string `json:"interface"` + Color string `json:"color"` + PrivateIP string `json:"private-ip"` + PublicIP string `json:"public-ip"` + NatType string `json:"nat-type"` + OperationState string `json:"operation-state"` +} + +// GetWANInterfaces fetches per-device WAN transport details via GET +// /dataservice/device/control/waninterface?deviceId={system-ip}, joined +// back to GetDeviceInterfaces results by interface name in +// transform_interfaces.go. +func (c *Client) GetWANInterfaces(systemIP string) ([]WANInterface, error) { + wanIfaces, _, err := c.GetWANInterfacesWithRaw(systemIP) + return wanIfaces, err +} + +// GetWANInterfacesWithRaw is GetWANInterfaces plus each row's own raw +// JSON object, for --include-raw-body (see wantRawBody in +// catalystsdwanmanager.go). +func (c *Client) GetWANInterfacesWithRaw(systemIP string) ([]WANInterface, []json.RawMessage, error) { + path := "/dataservice/device/control/waninterface?deviceId=" + url.QueryEscape(systemIP) + body, err := c.get(path) + if err != nil { + return nil, nil, err + } + return decodeListResponseWithRaw[WANInterface]("/dataservice/device/control/waninterface", body) +} + +// SiteTunnel is a single SD-WAN tunnel entry within a SiteCircuit, as +// returned by GET /dataservice/topology/monitor/site/{siteId}. Name +// encodes both tunnel endpoints as "{ipA}:{colorA}-{ipB}:{colorB}" - +// see parseTunnelEndpoints in transform_connections.go. +type SiteTunnel struct { + Name string `json:"name"` + Health string `json:"health"` + State string `json:"state"` + VqoeScore *float64 `json:"vqoe_score"` // nil when absent; 0 is a real score. +} + +// SiteCircuit is a per-color transport circuit within a +// SiteTopologyDevice. +type SiteCircuit struct { + Color string `json:"color"` + SystemIP string `json:"system_ip"` + CircuitHealth string `json:"circuit-health"` + Tunnels []SiteTunnel `json:"tunnels"` +} + +// SiteTopologyDevice is a single device entry within a GET +// /dataservice/topology/monitor/site/{siteId} response. Field names +// taken verbatim from the SD-WAN Manager OpenAPI spec's documented +// example. +type SiteTopologyDevice struct { + DeviceID string `json:"device-id"` + DeviceHealth string `json:"device-health"` + Circuits []SiteCircuit `json:"circuits"` +} + +// GetSiteTopologyMonitor fetches SD-WAN tunnel/circuit data for a site +// via GET /dataservice/topology/monitor/site/{siteId}. +func (c *Client) GetSiteTopologyMonitor(siteID string) ([]SiteTopologyDevice, error) { + devices, _, err := c.GetSiteTopologyMonitorWithRaw(siteID) + return devices, err +} + +// GetSiteTopologyMonitorWithRaw is GetSiteTopologyMonitor plus each +// device entry's own raw JSON object, for --include-raw-body (see +// wantRawBody in catalystsdwanmanager.go). +func (c *Client) GetSiteTopologyMonitorWithRaw(siteID string) ([]SiteTopologyDevice, []json.RawMessage, error) { + path := "/dataservice/topology/monitor/site/" + url.PathEscape(siteID) + body, err := c.get(path) + if err != nil { + return nil, nil, err + } + return decodeListResponseWithRaw[SiteTopologyDevice]("/dataservice/topology/monitor/site", body) +} + +// OMPLink is a single global OMP control-plane connection pair, as +// returned by GET /dataservice/device/omp/links. Unlike most +// /dataservice/device/* endpoints this is not scoped to a single +// deviceId, one call covers every device the credential can see. Field +// names taken verbatim from the SD-WAN Manager OpenAPI spec's +// documented example. +type OMPLink struct { + State string `json:"state"` + ADeviceID string `json:"adeviceId"` + BDeviceID string `json:"bdeviceId"` + ASystemIP string `json:"asystem-ip"` + BSystemIP string `json:"bsystem-ip"` + ASiteID string `json:"asite-id"` + BSiteID string `json:"bsite-id"` + AHostName string `json:"ahost-name"` + BHostName string `json:"bhost-name"` + APersonality string `json:"apersonality"` + BPersonality string `json:"bpersonality"` +} + +// ompLinkStates are the two values GetOMPLinks queries for. The +// endpoint's "state" query parameter is required, but the SD-WAN +// Manager OpenAPI spec never documents its accepted values, no enum, no +// component schema, just the free-text description "Connection state". +// Only "up" and "down" appear in the spec's own examples; "all" is not +// documented as accepted, so this queries both states explicitly and +// merges the results rather than gambling on an unverified value. +var ompLinkStates = []string{"up", "down"} + +// GetOMPLinks fetches the global OMP control-plane peering list via GET +// /dataservice/device/omp/links, once per state in ompLinkStates +// (merged). A failure on either call returns immediately, "some +// states, silently incomplete" is worse than a clear error for data +// meant to represent the full OMP peering topology. +func (c *Client) GetOMPLinks() ([]OMPLink, error) { + var links []OMPLink + for _, state := range ompLinkStates { + body, err := c.get("/dataservice/device/omp/links?state=" + url.QueryEscape(state)) + if err != nil { + return nil, err + } + batch, err := decodeListResponse[OMPLink]("/dataservice/device/omp/links", body) + if err != nil { + return nil, err + } + links = append(links, batch...) + } + return links, nil +} + +// OMPPeer is a single OMP peer entry for one device, as returned by GET +// /dataservice/device/omp/peers?deviceId={system-ip}, typically a WAN +// edge's control-plane sessions to its vsmart/vbond controllers. Field +// names taken verbatim from the SD-WAN Manager OpenAPI spec's +// documented example. +type OMPPeer struct { + VDeviceHostName string `json:"vdevice-host-name"` + Peer string `json:"peer"` + Type string `json:"type"` + State string `json:"state"` +} + +// GetOMPPeers fetches a device's OMP peer list via GET +// /dataservice/device/omp/peers?deviceId={system-ip}. +func (c *Client) GetOMPPeers(systemIP string) ([]OMPPeer, error) { + peers, _, err := c.GetOMPPeersWithRaw(systemIP) + return peers, err +} + +// GetOMPPeersWithRaw is GetOMPPeers plus each peer's own raw JSON +// object, for --include-raw-body (see wantRawBody in +// catalystsdwanmanager.go). +func (c *Client) GetOMPPeersWithRaw(systemIP string) ([]OMPPeer, []json.RawMessage, error) { + path := "/dataservice/device/omp/peers?deviceId=" + url.QueryEscape(systemIP) + body, err := c.get(path) + if err != nil { + return nil, nil, err + } + return decodeListResponseWithRaw[OMPPeer]("/dataservice/device/omp/peers", body) +} + +// GetPeerWANInterfaces is GetWANInterfaces for a tunnel peer outside +// the selected sites (see collectNeighborWAN in collect.go). Like +// GetSiteName it is a bulk, one-call-per-device lookup, so it shares +// the --site-name-rate throttle: a hub site can peer with hundreds of +// devices. +func (c *Client) GetPeerWANInterfaces(systemIP string) ([]WANInterface, error) { + c.throttleSiteName() + wan, _, err := c.GetWANInterfacesWithRaw(systemIP) + return wan, err +} + +// GetSiteName fetches the human-readable site name for a site-id via +// GET /dataservice/topology/device/site/{siteId}. Unlike GetDevices, +// this endpoint's response shape is not documented in the SD-WAN +// Manager OpenAPI spec (the schema is a bare, empty {"type": +// "object"}); the {"site_name": "...", "data": [...]} shape used here +// is the observed response. Callers should treat this as best-effort +// (see siteDisplayName in sites_select.go): some credentials may lack +// access to this endpoint, and a failure here should never block +// collection. +func (c *Client) GetSiteName(siteID string) (string, error) { + c.throttleSiteName() + body, err := c.get("/dataservice/topology/device/site/" + url.PathEscape(siteID)) + if err != nil { + return "", err + } + + var parsed struct { + SiteName string `json:"site_name"` + } + if err := json.Unmarshal(body, &parsed); err != nil { + return "", &apiError{Op: "/dataservice/topology/device/site", Status: http.StatusOK, Category: categoryMalformed, Err: err} + } + return parsed.SiteName, nil +} + +// operationName returns the endpoint path of a request without its +// query string, so diagnostics identify the operation without echoing +// request parameters. Response bodies are never part of a diagnostic: +// an error body can carry credentials, tokens or other sensitive +// content, and truncating it bounds only its size, not its +// sensitivity. +func operationName(path string) string { + if i := strings.IndexByte(path, '?'); i >= 0 { + return path[:i] + } + return path +} + +// transportCause strips the request URL that net/http adds to +// transport errors (*url.Error), keeping only the underlying cause, so +// a diagnostic never repeats request parameters or a redirect target. +func transportCause(err error) error { + var ue *url.Error + if errors.As(err, &ue) { + return ue.Err + } + return err +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/client_retry_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/client_retry_test.go new file mode 100644 index 0000000..6aa09f5 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/client_retry_test.go @@ -0,0 +1,187 @@ +// client_retry_test.go - Tests for the bounded retry and session +// renewal of the Cisco Catalyst SD-WAN Manager REST API client: one +// retry for a timeout or HTTP 5xx, none for a denial and one +// re-login per run when the session expires (HTTP 401, or the login +// page re-served with HTTP 200), shared by concurrent requests. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "errors" + "fmt" + "net/http" + "net/http/httptest" + "sync" + "sync/atomic" + "testing" + "time" +) + +// sessionServer is a Manager whose /dataservice/device endpoint is +// scripted per call; logins and token requests are counted. +type sessionServer struct { + logins, tokens, devices atomic.Int32 + device func(call int32, w http.ResponseWriter, r *http.Request) +} + +func (s *sessionServer) handler(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/j_security_check": + s.logins.Add(1) + case "/dataservice/client/token": + // The first login gets "test", every renewal "changeme". + if s.tokens.Add(1) == 1 { + fmt.Fprint(w, `{"token":"test"}`) + } else { + fmt.Fprint(w, `{"token":"changeme"}`) + } + case "/dataservice/device": + s.device(s.devices.Add(1), w, r) + } +} + +const oneDevice = `{"data":[{"deviceId":"192.0.2.1","host-name":"LAB-RTR01"}]}` + +func loggedInClient(t *testing.T, s *sessionServer) (*Client, func()) { + t.Helper() + ts := httptest.NewTLSServer(http.HandlerFunc(s.handler)) + c := newSecureTestClient(t, ts) + if err := c.Login("admin", "changeme"); err != nil { + ts.Close() + t.Fatalf("Login: %v", err) + } + return c, ts.Close +} + +func TestFetch_RetriesTimeoutOnce(t *testing.T) { + s := &sessionServer{device: func(call int32, w http.ResponseWriter, r *http.Request) { + if call == 1 { + time.Sleep(300 * time.Millisecond) + } + fmt.Fprint(w, oneDevice) + }} + c, stop := loggedInClient(t, s) + defer stop() + c.httpClient.Timeout = 100 * time.Millisecond + if _, err := c.GetDevices(); err != nil { + t.Fatalf("GetDevices after one timeout: %v", err) + } + if got := s.devices.Load(); got != 2 { + t.Errorf("device calls = %d, want 2 (one retry)", got) + } +} + +func TestFetch_RetryIsBounded(t *testing.T) { + for _, tt := range []struct { + name string + status int + calls int32 + category string + }{ + {"5xx retried once", http.StatusServiceUnavailable, 2, categoryServerError}, + {"403 never retried", http.StatusForbidden, 1, categoryDenied}, + {"404 never retried", http.StatusNotFound, 1, categoryNotFound}, + } { + t.Run(tt.name, func(t *testing.T) { + s := &sessionServer{device: func(_ int32, w http.ResponseWriter, _ *http.Request) { w.WriteHeader(tt.status) }} + c, stop := loggedInClient(t, s) + defer stop() + _, err := c.GetDevices() + if failureCategory(err) != tt.category { + t.Errorf("category = %q, want %q", failureCategory(err), tt.category) + } + if got := s.devices.Load(); got != tt.calls { + t.Errorf("device calls = %d, want %d", got, tt.calls) + } + }) + } +} + +func TestFetch_RenewsExpiredSessionOnce(t *testing.T) { + for _, tt := range []struct { + name string + expired func(w http.ResponseWriter) + }{ + {"HTTP 401", func(w http.ResponseWriter) { w.WriteHeader(http.StatusUnauthorized) }}, + {"login page with 200", func(w http.ResponseWriter) { fmt.Fprint(w, "login") }}, + } { + t.Run(tt.name, func(t *testing.T) { + var sawToken atomic.Value + s := &sessionServer{device: func(call int32, w http.ResponseWriter, r *http.Request) { + if call == 1 { + tt.expired(w) + return + } + sawToken.Store(r.Header.Get("X-XSRF-TOKEN")) + fmt.Fprint(w, oneDevice) + }} + c, stop := loggedInClient(t, s) + defer stop() + if _, err := c.GetDevices(); err != nil { + t.Fatalf("GetDevices after expiry: %v", err) + } + if s.logins.Load() != 2 { + t.Errorf("logins = %d, want 2", s.logins.Load()) + } + if sawToken.Load() != "changeme" { + t.Errorf("retried request sent token %v, want the renewed one", sawToken.Load()) + } + }) + } +} + +func TestFetch_AtMostOneRenewalPerRun(t *testing.T) { + s := &sessionServer{device: func(_ int32, w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusUnauthorized) }} + c, stop := loggedInClient(t, s) + defer stop() + for i := 0; i < 3; i++ { + _, err := c.GetDevices() + if !errors.Is(err, errSessionExpired) || failureCategory(err) != categoryDenied { + t.Fatalf("call %d: err = %v, want a denied session-expired error", i, err) + } + } + if got := s.logins.Load(); got != 1+maxReauthentications { + t.Errorf("logins = %d, want %d", got, 1+maxReauthentications) + } +} + +func TestFetch_ConcurrentExpiryRenewsOnce(t *testing.T) { + var gate sync.Once + ready := make(chan struct{}) + s := &sessionServer{} + s.device = func(_ int32, w http.ResponseWriter, r *http.Request) { + if r.Header.Get("X-XSRF-TOKEN") == "test" { + gate.Do(func() { close(ready) }) + <-ready + w.WriteHeader(http.StatusUnauthorized) + return + } + fmt.Fprint(w, oneDevice) + } + c, stop := loggedInClient(t, s) + defer stop() + + var wg sync.WaitGroup + errs := make(chan error, 8) + for i := 0; i < 8; i++ { + wg.Add(1) + go func() { + defer wg.Done() + _, err := c.GetDevices() + errs <- err + }() + } + wg.Wait() + close(errs) + for err := range errs { + if err != nil { + t.Errorf("concurrent request failed: %v", err) + } + } + if got := s.logins.Load(); got != 2 { + t.Errorf("logins = %d, want 2 (one shared renewal)", got) + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/client_security_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/client_security_test.go new file mode 100644 index 0000000..02a2113 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/client_security_test.go @@ -0,0 +1,249 @@ +// client_security_test.go - Security tests for the Cisco Catalyst +// SD-WAN Manager REST API client: no response body or request +// parameter in diagnostics, same-origin-only redirects, and an +// end-to-end secret canary through --include-raw-body. +// +// Secret-shaped inputs use the approved synthetic placeholders only. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "bytes" + "errors" + "fmt" + "io" + "log/slog" + "net/http" + "net/http/httptest" + "net/url" + "os" + "path/filepath" + "strings" + "sync/atomic" + "testing" + + "go.osirisjson.org/producers/pkg/sdk" +) + +// secretBody is an error body carrying every canary. +const secretBody = `{"error":{"message":"password=changeme","details":"` + canaryBearer + `","url":"` + canaryURI + `"}}` + +// newSecureTestClient builds a client through NewClient (so the real +// redirect policy and timeout apply) against a TLS test server. +func newSecureTestClient(t *testing.T, ts *httptest.Server) *Client { + t.Helper() + host, port := splitHostPort(t, ts.Listener.Addr().String()) + return NewClient(&Config{Host: host, Port: port, InsecureTLS: true, SiteNameRateLimit: 1000}, testLogger(t)) +} + +func TestClientErrors_NeverEchoResponseBodies(t *testing.T) { + tests := []struct { + name string + handler http.HandlerFunc + call func(*Client) error + }{ + {"login HTTP error", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusUnauthorized) + fmt.Fprint(w, secretBody) + }, func(c *Client) error { return c.Login("admin", "changeme") }}, + {"token HTTP error", func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/j_security_check" { + return + } + w.WriteHeader(http.StatusForbidden) + fmt.Fprint(w, secretBody) + }, func(c *Client) error { return c.Login("admin", "changeme") }}, + {"GET HTTP error", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusInternalServerError) + fmt.Fprint(w, secretBody) + }, func(c *Client) error { _, err := c.GetDevices(); return err }}, + {"GET 429 exhausted", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Retry-After", "0") + w.WriteHeader(http.StatusTooManyRequests) + fmt.Fprint(w, secretBody) + }, func(c *Client) error { _, err := c.GetDevices(); return err }}, + {"GET with query", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusBadGateway) + fmt.Fprint(w, secretBody) + }, func(c *Client) error { _, err := c.GetDeviceInterfaces("192.0.2.1"); return err }}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ts := httptest.NewTLSServer(tt.handler) + defer ts.Close() + var logs bytes.Buffer + c := newSecureTestClient(t, ts) + c.logger = slog.New(slog.NewTextHandler(&logs, nil)) + err := tt.call(c) + if err == nil { + t.Fatal("expected an error") + } + for _, s := range []string{"changeme", canaryBearer, canaryURI, "192.0.2.1", `"error"`} { + if strings.Contains(err.Error(), s) || strings.Contains(logs.String(), s) { + t.Errorf("diagnostic leaks %q: err=%v logs=%s", s, err, logs.String()) + } + } + }) + } +} + +func TestClient_RefusesCrossOriginRedirect(t *testing.T) { + var leaked atomic.Bool + other := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + body, _ := io.ReadAll(r.Body) + if bytes.Contains(body, []byte("changeme")) || r.Header.Get("X-XSRF-TOKEN") != "" { + leaked.Store(true) + } + w.WriteHeader(http.StatusOK) + })) + defer other.Close() + + for _, code := range []int{http.StatusMovedPermanently, http.StatusFound, http.StatusSeeOther, http.StatusTemporaryRedirect, http.StatusPermanentRedirect} { + t.Run(fmt.Sprintf("login %d", code), func(t *testing.T) { + leaked.Store(false) + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, other.URL+"/j_security_check", code) + })) + defer ts.Close() + err := newSecureTestClient(t, ts).Login("admin", "changeme") + if err == nil { + t.Fatal("expected login to fail on a cross-origin redirect") + } + if !errors.Is(err, errCrossOriginRedirect) { + t.Errorf("err = %v, want errCrossOriginRedirect", err) + } + if strings.Contains(err.Error(), other.URL) { + t.Errorf("error echoes the redirect target: %v", err) + } + if leaked.Load() { + t.Error("credentials reached the other origin") + } + }) + } + + t.Run("GET carries no XSRF token off origin", func(t *testing.T) { + leaked.Store(false) + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, other.URL+"/dataservice/device", http.StatusTemporaryRedirect) + })) + defer ts.Close() + c := newSecureTestClient(t, ts) + c.xsrfToken = "test" + if _, err := c.GetDevices(); !errors.Is(err, errCrossOriginRedirect) { + t.Errorf("err = %v, want errCrossOriginRedirect", err) + } + if leaked.Load() { + t.Error("XSRF token reached the other origin") + } + }) +} + +func TestClient_FollowsSameOriginRedirect(t *testing.T) { + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/dataservice/device": + http.Redirect(w, r, "/dataservice/device/v2", http.StatusFound) + case "/dataservice/device/v2": + fmt.Fprint(w, `{"data":[{"deviceId":"192.0.2.1","host-name":"LAB-RTR01"}]}`) + } + })) + defer ts.Close() + devices, err := newSecureTestClient(t, ts).GetDevices() + if err != nil { + t.Fatalf("GetDevices: %v", err) + } + if len(devices) != 1 { + t.Errorf("devices = %d, want 1", len(devices)) + } +} + +func TestClient_StopsRedirectLoop(t *testing.T) { + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, "/dataservice/device", http.StatusFound) + })) + defer ts.Close() + if _, err := newSecureTestClient(t, ts).GetDevices(); err == nil || !strings.Contains(err.Error(), "redirects") { + t.Errorf("err = %v, want a redirect-limit error", err) + } +} + +func TestOriginKey(t *testing.T) { + a, b := mustURL(t, "https://LAB-MANAGER01.example.com/x"), mustURL(t, "https://lab-manager01.example.com:443/y") + if originKey(a) != originKey(b) { + t.Errorf("originKey(%v) != originKey(%v)", a, b) + } + for _, u := range []string{"http://lab-manager01.example.com/", "https://lab-manager01.example.com:8443/", "https://lab-manager02.example.com/"} { + if originKey(mustURL(t, u)) == originKey(a) { + t.Errorf("originKey(%s) must differ from %s", u, a) + } + } +} + +// secretRawHandler serves the end-to-end fixture with a secret-bearing +// interface row and device field. +func secretRawHandler(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/dataservice/device/interface": + w.Header().Set("Content-Type", "application/json") + fmt.Fprint(w, `{"data":[{"ifname":"ge0/0","vpn-id":"0","auth-key":"changeme","nested":[{"note":"`+canaryBearer+`"}]}]}`) + default: + fixtureHandlerWithRawBody(w, r) + } +} + +// TestRunExport_RawBodyNeverEmitsSecrets runs the full export with +// --include-raw-body under every --safe-failure-mode and checks no +// canary reaches any written document or file mode beyond 0600. +func TestRunExport_RawBodyNeverEmitsSecrets(t *testing.T) { + ts := httptest.NewTLSServer(http.HandlerFunc(secretRawHandler)) + defer ts.Close() + host, port := splitHostPort(t, ts.Listener.Addr().String()) + for _, mode := range []string{sdk.FailClosed, sdk.LogAndRedact, sdk.Off} { + t.Run(mode, func(t *testing.T) { + out := t.TempDir() + cfg := &Config{ + Host: host, Port: port, Username: "user", Password: "changeme", InsecureTLS: true, + SafeFailureMode: mode, Purpose: "audit", IncludeRawBody: true, + AllSites: true, SiteNameRateLimit: 1000, OutputDir: out, + } + if err := runExport(cfg); err != nil { + t.Fatalf("runExport: %v", err) + } + n := 0 + err := filepath.WalkDir(out, func(path string, d os.DirEntry, err error) error { + if err != nil || d.IsDir() { + return err + } + n++ + data, err := os.ReadFile(path) + if err != nil { + return err + } + noSecrets(t, data) + fi, _ := d.Info() + if fi.Mode().Perm() != outputFileMode { + t.Errorf("%s mode = %v, want %v", path, fi.Mode().Perm(), outputFileMode) + } + return nil + }) + if err != nil { + t.Fatal(err) + } + if n == 0 { + t.Fatal("no document written") + } + }) + } +} + +func mustURL(t *testing.T, s string) *url.URL { + t.Helper() + u, err := url.Parse(s) + if err != nil { + t.Fatal(err) + } + return u +} diff --git a/osiris/network/cisco/vmanage/client_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/client_test.go similarity index 91% rename from osiris/network/cisco/vmanage/client_test.go rename to osiris/network/cisco/catalyst-sd-wan-manager/client_test.go index a8edab7..0d3f635 100644 --- a/osiris/network/cisco/vmanage/client_test.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/client_test.go @@ -1,12 +1,12 @@ -// client_test.go - Tests for the vManage REST API client: session+XSRF -// login, and both response envelope shapes GetDevices/ListTenants must -// handle. +// client_test.go - Tests for the SD-WAN Manager REST API client: +// session+XSRF login, and both response envelope shapes +// GetDevices/ListTenants must handle. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import ( "fmt" @@ -77,7 +77,7 @@ func TestLogin_InvalidCredentials(t *testing.T) { func TestGetDevices_EnvelopeShape(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - fmt.Fprint(w, `{"data":[{"deviceId":"192.0.2.10","system-ip":"192.0.2.10","host-name":"TEST-VMANAGE1","uuid":"11111111-1111-1111-1111-111111111111","site-id":"100","personality":"vmanage"}]}`) + fmt.Fprint(w, `{"data":[{"deviceId":"192.0.2.10","system-ip":"192.0.2.10","host-name":"TEST-SDWANMGR1","uuid":"11111111-1111-1111-1111-111111111111","site-id":"100","personality":"vmanage"}]}`) })) defer ts.Close() @@ -86,7 +86,7 @@ func TestGetDevices_EnvelopeShape(t *testing.T) { if err != nil { t.Fatalf("GetDevices failed: %v", err) } - if len(devices) != 1 || devices[0].HostName != "TEST-VMANAGE1" { + if len(devices) != 1 || devices[0].HostName != "TEST-SDWANMGR1" { t.Fatalf("unexpected devices: %+v", devices) } } @@ -109,8 +109,9 @@ func TestGetDevices_BareArrayShape(t *testing.T) { } func TestGetDevices_HealthAndInventoryFields(t *testing.T) { - // Field values taken verbatim from the vManage OpenAPI spec's own - // documented "Devices List" example for GET /dataservice/device. + // Field values taken verbatim from the SD-WAN Manager OpenAPI + // spec's own documented "Devices List" example for GET + // /dataservice/device. ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") fmt.Fprint(w, `{"data":[{"deviceId":"192.0.2.20","system-ip":"192.0.2.20","host-name":"LAB-VM200","personality":"vmanage","board-serial":"TST12345789","state":"green","state_description":"All daemons up","uptime-date":1634626320000,"lastupdated":1634627015139,"connectedVManages":["192.0.2.20"]}]}`) @@ -141,8 +142,8 @@ func TestGetDevices_HealthAndInventoryFields(t *testing.T) { if d.LastUpdated != 1634627015139 { t.Errorf("LastUpdated = %d, want %d", d.LastUpdated, 1634627015139) } - if len(d.ConnectedVManages) != 1 || d.ConnectedVManages[0] != "192.0.2.20" { - t.Errorf("ConnectedVManages = %v, want [192.0.2.20]", d.ConnectedVManages) + if len(d.ConnectedManagers) != 1 || d.ConnectedManagers[0] != "192.0.2.20" { + t.Errorf("ConnectedManagers = %v, want [192.0.2.20]", d.ConnectedManagers) } } @@ -163,26 +164,6 @@ func TestGetDevices_EmptyEnvelope(t *testing.T) { } } -func TestListTenants_BareArray(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - fmt.Fprint(w, `[{"name":"TEST-TENANT-1"},{"name":"TEST-TENANT-2"}]`) - })) - defer ts.Close() - - c := newTestClient(t, ts) - tenants, err := c.ListTenants() - if err != nil { - t.Fatalf("ListTenants failed: %v", err) - } - if len(tenants) != 2 { - t.Fatalf("expected 2 tenants, got %d", len(tenants)) - } - if got := tenantLabel(tenants[0]); got != "TEST-TENANT-1" { - t.Errorf("tenantLabel = %q, want %q", got, "TEST-TENANT-1") - } -} - func TestGetSiteName_UndocumentedResponseShape(t *testing.T) { // The observed response shape for // GET /dataservice/topology/device/site/{siteId} the spec itself @@ -400,8 +381,8 @@ func TestGetSiteTopologyMonitor_EnvelopeShape(t *testing.T) { func TestGetOMPLinks_QueriesBothStatesAndMerges(t *testing.T) { // The endpoint's "state" query parameter is required but its - // accepted values are undocumented in the vManage OpenAPI spec (no - // enum, only "up"/"down" ever appear in worked examples) + // accepted values are undocumented in the SD-WAN Manager OpenAPI + // spec (no enum, only "up"/"down" ever appear in worked examples) // GetOMPLinks queries both explicitly rather than an unverified // "all" and merges the results. var seenStates []string diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/collect.go b/osiris/network/cisco/catalyst-sd-wan-manager/collect.go new file mode 100644 index 0000000..7fc798d --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/collect.go @@ -0,0 +1,361 @@ +// collect.go - Bounded, independent collection stage of the Cisco +// Catalyst SD-WAN Manager OSIRIS JSON Producer. +// +// collect runs every API operation for the selected sites once and +// returns the observations together with their coverage record. It +// talks to the controller only through managerAPI, so tests and later +// stages can inject a fake. Building and publishing documents is a +// separate stage (document.go, output.go): a collection is never +// written as it is gathered. +// +// Operation classes: +// +// - essential: the device inventory (GET /dataservice/device). Its +// failure aborts the run, because no document can be built without +// it; +// - optional: every other operation. A failure is logged with its +// category, recorded in coverage and leaves the affected document +// partial. Optional operations are independent of each other: a +// failed interface listing for a device does not skip that +// device's WAN interfaces or OMP peers. +// +// GET /dataservice/tenant is no longer called: the tenants a +// credential can see are not the accounts this producer collected +// from, so they no longer feed metadata.scope.accounts. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "encoding/json" + "fmt" + "log/slog" + "sort" + "sync" +) + +// siteNamer resolves a site-id to its display name. +type siteNamer interface { + GetSiteName(siteID string) (string, error) +} + +// managerAPI is the controller surface the collection stage uses. +// *Client implements it. +type managerAPI interface { + siteNamer + GetDevicesWithRaw() ([]Device, []json.RawMessage, error) + GetOMPLinks() ([]OMPLink, error) + GetDeviceInterfacesWithRaw(systemIP string) ([]Interface, []json.RawMessage, error) + GetWANInterfacesWithRaw(systemIP string) ([]WANInterface, []json.RawMessage, error) + GetOMPPeersWithRaw(systemIP string) ([]OMPPeer, []json.RawMessage, error) + GetSiteTopologyMonitorWithRaw(siteID string) ([]SiteTopologyDevice, []json.RawMessage, error) + GetPeerWANInterfaces(systemIP string) ([]WANInterface, error) +} + +var _ managerAPI = (*Client)(nil) + +// deviceObs is one device and everything collected for it. +type deviceObs struct { + Device + raw json.RawMessage + + ifaces []Interface + ifacesRaw []json.RawMessage + ifacesOK bool // the interface listing answered (possibly empty). + + wan []WANInterface + wanRaw []json.RawMessage + + peers []OMPPeer + peersRaw []json.RawMessage +} + +// siteObs is one selected site and its observations. +type siteObs struct { + id, name string + devices []*deviceObs + + topology []SiteTopologyDevice + topologyRaw []json.RawMessage + topologyOK bool + + cov *coverage // operations scoped to this site. +} + +// collection is the result of one collection run. +type collection struct { + ompLinks []OMPLink + sites []*siteObs + global *coverage // controller-wide operations. + wantRaw bool + + // fabric indexes the whole inventory for cross-site endpoint + // resolution (neighbors.go), wanBySystemIP holds every WAN + // interface listing collected, for selected devices and for tunnel + // peers outside the selected sites. + fabric *fabricIndex + wanBySystemIP map[string][]WANInterface + // unidentified counts inventory devices with a known personality + // but no native identity (no serial, uuid or deviceId): they are + // never emitted. + unidentified int +} + +// siteCoverage is the coverage record of one site's document: the +// controller-wide operations plus the site's own. +func (col *collection) siteCoverage(s *siteObs) *coverage { + return merged(col.global, s.cov) +} + +// collect gathers the inventory, selects sites and collects every +// selected site's per-device and per-site operations (see the file +// comment for operation classes). +func collect(api managerAPI, cfg *Config, logger *slog.Logger) (*collection, error) { + col := &collection{ + global: &coverage{}, + wantRaw: cfg.Purpose == "audit" && cfg.IncludeRawBody, + wanBySystemIP: map[string][]WANInterface{}, + } + + devices, devicesRaw, err := api.GetDevicesWithRaw() + col.global.record(opDevice, len(devices), err) + if err != nil { + return nil, fmt.Errorf("fetching device inventory failed: %w", err) + } + var rawByID map[string]json.RawMessage + if col.wantRaw { + rawByID = deviceRawIndex(devices, devicesRaw) + } + col.fabric = newFabricIndex(devices) + for _, d := range devices { + if rt, ok := personalityToType[d.Personality]; ok && deviceNativeKey(d, rt) == "" { + col.unidentified++ + } + } + if col.unidentified > 0 { + logger.Warn("devices without native identity skipped", "count", col.unidentified) + } + + // One controller-wide call covers every site's OMP peering; + // each site document keeps the sessions of its own devices. + links, err := api.GetOMPLinks() + col.global.record(opOMPLinks, len(links), err) + if err != nil { + logger.Warn("OMP link listing failed (continuing without OMP peering connections)", "category", failureCategory(err), "err", err) + } else { + col.ompLinks = links + } + + groups := GroupDevicesBySiteID(devices) + selected, names, err := resolveSiteSelection(cfg, groups, api, logger) + if err != nil { + return nil, fmt.Errorf("resolving site selection: %w", err) + } + logger.Info("site selection resolved", "sites", len(selected)) + + for _, siteID := range selected { + s := &siteObs{id: siteID, cov: &coverage{}} + col.sites = append(col.sites, s) + + if siteID == "" { + s.cov.skip(opSiteName, "unsited") + } else if name, ok := names[siteID]; ok { + s.name = name + } else { + name, err := api.GetSiteName(siteID) + s.cov.record(opSiteName, boolCount(name != ""), err) + switch { + case err != nil: + logger.Warn("site name lookup failed (using site-id instead)", "site_id", siteID, "category", failureCategory(err), "err", err) + s.name = siteID + case name == "": + s.name = siteID + default: + s.name = name + } + } + + log := logger.With("site_id", siteID, "site", siteLabel(siteID, s.name)) + collectSite(api, col, s, groups[siteID], rawByID, log) + } + collectNeighborWAN(api, col, logger) + return col, nil +} + +// collectNeighborWAN fetches the WAN interface listing of every tunnel +// peer outside the selected sites, once per device, so the remote end +// of a cross-site tunnel can be resolved to its transport interface +// (neighbors.go). Peers that are unknown or ambiguous in the inventory +// are not fetched. Each lookup is recorded in the coverage of every +// site whose tunnels need that peer, so a document's record counts only +// the lookups behind it. +func collectNeighborWAN(api managerAPI, col *collection, logger *slog.Logger) { + selected := map[string]bool{} + for _, s := range col.sites { + for _, o := range s.devices { + if o.SystemIP != "" { + selected[o.SystemIP] = true + } + } + } + needBy := map[*siteObs][]string{} + need := map[string]bool{} + for _, s := range col.sites { + mine := map[string]bool{} + for _, dev := range s.topology { + for _, c := range dev.Circuits { + for _, t := range c.Tunnels { + a, b, ok := parseTunnelEndpoints(t.Name) + if !ok { + continue + } + for _, k := range []string{a, b} { + ip, _ := splitTunnelKey(k) + if selected[ip] || mine[ip] { + continue // its own listing was already attempted. + } + if _, known := col.fabric.device(ip); known { + mine[ip] = true + need[ip] = true + needBy[s] = append(needBy[s], ip) + } + } + } + } + } + } + ips := make([]string, 0, len(need)) + for ip := range need { + ips = append(ips, ip) + } + sort.Strings(ips) + if len(ips) == 0 { + return + } + logger.Info("collecting WAN interfaces of tunnel peers outside the selected sites", "devices", len(ips), "workers", siteNameWorkers) + + type result struct { + rows int + err error + } + results := make(map[string]result, len(ips)) + + // Bounded worker pool; the requests/second cap is the client's + // --site-name-rate throttle (see GetPeerWANInterfaces). + var mu sync.Mutex + var wg sync.WaitGroup + sem := make(chan struct{}, siteNameWorkers) + done := 0 + for _, ip := range ips { + wg.Add(1) + sem <- struct{}{} + go func(ip string) { + defer wg.Done() + defer func() { <-sem }() + wan, err := api.GetPeerWANInterfaces(ip) + + mu.Lock() + defer mu.Unlock() + results[ip] = result{len(wan), err} + if err != nil { + logger.Warn("neighbor WAN interface listing failed (its tunnels stay unresolved)", "category", failureCategory(err), "err", err) + } else { + col.wanBySystemIP[ip] = wan + } + done++ + if done%25 == 0 || done == len(ips) { + logger.Info("tunnel peer WAN interfaces collected", "done", done, "total", len(ips)) + } + }(ip) + } + wg.Wait() + + for s, list := range needBy { + for _, ip := range list { + r := results[ip] + s.cov.record(opNeighborWAN, r.rows, r.err) + } + } +} + +// collectSite runs the per-device and per-site operations of one site. +func collectSite(api managerAPI, col *collection, s *siteObs, devices []Device, rawByID map[string]json.RawMessage, log *slog.Logger) { + var withIP int + for _, d := range devices { + if d.SystemIP != "" { + withIP++ + } + } + if withIP > 0 { + log.Info("collecting device interfaces and connections", "devices", withIP) + } + + for _, d := range devices { + o := &deviceObs{Device: d} + if col.wantRaw { + o.raw = rawByID[d.DeviceID] + } + s.devices = append(s.devices, o) + + if d.SystemIP == "" { + continue + } + if _, ok := personalityToType[d.Personality]; !ok { + continue // TransformDevices skips this device too. + } + dlog := log.With("device", d.HostName) + + ifaces, ifacesRaw, err := api.GetDeviceInterfacesWithRaw(d.SystemIP) + s.cov.record(opDeviceInterface, len(ifaces), err) + if err != nil { + dlog.Warn("interface listing failed (continuing without this device's interfaces)", "category", failureCategory(err), "err", err) + } else { + o.ifaces, o.ifacesRaw, o.ifacesOK = ifaces, ifacesRaw, true + } + + wan, wanRaw, err := api.GetWANInterfacesWithRaw(d.SystemIP) + s.cov.record(opWANInterface, len(wan), err) + if err != nil { + dlog.Warn("WAN interface listing failed (continuing with base interface data only)", "category", failureCategory(err), "err", err) + } else { + o.wan, o.wanRaw = wan, wanRaw + col.wanBySystemIP[d.SystemIP] = wan + } + + peers, peersRaw, err := api.GetOMPPeersWithRaw(d.SystemIP) + s.cov.record(opOMPPeers, len(peers), err) + if err != nil { + dlog.Warn("OMP peer listing failed (continuing without this device's OMP peering)", "category", failureCategory(err), "err", err) + } else { + o.peers, o.peersRaw = peers, peersRaw + } + + if o.ifacesOK { + dlog.Info("device interfaces collected", "rows", len(ifaces)) + } + } + + // GET /dataservice/topology/monitor/site/{siteId} has no siteId to + // call with for the unsited group. + if s.id == "" { + s.cov.skip(opSiteTopology, "unsited") + return + } + topo, topoRaw, err := api.GetSiteTopologyMonitorWithRaw(s.id) + s.cov.record(opSiteTopology, len(topo), err) + if err != nil { + log.Warn("site topology monitor failed (continuing without SD-WAN tunnel connections)", "category", failureCategory(err), "err", err) + return + } + s.topology, s.topologyRaw, s.topologyOK = topo, topoRaw, true +} + +// boolCount is 1 for true, for operations that return a single value. +func boolCount(b bool) int { + if b { + return 1 + } + return 0 +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/collect_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/collect_test.go new file mode 100644 index 0000000..b30e68b --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/collect_test.go @@ -0,0 +1,353 @@ +// collect_test.go - Tests for the collection stage, the coverage record +// and the run outcome contract of the Cisco Catalyst SD-WAN Manager +// OSIRIS JSON Producer, driven through a fake SD-WAN managerAPI. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "encoding/json" + "errors" + "net/http" + "os" + "path/filepath" + "sort" + "strings" + "sync" + "testing" + "time" + + "go.osirisjson.org/producers/pkg/sdk" +) + +// fakeAPI is an in-memory managerAPI. Per-device maps are keyed by +// system-ip; a key in the matching err map makes that call fail. +type fakeAPI struct { + devices []Device + devicesErr error + linksErr error + names map[string]string + + ifaces map[string][]Interface + ifacesErr map[string]error + wan map[string][]WANInterface + peers map[string][]OMPPeer + peersErr map[string]error + topo map[string][]SiteTopologyDevice + topoErr map[string]error + + mu sync.Mutex // guards calls, which concurrent peer lookups append to. + calls []string +} + +func (f *fakeAPI) GetDevicesWithRaw() ([]Device, []json.RawMessage, error) { + f.calls = append(f.calls, "device") + raws := make([]json.RawMessage, len(f.devices)) + for i := range raws { + raws[i] = json.RawMessage(`{}`) + } + return f.devices, raws, f.devicesErr +} + +func (f *fakeAPI) GetOMPLinks() ([]OMPLink, error) { + f.calls = append(f.calls, "omp_links") + return nil, f.linksErr +} + +func (f *fakeAPI) GetSiteName(siteID string) (string, error) { + f.calls = append(f.calls, "site_name:"+siteID) + return f.names[siteID], nil +} + +func (f *fakeAPI) GetDeviceInterfacesWithRaw(ip string) ([]Interface, []json.RawMessage, error) { + f.calls = append(f.calls, "device_interface:"+ip) + return f.ifaces[ip], nil, f.ifacesErr[ip] +} + +func (f *fakeAPI) GetWANInterfacesWithRaw(ip string) ([]WANInterface, []json.RawMessage, error) { + f.calls = append(f.calls, "wan_interface:"+ip) + return f.wan[ip], nil, nil +} + +func (f *fakeAPI) GetOMPPeersWithRaw(ip string) ([]OMPPeer, []json.RawMessage, error) { + f.calls = append(f.calls, "omp_peers:"+ip) + return f.peers[ip], nil, f.peersErr[ip] +} + +func (f *fakeAPI) GetSiteTopologyMonitorWithRaw(siteID string) ([]SiteTopologyDevice, []json.RawMessage, error) { + f.calls = append(f.calls, "site_topology:"+siteID) + var raws []json.RawMessage + for _, d := range f.topo[siteID] { + b, _ := json.Marshal(d) + raws = append(raws, b) + } + return f.topo[siteID], raws, f.topoErr[siteID] +} + +func (f *fakeAPI) GetPeerWANInterfaces(ip string) ([]WANInterface, error) { + f.mu.Lock() + f.calls = append(f.calls, "wan_interface:"+ip) + f.mu.Unlock() + return f.wan[ip], nil +} + +func (f *fakeAPI) called(name string) bool { + f.mu.Lock() + defer f.mu.Unlock() + for _, c := range f.calls { + if c == name { + return true + } + } + return false +} + +// twoSiteFake is a fabric of one cEdge in each of sites 100 and 200. +func twoSiteFake() *fakeAPI { + return &fakeAPI{ + devices: []Device{ + {DeviceID: "192.0.2.11", SystemIP: "192.0.2.11", HostName: "LAB-RTR01", UUID: "TST-UUID-0001", SiteID: "100", Personality: "vedge", BoardSerial: "TST0000001"}, + {DeviceID: "192.0.2.12", SystemIP: "192.0.2.12", HostName: "LAB-RTR02", UUID: "TST-UUID-0002", SiteID: "200", Personality: "vedge", BoardSerial: "TST0000002"}, + }, + names: map[string]string{"100": "BRANCH-00", "200": "OFFICE-00"}, + ifaces: map[string][]Interface{ + "192.0.2.11": {{IfName: "ge0/0", AFType: "ipv4", VPNID: "0", IfAdminStatus: "Up", IfOperStatus: "Up"}}, + "192.0.2.12": {{IfName: "ge0/0", AFType: "ipv4", VPNID: "0", IfAdminStatus: "Up", IfOperStatus: "Up"}}, + }, + } +} + +func testConfig(t *testing.T) *Config { + t.Helper() + return &Config{ + Host: "lab-manager01.example.com", OutputDir: t.TempDir(), + SafeFailureMode: sdk.FailClosed, Purpose: "documentation", + AllSites: true, SiteNameRateLimit: 1000, + } +} + +var fixedRun = time.Date(2026, 11, 13, 12, 0, 0, 0, time.UTC) + +func denied(op string) error { + return &apiError{Op: op, Status: http.StatusForbidden, Category: categoryDenied} +} + +func TestCollect_InterfaceFailureDoesNotSkipIndependentOperations(t *testing.T) { + f := twoSiteFake() + f.ifacesErr = map[string]error{"192.0.2.11": denied("/dataservice/device/interface")} + col, err := collect(f, testConfig(t), testLogger(t)) + if err != nil { + t.Fatal(err) + } + for _, c := range []string{"wan_interface:192.0.2.11", "omp_peers:192.0.2.11", "site_topology:100"} { + if !f.called(c) { + t.Errorf("%s was not attempted after the interface listing failed", c) + } + } + cov := col.siteCoverage(col.sites[0]) + if cov.complete() { + t.Error("site 100 coverage must be incomplete") + } + got := cov.metadata()["coverage"].([]any) + var iface map[string]any + for _, e := range got { + if m := e.(map[string]any); m["operation"] == opDeviceInterface { + iface = m + } + } + if iface["status"] != statusFailed || iface["categories"].(map[string]any)[categoryDenied] != 1 { + t.Errorf("device_interface coverage = %v, want failed with one denied", iface) + } + if !col.siteCoverage(col.sites[1]).complete() { + t.Error("site 200 coverage must be complete") + } +} + +func TestCollect_InventoryFailureAborts(t *testing.T) { + f := twoSiteFake() + f.devicesErr = denied("/dataservice/device") + if _, err := collect(f, testConfig(t), testLogger(t)); err == nil { + t.Fatal("expected an inventory failure to abort collection") + } + if f.called("omp_links") { + t.Error("no further operation may run after the inventory failed") + } +} + +func TestCoverage_StatusesAndMerge(t *testing.T) { + var c coverage + c.record("a", 2, nil) + c.record("b", 0, nil) + c.record("c", 1, nil) + c.record("c", 0, denied("/x")) + c.record("d", 0, &apiError{Op: "/y", Category: categoryMalformed}) + c.skip("e", "unsited") + want := map[string]string{"a": statusSucceeded, "b": statusEmpty, "c": statusPartial, "d": statusFailed, "e": statusSkipped} + for op, st := range want { + if got := c.ops[op].status(); got != st { + t.Errorf("%s status = %s, want %s", op, got, st) + } + } + if c.complete() { + t.Error("coverage with failures reported complete") + } + m := merged(&coverage{}, &c) + if m.ops["c"].attempts != 2 || m.ops["c"].categories[categoryDenied] != 1 { + t.Errorf("merged c = %+v", m.ops["c"]) + } + if gaps := c.gaps(); len(gaps) != 2 || !strings.HasPrefix(gaps[0], "c (partial: denied)") { + t.Errorf("gaps = %v", gaps) + } +} + +func TestExport_PartialRunContract(t *testing.T) { + for _, requireComplete := range []bool{false, true} { + f := twoSiteFake() + f.peersErr = map[string]error{"192.0.2.12": denied("/dataservice/device/omp/peers")} + cfg := testConfig(t) + cfg.RequireComplete = requireComplete + err := export(f, cfg, testLogger(t), fixedRun) + if requireComplete && err == nil { + t.Error("--require-complete: expected an error for a partial document") + } + if !requireComplete && err != nil { + t.Errorf("partial run without --require-complete: %v", err) + } + files := writtenFiles(t, cfg.OutputDir) + if len(files) != 2 { + t.Fatalf("require-complete=%v: %d documents written, want 2", requireComplete, len(files)) + } + for _, p := range files { + doc := readDoc(t, p) + ext := doc["metadata"].(map[string]any)[extensionKey].(map[string]any) + wantComplete := !strings.Contains(p, "OFFICE-00") + if ext["complete"] != wantComplete { + t.Errorf("%s complete = %v, want %v", filepath.Base(p), ext["complete"], wantComplete) + } + if ext["api_profile"] != apiProfileUnverified { + t.Errorf("api_profile = %v", ext["api_profile"]) + } + } + } +} + +func TestExport_SiteWriteFailureFailsTheRunAfterOtherSites(t *testing.T) { + f := twoSiteFake() + cfg := testConfig(t) + // A file where site 100's directory should be makes its write fail. + if err := os.WriteFile(filepath.Join(cfg.OutputDir, "BRANCH-00"), []byte("x"), 0o600); err != nil { + t.Fatal(err) + } + err := export(f, cfg, testLogger(t), fixedRun) + if err == nil || !strings.Contains(err.Error(), "1 of 2 site(s) not written") { + t.Fatalf("err = %v, want one site not written", err) + } + if files := writtenFiles(t, cfg.OutputDir); len(files) != 1 || !strings.Contains(files[0], "OFFICE-00") { + t.Errorf("written = %v, want only the OFFICE-00 document", files) + } +} + +func TestExport_OneTimestampPerRun(t *testing.T) { + f := twoSiteFake() + cfg := testConfig(t) + if err := export(f, cfg, testLogger(t), fixedRun); err != nil { + t.Fatal(err) + } + for _, p := range writtenFiles(t, cfg.OutputDir) { + if !strings.Contains(filepath.Base(p), "2026-11-13T12-00-00Z") { + t.Errorf("%s does not carry the run timestamp", p) + } + if ts := readDoc(t, p)["metadata"].(map[string]any)["timestamp"]; ts != "2026-11-13T12:00:00Z" { + t.Errorf("metadata.timestamp = %v", ts) + } + } +} + +func TestDecodeListResponse_DistinguishesMalformedFromEmpty(t *testing.T) { + tests := []struct { + body string + category string // "" = success. + n int + }{ + {`{"data":[{"ifname":"ge0/0"}]}`, "", 1}, + {`[{"ifname":"ge0/0"}]`, "", 1}, + {`{"data":[]}`, "", 0}, + {`{"data":null}`, "", 0}, + {`[]`, "", 0}, + {``, categoryMalformed, 0}, + {`{}`, categoryMalformed, 0}, + {`{"error":{"message":"x"}}`, categoryServerError, 0}, + {`{"data":"x"}`, categoryMalformed, 0}, + {``, categoryMalformed, 0}, + } + for _, tt := range tests { + items, err := decodeListResponse[Interface]("/dataservice/device/interface", []byte(tt.body)) + if got := map[bool]string{true: failureCategory(err), false: ""}[err != nil]; got != tt.category { + t.Errorf("%q: category = %q, want %q", tt.body, got, tt.category) + } + if len(items) != tt.n { + t.Errorf("%q: %d items, want %d", tt.body, len(items), tt.n) + } + } +} + +func TestDevice_TimestampsAcceptStringAndNumber(t *testing.T) { + var devices []Device + body := `[{"lastupdated":"1634627015139","uptime-date":1634626320000},{"lastupdated":"","uptime-date":null},{"lastupdated":"n/a"}]` + if err := json.Unmarshal([]byte(body), &devices); err != nil { + t.Fatalf("schema-shaped string timestamps must decode: %v", err) + } + if devices[0].LastUpdated != 1634627015139 || devices[0].UptimeDate != 1634626320000 { + t.Errorf("decoded %+v", devices[0]) + } + if devices[1].LastUpdated != 0 || devices[2].LastUpdated != 0 { + t.Error("empty, null and non-numeric timestamps must decode to 0") + } +} + +func TestReadBounded_TooLarge(t *testing.T) { + old := maxResponseBytes + maxResponseBytes = 8 + defer func() { maxResponseBytes = old }() + if _, err := readBounded(strings.NewReader("123456789")); !errors.Is(err, errResponseTooLarge) { + t.Errorf("err = %v, want errResponseTooLarge", err) + } + if b, err := readBounded(strings.NewReader("12345678")); err != nil || len(b) != 8 { + t.Errorf("at the limit: %q, %v", b, err) + } +} + +func TestRetryDelay_RetryAfterIsCapped(t *testing.T) { + resp := &http.Response{Header: http.Header{"Retry-After": []string{"3600"}}} + if d := retryDelay(resp, 0); d != maxRetryDelay { + t.Errorf("retryDelay = %v, want capped %v", d, maxRetryDelay) + } +} + +func writtenFiles(t *testing.T, root string) []string { + t.Helper() + var out []string + filepath.WalkDir(root, func(p string, d os.DirEntry, err error) error { + if err == nil && !d.IsDir() && strings.HasSuffix(p, ".json") { + out = append(out, p) + } + return nil + }) + sort.Strings(out) + return out +} + +func readDoc(t *testing.T, p string) map[string]any { + t.Helper() + data, err := os.ReadFile(p) + if err != nil { + t.Fatal(err) + } + var m map[string]any + if err := json.Unmarshal(data, &m); err != nil { + t.Fatal(err) + } + return m +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/config.go b/osiris/network/cisco/catalyst-sd-wan-manager/config.go new file mode 100644 index 0000000..d362ca3 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/config.go @@ -0,0 +1,172 @@ +// config.go - Configuration types for the Cisco Catalyst SD-WAN Manager +// OSIRIS JSON producer. +// +// SD-WAN Manager is a single WAN-overlay controller: one login +// authenticates against one controller (reachable at a +// customer-specific domain such as sdwan-manager.example.com) which +// manages many WAN edge sites. A single SD-WAN Manager run fans out +// into many documents: one per WAN edge site, grouped by device +// site-id. +// +// Output hierarchy (see OutputPath below), one document per site +// regardless of how many sites the controller reports: +// +// / +// / +// cisco-catalyst-sdwan-manager--.json +// +// defaults to defaultOutputDir when --output is not given. +// A fixed, non-timestamped directory name lets a re-run from the same +// working directory (or the same explicit --output) naturally reuse it: +// a second run adds each site's new timestamped file alongside the +// previous ones instead of scattering a new dated directory per run. +// Directories this producer creates are private (0700) and documents +// are published atomically as private files (0600), see output.go. +// +// SD-WAN Manager's device inventory (GET /dataservice/device) has no +// human-readable site name field, only a numeric site-id, the display +// name used here and in metadata.scope.sites is resolved separately via +// GET /dataservice/topology/device/site/{siteId} (see sites_select.go); +// OutputPath falls back to the "unsited" segment when no name is +// available (empty siteName), the same fallback used for devices with +// no site-id at all. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification + +package catalystsdwanmanager + +import ( + "fmt" + "path/filepath" + "strings" + "unicode" +) + +// defaultOutputDir is the --output value used when the flag is omitted. +const defaultOutputDir = "osirisjson-cisco-catalyst-sdwan-manager" + +// defaultSiteNameRateLimit is the --site-name-rate value used when the +// flag is omitted: 10 requests/second. SD-WAN Manager's rate limit is +// typically shared across every consumer polling the same controller +// (monitoring systems, other automation, not just this producer), so +// this defaults conservatively, tune with --site-name-rate based on +// your own environment's actual headroom, see client.go's +// throttleSiteName. +const defaultSiteNameRateLimit = 10 + +// unsitedSegment is the OutputPath/scope fallback for devices SD-WAN +// Manager has not assigned to a site (empty site-id). +const unsitedSegment = "unclaimed" + +// Config carries runtime settings resolved from CLI flags. +type Config struct { + Host string // controller FQDN or IP. + Port int // 0 = use defaultPort. + Username string + Password string + InsecureTLS bool // --insecure: skip TLS verify. + + OutputDir string + SafeFailureMode string + + // Purpose is the OSIRIS JSON spec section 13.1.3 output grade. + Purpose string + + // SiteFilter is the explicit --site value (site-id list, unsitedSegment + // selects devices with no site-id). Empty when --site was not given. + SiteFilter []string + // AllSites is --all: collect every discovered site non-interactively, + // skipping the picker. Mutually exclusive with SiteFilter. + AllSites bool + + // SiteNameRateLimit caps requests/second for bulk site-name + // resolution (see client.go's throttleSiteName), independent of + // worker concurrency. Defaults to defaultSiteNameRateLimit. + SiteNameRateLimit int + + // RequireComplete is --require-complete: a run whose documents + // are all written but where an optional operation failed (see the + // coverage record) exits with an error instead of success. + RequireComplete bool + + // IncludeRawBody attaches each collected endpoint's API rows, + // recursively redacted and size-capped (see raw.go), under + // extensions["osiris.cisco.catalystsdwanmanager"] on the owning + // device resource, a fallback for fields this producer doesn't + // model yet into OSIRIS JSON. Only takes effect when + // '--purpose audit' flag is declared. + IncludeRawBody bool +} + +// OutputPath returns the hierarchical output path for one site's +// document: +// //cisco-catalyst-sdwan-manager--.json +// +// segment is the site's display name made safe by +// sanitizeFilenameSegment (see siteSegments for the per-run collision +// policy) an empty result (no site-id at all, or a name that +// sanitizes to nothing) maps to the "unclaimed" segment. The directory +// is not required to be new: writeDocument reuses an existing +// directory and adds the new timestamped file alongside +// whatever is already there, never overwriting an existing file. +func OutputPath(outputDir, timestamp, siteName string) string { + segment := sanitizeFilenameSegment(siteName) + if segment == "" { + segment = unsitedSegment + } + filename := fmt.Sprintf("cisco-catalyst-sdwan-manager-%s-%s.json", timestamp, segment) + return filepath.Join(outputDir, segment, filename) +} + +// sanitizeFilenameSegment turns a display label into one safe path +// component (on any of Linux/macOS/Windows): path separators, reserved +// characters, whitespace and control characters become "-", and +// leading/trailing dots are trimmed, so the result can never be "." or +// "..", a hidden name or a name Windows rejects. It returns "" when +// nothing remains; callers fall back to unsitedSegment. +func sanitizeFilenameSegment(s string) string { + mapped := strings.Map(func(r rune) rune { + switch r { + case '/', '\\', ':', '*', '?', '"', '<', '>', '|': + return '-' + } + if r < 0x20 || r == 0x7f || unicode.IsSpace(r) || !unicode.IsPrint(r) { + return '-' + } + return r + }, s) + return strings.Trim(mapped, ".") +} + +// siteSegments assigns each site of one run a distinct output path +// component. Two different site-ids whose display names sanitize to +// the same component (case-insensitively, so case-folding filesystems +// cannot merge them either) would otherwise write into one directory +// with colliding file names; every site after the first to claim a +// component gets its sanitized site-id appended. The zero value is +// ready to use. +type siteSegments struct { + owner map[string]string // lower-cased segment -> site-id. +} + +// segment returns the output path component for siteID/siteName. +func (s *siteSegments) segment(siteID, siteName string) string { + if s.owner == nil { + s.owner = map[string]string{} + } + seg := sanitizeFilenameSegment(siteName) + if seg == "" { + seg = unsitedSegment + } + if id, taken := s.owner[strings.ToLower(seg)]; taken && id != siteID { + suffix := sanitizeFilenameSegment(siteID) + if suffix == "" { + suffix = unsitedSegment + } + seg = seg + "-" + suffix + } + s.owner[strings.ToLower(seg)] = siteID + return seg +} diff --git a/osiris/network/cisco/vmanage/config_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/config_test.go similarity index 80% rename from osiris/network/cisco/vmanage/config_test.go rename to osiris/network/cisco/catalyst-sd-wan-manager/config_test.go index dad3a39..43a721e 100644 --- a/osiris/network/cisco/vmanage/config_test.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/config_test.go @@ -1,16 +1,16 @@ // config_test.go - Tests for the per-site OutputPath convention. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import "testing" func TestOutputPath(t *testing.T) { got := OutputPath("/out", "2026-08-08T10-00-00Z", "MXP") - want := "/out/MXP/cisco-vmanage-2026-08-08T10-00-00Z-MXP.json" + want := "/out/MXP/cisco-catalyst-sdwan-manager-2026-08-08T10-00-00Z-MXP.json" if got != want { t.Errorf("OutputPath = %q, want %q", got, want) } @@ -18,7 +18,7 @@ func TestOutputPath(t *testing.T) { func TestOutputPath_UnsitedFallback(t *testing.T) { got := OutputPath("/out", "2026-08-08T10-00-00Z", "") - want := "/out/unclaimed/cisco-vmanage-2026-08-08T10-00-00Z-unclaimed.json" + want := "/out/unclaimed/cisco-catalyst-sdwan-manager-2026-08-08T10-00-00Z-unclaimed.json" if got != want { t.Errorf("OutputPath = %q, want %q", got, want) } @@ -26,7 +26,7 @@ func TestOutputPath_UnsitedFallback(t *testing.T) { func TestOutputPath_SanitizesUnsafeCharacters(t *testing.T) { got := OutputPath("/out", "2026-08-08T10-00-00Z", "site/with:bad*chars") - want := "/out/site-with-bad-chars/cisco-vmanage-2026-08-08T10-00-00Z-site-with-bad-chars.json" + want := "/out/site-with-bad-chars/cisco-catalyst-sdwan-manager-2026-08-08T10-00-00Z-site-with-bad-chars.json" if got != want { t.Errorf("OutputPath = %q, want %q", got, want) } diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/contract_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/contract_test.go new file mode 100644 index 0000000..825b8ea --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/contract_test.go @@ -0,0 +1,120 @@ +// contract_test.go - Per-release API contract tests (20.18, 26.1, 26.2) +// for the Cisco Catalyst SD-WAN Manager OSIRIS JSON Producer. +// +// Each testdata contract_ scenario answers every endpoint the +// producer calls with bodies that carry exactly the keys of that +// release's documented example response (the 26.2 interface rows add +// fec-mode), with synthetic values. The inventory mixes the example's +// typing (integer timestamps) with the published schema's (string +// timestamps and longitude). For every release, every site document +// must be complete, keep the cross-site tunnel and the OMP sessions, +// resolve every endpoint, and describe the same topology as every +// other release: the documented contract changes between these +// releases do not change the emitted graph. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "encoding/json" + "os" + "path/filepath" + "reflect" + "sort" + "testing" + + "go.osirisjson.org/producers/pkg/sdk" +) + +var contractReleases = []string{"contract_20_18", "contract_26_1", "contract_26_2"} + +// contractExport runs the full export against one release scenario and +// returns its documents by site name. +func contractExport(t *testing.T, dir, purpose string) map[string]sdk.Document { + t.Helper() + ts := goldenServer(t, filepath.Join(goldenRoot, dir)) + defer ts.Close() + host, port := splitHostPort(t, ts.Listener.Addr().String()) + cfg := &Config{ + Host: host, Port: port, Username: "admin", Password: "changeme", + OutputDir: t.TempDir(), SafeFailureMode: sdk.FailClosed, Purpose: purpose, + InsecureTLS: true, AllSites: true, SiteNameRateLimit: 1000, RequireComplete: true, + } + if err := runExport(cfg); err != nil { + t.Fatalf("%s: runExport: %v", dir, err) + } + docs := map[string]sdk.Document{} + for _, p := range writtenFiles(t, cfg.OutputDir) { + data, err := os.ReadFile(p) + if err != nil { + t.Fatal(err) + } + var d sdk.Document + if err := json.Unmarshal(data, &d); err != nil { + t.Fatal(err) + } + docs[d.Metadata.Scope.Sites[0]] = d + } + return docs +} + +// graphShape is the release-independent view of a document: resource +// IDs and types, connection IDs with endpoints, and group members. +func graphShape(d sdk.Document) []string { + var out []string + for _, r := range d.Topology.Resources { + out = append(out, "r "+r.ID+" "+r.Type) + } + for _, c := range d.Topology.Connections { + out = append(out, "c "+c.ID+" "+c.Source+" "+c.Target) + } + for _, g := range d.Topology.Groups { + for _, m := range g.Members { + out = append(out, "g "+g.ID+" "+m) + } + } + sort.Strings(out) + return out +} + +func TestContract_EveryReleaseYieldsTheSameCompleteGraph(t *testing.T) { + for _, purpose := range []string{"documentation", "audit"} { + var reference map[string][]string + for _, rel := range contractReleases { + docs := contractExport(t, rel, purpose) + if len(docs) != 3 { + t.Fatalf("%s/%s: %d documents, want 3", rel, purpose, len(docs)) + } + shapes := map[string][]string{} + for site, d := range docs { + meta := extOf(d.Metadata.Extensions) + if meta["complete"] != true { + t.Errorf("%s/%s/%s: document is partial: %v", rel, purpose, site, meta["coverage"]) + } + graph := meta["graph"].(map[string]any) + for k, v := range graph { + if k != "neighbor_devices" && k != "neighbor_interfaces" && v != float64(0) { + t.Errorf("%s/%s/%s: graph %s = %v, want 0", rel, purpose, site, k, v) + } + } + shapes[site] = graphShape(d) + } + for _, site := range []string{"BRANCH-00", "OFFICE-00"} { + d := docs[site] + if n := len(connsOfType(d, "network.vpn")); n != 1 { + t.Errorf("%s/%s/%s: %d tunnels, want 1", rel, purpose, site, n) + } + if n := len(connsOfType(d, "network")); n != 1 { + t.Errorf("%s/%s/%s: %d OMP sessions, want 1", rel, purpose, site, n) + } + } + if reference == nil { + reference = shapes + } else if !reflect.DeepEqual(shapes, reference) { + t.Errorf("%s/%s: graph differs from %s", rel, purpose, contractReleases[0]) + } + } + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/coverage.go b/osiris/network/cisco/catalyst-sd-wan-manager/coverage.go new file mode 100644 index 0000000..4e493ba --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/coverage.go @@ -0,0 +1,237 @@ +// coverage.go - Discovery-coverage record for the Cisco Catalyst +// SD-WAN Manager OSIRIS JSON Producer. +// +// Every API operation the producer attempts is recorded once per +// attempt and aggregated per operation. Each document carries the +// record of the operations that fed it (the controller-wide ones and +// its own site's) as metadata["osiris.cisco.catalystsdwanmanager"]: +// +// { +// "api_profile": "unverified", +// "complete": false, +// "coverage": [ +// {"operation": "device_interface","status": "partial", +// "attempts": 3, "failed": 1, "count": 14, +// "categories": {"denied": 1}} +// ] +// } +// +// Statuses: succeeded (every attempt answered, at least one row), +// empty (every attempt answered, no rows), partial (some attempts +// failed), failed (every attempt failed) and skipped (not attempted, +// with a reason). complete is false when any operation is partial or +// failed, so an OSIRIS JSON Consumer holding only the document can tell +// "the Manager has none" from "this producer could not ask". Failure +// categories are the fixed labels of apierror.go and never carry +// response or transport text. api_profile is "unverified": no trusted +// operation identifies the Manager release, so the reply shapes of the +// documented 20.18, 26.1 and 26.2 Cisco API contracts are all accepted. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "sort" + "strings" +) + +// Operation names in the coverage record, in render order. +const ( + opDevice = "device" + opOMPLinks = "omp_links" + opSiteName = "site_name" + opDeviceInterface = "device_interface" + opWANInterface = "wan_interface" + opOMPPeers = "omp_peers" + opSiteTopology = "site_topology" + opNeighborWAN = "neighbor_wan_interface" +) + +var opOrder = []string{opDevice, opOMPLinks, opSiteName, opDeviceInterface, opWANInterface, opOMPPeers, opSiteTopology, opNeighborWAN} + +// Coverage statuses. +const ( + statusSucceeded = "succeeded" + statusEmpty = "empty" + statusPartial = "partial" + statusFailed = "failed" + statusSkipped = "skipped" +) + +// apiProfileUnverified labels documents collected without a declared +// or discovered Manager release. +const apiProfileUnverified = "unverified" + +// opStat aggregates every attempt of one operation. +type opStat struct { + attempts, failed, count int + categories map[string]int + skipReason string +} + +// coverage accumulates operation outcomes. The zero value is ready to +// use. +type coverage struct { + ops map[string]*opStat +} + +func (c *coverage) stat(op string) *opStat { + if c.ops == nil { + c.ops = map[string]*opStat{} + } + s, ok := c.ops[op] + if !ok { + s = &opStat{} + c.ops[op] = s + } + return s +} + +// record adds one attempt of op that returned count rows or failed +// with err. +func (c *coverage) record(op string, count int, err error) { + s := c.stat(op) + s.attempts++ + if err != nil { + s.failed++ + if s.categories == nil { + s.categories = map[string]int{} + } + s.categories[failureCategory(err)]++ + return + } + s.count += count +} + +// skip records op as not attempted for reason, unless it was attempted. +func (c *coverage) skip(op, reason string) { + s := c.stat(op) + if s.attempts == 0 && s.skipReason == "" { + s.skipReason = reason + } +} + +// merged returns a new coverage holding the attempts of every given +// record. +func merged(records ...*coverage) *coverage { + out := &coverage{} + for _, r := range records { + if r == nil { + continue + } + for op, s := range r.ops { + d := out.stat(op) + d.attempts += s.attempts + d.failed += s.failed + d.count += s.count + for k, v := range s.categories { + if d.categories == nil { + d.categories = map[string]int{} + } + d.categories[k] += v + } + if d.attempts == 0 && d.skipReason == "" { + d.skipReason = s.skipReason + } + } + } + return out +} + +func (s *opStat) status() string { + switch { + case s.attempts == 0: + return statusSkipped + case s.failed == s.attempts: + return statusFailed + case s.failed > 0: + return statusPartial + case s.count > 0: + return statusSucceeded + } + return statusEmpty +} + +// complete reports whether no operation failed, fully or partially. +func (c *coverage) complete() bool { + for _, s := range c.ops { + if s.failed > 0 { + return false + } + } + return true +} + +// gaps returns "operation (status: categories)" for every partial or +// failed operation, in render order, for diagnostics. +func (c *coverage) gaps() []string { + var out []string + for _, op := range c.order() { + s := c.ops[op] + if s.failed == 0 { + continue + } + cats := make([]string, 0, len(s.categories)) + for k := range s.categories { + cats = append(cats, k) + } + sort.Strings(cats) + out = append(out, op+" ("+s.status()+": "+strings.Join(cats, ",")+")") + } + return out +} + +// order returns the recorded operations in opOrder, then any other +// operation alphabetically. +func (c *coverage) order() []string { + known := map[string]bool{} + var out []string + for _, op := range opOrder { + known[op] = true + if _, ok := c.ops[op]; ok { + out = append(out, op) + } + } + var rest []string + for op := range c.ops { + if !known[op] { + rest = append(rest, op) + } + } + sort.Strings(rest) + return append(out, rest...) +} + +// metadata renders the record as the producer's metadata extension +// value (see the file comment). +func (c *coverage) metadata() map[string]any { + ops := make([]any, 0, len(c.ops)) + for _, op := range c.order() { + s := c.ops[op] + m := map[string]any{ + "operation": op, + "status": s.status(), + "attempts": s.attempts, + "count": s.count, + } + if s.failed > 0 { + m["failed"] = s.failed + cats := make(map[string]any, len(s.categories)) + for k, v := range s.categories { + cats[k] = v + } + m["categories"] = cats + } + if s.skipReason != "" && s.attempts == 0 { + m["reason"] = s.skipReason + } + ops = append(ops, m) + } + return map[string]any{ + "api_profile": apiProfileUnverified, + "complete": c.complete(), + "coverage": ops, + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/document.go b/osiris/network/cisco/catalyst-sd-wan-manager/document.go new file mode 100644 index 0000000..42fd59a --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/document.go @@ -0,0 +1,407 @@ +// document.go - Per-site document build stage of the Cisco Catalyst +// SD-WAN Manager OSIRIS JSON Producer. +// +// buildSiteDocument turns one collected site (collect.go) into a +// portable OSIRIS JSON document without any API call: +// +// 1. the site's own devices and interfaces, with provider.site (the +// site name, OSIRIS JSON's facility identifier; the raw site-id is +// extension site_id) and provider.system (the Manager host); +// 2. OMP sessions and transport tunnels with at least one endpoint in +// the site, the remote endpoint resolved against the whole +// controller inventory and carried as a neighbor resource when it +// belongs to another site (neighbors.go); +// 3. the logical.site group of the site's own resources; +// 4. raw row attachment (raw.go), the --purpose field contract +// (purpose.go) and secret handling; +// 5. the SDK build plus the producer metadata: coverage (coverage.go) +// and the graph record below. +// +// The graph record, under metadata["osiris.cisco.catalystsdwanmanager"] +// "graph", counts what crossed or failed to cross the site boundary: +// neighbor devices and interfaces included, OMP sessions and tunnels +// omitted because an endpoint was unknown or ambiguous, tunnel names +// not in the documented form, and inventory devices skipped for lack of +// a native identity. +// +// Every document of one run shares the run's single timestamp. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "encoding/json" + "log/slog" + "strings" + "time" + + "go.osirisjson.org/producers/pkg/sdk" +) + +// graphStats is the graph record of one site document. +type graphStats struct { + neighborDevices int + neighborInterfaces int + unresolvedOMP int + unresolvedTunnels int + unparsedTunnels int + unidentified int +} + +func (g graphStats) metadata() map[string]any { + return map[string]any{ + "neighbor_devices": g.neighborDevices, + "neighbor_interfaces": g.neighborInterfaces, + "unresolved_omp": g.unresolvedOMP, + "unresolved_tunnels": g.unresolvedTunnels, + "unparsed_tunnels": g.unparsedTunnels, + "unidentified_devices": g.unidentified, + } +} + +// buildSiteDocument builds the document of site s from col now is the +// run timestamp. +func buildSiteDocument(col *collection, s *siteObs, cfg *Config, now time.Time, log *slog.Logger) (*sdk.Document, error) { + ctx := sdk.NewContext(&sdk.ProducerConfig{ + SafeFailureMode: cfg.SafeFailureMode, + Purpose: cfg.Purpose, + }) + ctx.Logger = log + ctx.Clock = func() time.Time { return now } + stats := graphStats{unidentified: col.unidentified} + + devices := make([]Device, len(s.devices)) + for i, o := range s.devices { + devices[i] = o.Device + } + resources, _ := TransformDevices(devices, cfg.Purpose) + var connections []sdk.Connection + + deviceResIdx := make(map[string]int, len(resources)) + for i, r := range resources { + deviceResIdx[r.ID] = i + } + + rawRows := newRawCollector(col.wantRaw) + local := map[string]bool{} // resource IDs of this site. + localSystemIP := map[string]string{} // system IP -> local device ID. + ifaceIndex := map[string]string{} // "{system-ip}:{color}" -> local interface ID, "" = ambiguous. + deviceIDToResID := map[string]string{} + for _, o := range s.devices { + resType, ok := personalityToType[o.Personality] + if !ok { + continue + } + deviceKey := deviceNativeKey(o.Device, resType) + if deviceKey == "" { + continue + } + resID := resourceID(deviceKey) + idx, ok := deviceResIdx[resID] + if !ok { + continue + } + local[resID] = true + if o.DeviceID != "" { + deviceIDToResID[o.DeviceID] = resID + } + if o.raw != nil { + rawRows.attachOne(&resources[idx], "raw", o.raw) + } + if o.SystemIP == "" { + continue + } + if x, ok := col.fabric.device(o.SystemIP); ok && x.id == resID { + localSystemIP[o.SystemIP] = resID + } + if o.ifacesOK { + ifaceResources, containsConns, tunnelIndex := TransformInterfaces(resID, resType, deviceKey, o.SystemIP, o.ifaces, o.wan) + for _, r := range ifaceResources { + local[r.ID] = true + } + resources = append(resources, ifaceResources...) + connections = append(connections, containsConns...) + for k, v := range tunnelIndex { + addTunnelEndpoint(ifaceIndex, k, v) + } + } + rawRows.attachList(&resources[idx], "interfaces_raw", o.ifacesRaw) + rawRows.attachList(&resources[idx], "wan_interfaces_raw", o.wanRaw) + rawRows.attachList(&resources[idx], "omp_peers_raw", o.peersRaw) + } + + siteNames := map[string]string{} + for _, other := range col.sites { + if other.id != "" { + siteNames[other.id] = other.name + } + } + neighbors := newNeighborSet(cfg.Host, siteNames) + + // resolveDevice maps a system IP to a local device or a neighbor + // candidate; false for an unknown or ambiguous system IP. + resolveDevice := func(systemIP string) (string, bool) { + if id, ok := localSystemIP[systemIP]; ok { + return id, true + } + x, ok := col.fabric.device(systemIP) + if !ok { + return "", false + } + return neighbors.proposeDevice(x), true + } + + // OMP: global links touching this site, plus this site's devices + // own peer lists, reconciled into one connection per pair. + var omp []ompObservation + for _, l := range col.ompLinks { + _, aLocal := localSystemIP[l.ASystemIP] + _, bLocal := localSystemIP[l.BSystemIP] + if !aLocal && !bLocal { + continue // another site's session. + } + a, okA := resolveDevice(l.ASystemIP) + b, okB := resolveDevice(l.BSystemIP) + if !okA || !okB { + stats.unresolvedOMP++ + continue + } + omp = append(omp, ompObservation{a: a, b: b, state: l.State, source: opOMPLinks}) + } + // Peer lists of every collected device, so a session seen from both + // ends (for example an edge and its controller, both selected) is + // reconciled the same way in every site document that carries it. + for _, other := range col.sites { + for _, o := range other.devices { + for _, p := range o.peers { + _, selfLocal := localSystemIP[o.SystemIP] + _, peerLocal := localSystemIP[p.Peer] + if !selfLocal && !peerLocal { + continue + } + self, okA := resolveDevice(o.SystemIP) + peer, okB := resolveDevice(p.Peer) + if !okA || !okB { + if selfLocal { + stats.unresolvedOMP++ + } + continue + } + omp = append(omp, ompObservation{a: self, b: peer, state: p.State, source: opOMPPeers}) + } + } + } + ompConns := TransformOMP(omp) + + // Tunnels: the local end resolves through this site's interfaces; + // the remote end through the peer device's WAN interface listing. + var tunnelConns []sdk.Connection + if s.topologyOK { + resolveTunnelEnd := func(key string) (string, bool) { + if id, ok := ifaceIndex[key]; ok { + return id, id != "" + } + ip, color := splitTunnelKey(key) + if _, isLocal := localSystemIP[ip]; isLocal { + return "", false // a local device without that interface. + } + x, ok := col.fabric.device(ip) + if !ok { + return "", false + } + var ifname string + for _, w := range col.wanBySystemIP[ip] { + if w.Color != color || w.Interface == "" { + continue + } + if ifname != "" && ifname != w.Interface { + return "", false // two interfaces on one color: ambiguous. + } + ifname = w.Interface + } + if ifname == "" { + return "", false + } + return neighbors.proposeInterface(x, ifname, color), true + } + var tstats tunnelStats + tunnelConns, tstats = TransformTunnels(s.topology, resolveTunnelEnd) + stats.unresolvedTunnels, stats.unparsedTunnels = tstats.unresolved, tstats.unparsed + // Keep only tunnels with at least one end in this site. + kept := tunnelConns[:0] + for _, c := range tunnelConns { + if local[c.Source] || local[c.Target] { + kept = append(kept, c) + } + } + tunnelConns = kept + + // Each entry is matched back to its device resource (see + // topologyOwner); an entry with no owner is counted in + // raw_omitted, never dropped silently. + if col.wantRaw && len(memberDeviceIDs(resources, local)) > 0 { + fallback := memberDeviceIDs(resources, local)[0] + if len(s.topology) != len(s.topologyRaw) { + rawRows.omit(fallback, "site_topology_raw", rawOmitUnparseable, len(s.topologyRaw)) + } else { + for i, st := range s.topology { + if resID := topologyOwner(st, deviceIDToResID, localSystemIP); resID != "" { + rawRows.attachOne(&resources[deviceResIdx[resID]], "site_topology_raw", s.topologyRaw[i]) + } else { + rawRows.omit(fallback, "site_topology_raw", rawOmitUnowned, 1) + } + } + } + } + } + if len(ompConns) > 0 { + log.Info("OMP peering connections resolved", "count", len(ompConns)) + } + if len(tunnelConns) > 0 { + log.Info("SD-WAN tunnel connections resolved", "count", len(tunnelConns)) + } + connections = append(connections, ompConns...) + connections = append(connections, tunnelConns...) + + neighbors.use(ompConns) + neighbors.use(tunnelConns) + nRes, nConns, nDev, nIf := neighbors.build() + stats.neighborDevices, stats.neighborInterfaces = nDev, nIf + rawRows.finish(resources) + + // The site group lists the site's own resources only. + memberIDs := make([]string, 0, len(local)) + for _, r := range resources { + if local[r.ID] { + memberIDs = append(memberIDs, r.ID) + } + } + setProvenance(resources, s.name, cfg.Host) + // A neighbor never duplicates one of the site's own resources (for + // example two inventory devices sharing a serial number). + for _, r := range nRes { + if !local[r.ID] { + resources = append(resources, r) + } + } + seenConn := make(map[string]bool, len(connections)) + for _, c := range connections { + seenConn[c.ID] = true + } + for _, c := range nConns { + if !seenConn[c.ID] { + connections = append(connections, c) + } + } + + var groups []sdk.Group + if g, ok := TransformSiteGroup(s.id, s.name, devices, memberIDs); ok { + groups = append(groups, g) + } + + // Documentation keeps only its reviewed field set (purpose.go). + applyPurpose(cfg.Purpose, resources, connections, groups) + + // log-and-redact and off never emit a detected secret: the producer + // replaces every detected value before Build (the SDK only logs and + // flags in log-and-redact), and verifyRedacted refuses a document + // that still carries one. fail-closed keeps the values and lets + // Build abort. + if cfg.SafeFailureMode != sdk.FailClosed { + if n := redactElements(resources, connections, groups); n > 0 { + log.Warn("secret values redacted before build", "count", n) + } + } + + scope := sdk.Scope{ + Providers: []string{providerName}, + Purpose: cfg.Purpose, + Clusters: []string{cfg.Host}, + } + if s.name != "" { + scope.Sites = []string{s.name} + } + + builder := sdk.NewDocumentBuilder(ctx). + WithGenerator(generatorName, generatorVersion, generatorURL). + WithScope(scope) + for _, r := range resources { + builder.AddResource(r) + } + for _, c := range connections { + builder.AddConnection(c) + } + for _, g := range groups { + builder.AddGroup(g) + } + doc, err := builder.Build() + if err != nil { + return nil, err + } + meta := col.siteCoverage(s).metadata() + meta["graph"] = stats.metadata() + doc.Metadata.Extensions = map[string]any{extensionKey: meta} + if err := verifyRedacted(doc, cfg.SafeFailureMode); err != nil { + return nil, err + } + return doc, nil +} + +// topologyOwner finds the local device a site topology entry belongs +// to: by the Manager device-id ("device-id" here, "deviceId" in GET +// /dataservice/device), then by that value read as a system IP (some +// releases report the system IP there), then by the system IP of the +// entry's circuits. "" when none matches. +func topologyOwner(st SiteTopologyDevice, byDeviceID, bySystemIP map[string]string) string { + if id := byDeviceID[st.DeviceID]; id != "" { + return id + } + if id := bySystemIP[st.DeviceID]; id != "" { + return id + } + for _, c := range st.Circuits { + if id := bySystemIP[c.SystemIP]; id != "" { + return id + } + } + return "" +} + +// memberDeviceIDs returns the IDs of the site's own device resources +// (not interfaces), in resource order. +func memberDeviceIDs(resources []sdk.Resource, local map[string]bool) []string { + var out []string + for _, r := range resources { + if local[r.ID] && !strings.HasSuffix(r.Type, ".port") && r.Type != "network.interface" { + out = append(out, r.ID) + } + } + return out +} + +// setProvenance records where each of the site's own resources comes +// from: provider.site is the site name (left empty for the unsited +// bucket) and provider.system the Manager the run collected from. +func setProvenance(resources []sdk.Resource, siteName, host string) { + for i := range resources { + resources[i].Provider.Site = siteName + resources[i].Provider.System = host + } +} + +// deviceRawIndex builds a Device.DeviceID -> raw JSON object lookup +// from GetDevicesWithRaw's parallel devices/raws slices. +func deviceRawIndex(devices []Device, raws []json.RawMessage) map[string]json.RawMessage { + if len(devices) != len(raws) { + return nil + } + idx := make(map[string]json.RawMessage, len(devices)) + for i, d := range devices { + if d.DeviceID != "" { + idx[d.DeviceID] = raws[i] + } + } + return idx +} diff --git a/osiris/network/cisco/vmanage/flags.go b/osiris/network/cisco/catalyst-sd-wan-manager/flags.go similarity index 71% rename from osiris/network/cisco/vmanage/flags.go rename to osiris/network/cisco/catalyst-sd-wan-manager/flags.go index 19ac9d3..6caa9ad 100644 --- a/osiris/network/cisco/vmanage/flags.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/flags.go @@ -1,9 +1,9 @@ // flags.go - CLI flag parsing for the Cisco Catalyst SD-WAN Manager -// (vManage) OSIRIS JSON producer. +// OSIRIS JSON producer. // -// vManage is a single WAN-overlay controller (see config.go), not a -// per-device CSV batch target, so this producer intentionally has no -// -s/--source CSV batch mode, unlike apic/nxos/iosxe it does not +// SD-WAN Manager is a single WAN-overlay controller (see config.go), +// not a per-device CSV batch target, so this producer intentionally has +// no -s/--source CSV batch mode, unlike apic/nxos/iosxe it does not // conform to cisco/run's ProducerFactory/RunConfig shape at all. It // reuses the vendor-agnostic helpers from cisco/run (ParseHostPort, // PromptPassword, and LoadCredentialFile/CredentialFile for @@ -16,14 +16,14 @@ // one, prompted for interactively on the controlling terminal (see // tty.go) and held only in memory for the run. --host/--username follow // the same fallback chain (flag, then --secrets-file, then interactive -// prompt), so a bare "osirisjson-producer cisco vmanage" with no flags -// at all still works end to end. +// prompt), so a bare "osirisjson-producer cisco sdwan" +// with no flags at all still works end to end. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import ( "flag" @@ -35,18 +35,19 @@ import ( "go.osirisjson.org/producers/pkg/osirismeta" ) -// defaultPort is the vManage HTTPS port used when --host has no +// defaultPort is the SD-WAN Manager HTTPS port used when --host has no // explicit :port and --port is not given. const defaultPort = 443 -// vmanageFlagValues holds every vmanage CLI flag's bound destination. -// registerFlags is the single place these flags are named and -// described - both ParseFlags (which parses them) and FlagsUsage -// (which renders their registered descriptions for vmanage.go's -// printHelp) build off this same registration, so the flag list shown -// in --help and the one flag.Parse falls back to printing on a parse -// error (e.g. an unrecognized flag) can never drift apart. -type vmanageFlagValues struct { +// managerFlagValues holds every SD-WAN Manager CLI flag's bound +// destination. registerFlags is the single place these flags are named +// and described both ParseFlags (which parses them) and FlagsUsage +// (which renders their registered descriptions for +// catalystsdwanmanager.go's printHelp) build off this same +// registration, so the flag list shown in --help and the one flag.Parse +// falls back to printing on a parse error (e.g. an unrecognized flag) +// can never drift apart. +type managerFlagValues struct { host string username string secretsFile string @@ -59,42 +60,44 @@ type vmanageFlagValues struct { allSites bool siteRate int - includeRawBody bool + includeRawBody bool + requireComplete bool } -// registerFlags binds every vmanage CLI flag onto fs and returns their -// destinations. See vmanageFlagValues' doc comment for why this is -// factored out instead of living inline in ParseFlags. -func registerFlags(fs *flag.FlagSet) *vmanageFlagValues { - v := &vmanageFlagValues{} +// registerFlags binds every SD-WAN Manager CLI flag onto fs and returns +// their destinations. See managerFlagValues doc comment for why this +// is factored out instead of living inline in ParseFlags. +func registerFlags(fs *flag.FlagSet) *managerFlagValues { + v := &managerFlagValues{} - fs.StringVar(&v.host, "h", "", "vManage controller host (FQDN or IP, e.g. vmanage.example.com), optionally with :port; prompted for interactively when omitted") - fs.StringVar(&v.host, "host", "", "vManage controller host, see -h") + fs.StringVar(&v.host, "h", "", "SD-WAN Manager controller host (FQDN or IP, e.g. sdwan-manager.example.com), optionally with :port; prompted for interactively when omitted") + fs.StringVar(&v.host, "host", "", "SD-WAN Manager controller host, see -h") fs.StringVar(&v.username, "u", "", "username for authentication; prompted for interactively when omitted") fs.StringVar(&v.username, "username", "", "username for authentication, see -u") fs.StringVar(&v.secretsFile, "secrets-file", "", "JSON file with {host, username, password}; whatever it omits still falls back to its own flag or an interactive prompt") fs.IntVar(&v.port, "P", 0, fmt.Sprintf("override port (default: %d)", defaultPort)) fs.IntVar(&v.port, "port", 0, "override port, see -P") - fs.StringVar(&v.output, "o", "", fmt.Sprintf("output directory - every run writes //cisco-vmanage--.json, created if missing and reused if it already exists (default: %q in the current directory)", defaultOutputDir)) + fs.StringVar(&v.output, "o", "", fmt.Sprintf("output directory - every run writes //cisco-catalyst-sdwan-manager--.json, created if missing and reused if it already exists (default: %q in the current directory)", defaultOutputDir)) fs.StringVar(&v.output, "output", "", "output directory, see -o") - fs.StringVar(&v.safeFail, "safe-failure-mode", "fail-closed", "secret handling: fail-closed, log-and-redact, or off") + fs.StringVar(&v.safeFail, "safe-failure-mode", "fail-closed", "secret handling: fail-closed (abort the site on any detected secret), log-and-redact (replace detected values, then verify none remain), or off (replace detected values, skip the final check)") fs.StringVar(&v.purposeStr, "purpose", "", osirismeta.PurposeHelp()) fs.BoolVar(&v.insecure, "insecure", false, "skip TLS certificate verification") fs.StringVar(&v.siteFlag, "site", "", fmt.Sprintf("comma-separated site(s) to collect, by raw site-id or resolved site name (use %q for devices with no site-id, or \"all\" for --all); omit for an interactive picker", unsitedSegment)) fs.BoolVar(&v.allSites, "all", false, "collect every site discovered, non-interactively (skips the site picker; mutually exclusive with --site)") - fs.IntVar(&v.siteRate, "site-name-rate", defaultSiteNameRateLimit, fmt.Sprintf("requests/second for bulk site-name resolution (default: %d). vManage's own rate limit is typically shared across every API consumer hitting it, monitoring systems, other automation, etc. not just this producer, so raise or lower this based on how much headroom your environment actually has; the default assumes this producer is one of several concurrent consumers", defaultSiteNameRateLimit)) - fs.BoolVar(&v.includeRawBody, "include-raw-body", false, "attach each collected endpoint's full, unmodified API response body under extensions[\"osiris.cisco.vmanage\"] on the owning device resource (requires --purpose audit; a lossless fallback for fields not yet modeled by this producer)") + fs.IntVar(&v.siteRate, "site-name-rate", defaultSiteNameRateLimit, fmt.Sprintf("requests/second for bulk per-object lookups: site-name resolution and the WAN interface listings of tunnel peers outside the selected sites (default: %d). SD-WAN Manager's own rate limit is typically shared across every API consumer hitting it, monitoring systems, other automation, etc. not just this producer, so raise or lower this based on how much headroom your environment actually has; the default assumes this producer is one of several concurrent consumers", defaultSiteNameRateLimit)) + fs.BoolVar(&v.requireComplete, "require-complete", false, "exit with an error when any written document is partial, that is when an optional API operation failed or was denied (see the coverage record in each document's metadata); without it a partial run succeeds once every selected document is written") + fs.BoolVar(&v.includeRawBody, "include-raw-body", false, "attach each collected endpoint's API rows under extensions[\"osiris.cisco.catalystsdwanmanager\"] on the owning device resource, with every secret redacted and oversized rows withheld and counted in raw_omitted (requires --purpose audit; a fallback for fields not yet modeled by this producer)") // Overriding fs.Usage (rather than leaving flag.Parse's default, // which is "Usage of %s:" followed by fs.PrintDefaults()) means a // real parse error e.g. an unrecognized flag, which flag.Parse // reports by calling fs.Usage() before returning the error shows - // the exact same aligned table as vmanage.go's --help (both call - // renderFlagsTable against this same fs), not the stdlib's raw - // two-line-per-flag dump. See renderFlagsTable doc comment for why - // that default format was replaced: it splits each flag's name and - // description across separate, unaligned lines with no merging of - // short/long aliases, which reads poorly. + // the exact same aligned table as catalystsdwanmanager.go's --help + // (both call renderFlagsTable against this same fs), not the + // stdlib's raw two-line-per-flag dump. See renderFlagsTable doc + // comment for why that default format was replaced: it splits each + // flag's name and description across separate, unaligned lines with + // no merging of short/long aliases, which reads poorly. fs.Usage = func() { fmt.Fprintf(fs.Output(), "Usage of %s:\n", fs.Name()) fmt.Fprint(fs.Output(), renderFlagsTable(fs)) @@ -127,6 +130,7 @@ var flagRows = [][]string{ {"purpose"}, {"safe-failure-mode"}, {"insecure"}, + {"require-complete"}, {"include-raw-body"}, } @@ -275,33 +279,41 @@ func wordWrap(s string, width int) []string { return out } -// FlagsUsage renders the vmanage flag table exactly as registerFlags -// defines it the same source ParseFlags binds against so -// vmanage.go's printHelp can show it in --help without hand-retyping -// each flag and risking it drifting out of sync with the real flag -// set. See renderFlagsTable for the table layout. +// FlagsUsage renders the SD-WAN Manager flag table exactly as +// registerFlags defines it the same source ParseFlags binds against so +// catalystsdwanmanager.go's printHelp can show it in --help without +// hand-retyping each flag and risking it drifting out of sync with the +// real flag set. See renderFlagsTable for the table layout. func FlagsUsage() string { - fs := flag.NewFlagSet("osirisjson-producer cisco vmanage", flag.ContinueOnError) + fs := flag.NewFlagSet("osirisjson-producer cisco sdwan", flag.ContinueOnError) registerFlags(fs) return renderFlagsTable(fs) } -// ParseFlags parses CLI flags for the vManage producer and returns a -// Config. host/username/password are resolved in this order: the -// -h/-u flag, then --secrets-file, then (for whichever of the three is -// still missing) an interactive prompt on the controlling terminal +// ParseFlags parses CLI flags for the SD-WAN Manager producer and +// returns a Config. host/username/password are resolved in this order: +// the -h/-u flag, then --secrets-file, then (for whichever of the three +// is still missing) an interactive prompt on the controlling terminal // promptVisible for host/username, promptHidden for password. Either // prompt function may be nil (e.g. no controlling terminal available, // such as under cron/CI), in which case a still-missing host or // username is a hard error and a still-missing password is left empty // with a warning, matching today's headless/automation behavior. func ParseFlags(args []string, promptVisible, promptHidden func(string) (string, error)) (*Config, error) { - fs := flag.NewFlagSet("osirisjson-producer cisco vmanage", flag.ContinueOnError) + fs := flag.NewFlagSet("osirisjson-producer cisco sdwan", flag.ContinueOnError) v := registerFlags(fs) if err := fs.Parse(args); err != nil { return nil, err } + // flag.Parse stops at the first non-flag argument and silently + // ignores every flag after it, so a stray value such as + // "--include-raw-body true" would drop a later --site and fall + // back to the interactive picker (and its full site-name + // resolution pass). This producer takes no positional arguments. + if fs.NArg() > 0 { + return nil, fmt.Errorf("unexpected argument %q: flags after it were not parsed (boolean flags take no separate value, use --flag or --flag=false)", fs.Arg(0)) + } host, username, secretsFile := v.host, v.username, v.secretsFile port := v.port @@ -352,15 +364,15 @@ func ParseFlags(args []string, promptVisible, promptHidden func(string) (string, // Still-missing host is asked for interactively (see tty.go's // promptVisible) rather than failing outright, so a bare - // "osirisjson-producer cisco vmanage" works end to end. No - // controlling terminal (e.g. cron/CI with neither the flag nor - // --secrets-file set) is a hard error, same as before this fallback - // chain existed. + // "osirisjson-producer cisco sdwan" works end to + // end. No controlling terminal (e.g. cron/CI with neither the flag + // nor --secrets-file set) is a hard error, same as before this + // fallback chain existed. if host == "" { if promptVisible == nil { - return nil, fmt.Errorf("--host is required (e.g. --host vmanage.example.com)") + return nil, fmt.Errorf("--host is required (e.g. --host sdwan-manager.example.com)") } - v, err := promptVisible("vManage controller host (FQDN or IP, e.g. vmanage.example.com): ") + v, err := promptVisible("SD-WAN Manager controller host (FQDN or IP, e.g. sdwan-manager.example.com): ") if err != nil { return nil, fmt.Errorf("reading host: %w", err) } @@ -383,11 +395,11 @@ func ParseFlags(args []string, promptVisible, promptHidden func(string) (string, // Resolved against the bare host (h, no port) so a --secrets-file // rule's CIDR/exact-host match works the same way it does for - // apic/iosxe/nxos see run.CredentialFile.ResolveForHost. vmanage - // only ever has one target host per run, so a rules file is mostly - // useful here for reusing one file across multiple controllers - // (matched by host/CIDR) rather than for a per-target batch, but - // the resolution logic is identical either way. + // apic/iosxe/nxos see run.CredentialFile.ResolveForHost. SD-WAN + // Manager only ever has one target host per run, so a rules file is + // mostly useful here for reusing one file across multiple + // controllers (matched by host/CIDR) rather than for a per-target + // batch, but the resolution logic is identical either way. tfUsername, tfPassword := tf.ResolveForHost(h) if username == "" { @@ -397,7 +409,7 @@ func ParseFlags(args []string, promptVisible, promptHidden func(string) (string, if promptVisible == nil { return nil, fmt.Errorf("--username is required") } - v, err := promptVisible("Username for vManage authentication: ") + v, err := promptVisible("Username for SD-WAN Manager authentication: ") if err != nil { return nil, fmt.Errorf("reading username: %w", err) } @@ -458,5 +470,6 @@ func ParseFlags(args []string, promptVisible, promptHidden func(string) (string, AllSites: allSites, SiteNameRateLimit: siteRate, IncludeRawBody: includeRawBody, + RequireComplete: v.requireComplete, }, nil } diff --git a/osiris/network/cisco/vmanage/flags_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/flags_test.go similarity index 65% rename from osiris/network/cisco/vmanage/flags_test.go rename to osiris/network/cisco/catalyst-sd-wan-manager/flags_test.go index 384baa8..ae82e90 100644 --- a/osiris/network/cisco/vmanage/flags_test.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/flags_test.go @@ -1,13 +1,13 @@ // flags_test.go - Tests for CLI flag parsing, including the -// customer-domain --host requirement (e.g. vmanage.example.com) and -// the host/username/password fallback chain (flag, then --secrets-file, +// customer-domain --host requirement (e.g. sdwan-manager.example.com) +// and host/username/password fallback chain (flag, then --secrets-file, // then an interactive prompt see flags.go's ParseFlags doc comment). // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import ( "encoding/json" @@ -26,12 +26,12 @@ func promptHiddenStub(string) (string, error) { } func TestParseFlags_DomainHost(t *testing.T) { - cfg, err := ParseFlags([]string{"-h", "vmanage.example.com", "-u", "user"}, nil, promptHiddenStub) + cfg, err := ParseFlags([]string{"-h", "sdwan-manager.example.com", "-u", "user"}, nil, promptHiddenStub) if err != nil { t.Fatalf("ParseFlags failed: %v", err) } - if cfg.Host != "vmanage.example.com" { - t.Errorf("Host = %q, want %q", cfg.Host, "vmanage.example.com") + if cfg.Host != "sdwan-manager.example.com" { + t.Errorf("Host = %q, want %q", cfg.Host, "sdwan-manager.example.com") } if cfg.Port != defaultPort { t.Errorf("Port = %d, want default %d", cfg.Port, defaultPort) @@ -39,12 +39,12 @@ func TestParseFlags_DomainHost(t *testing.T) { } func TestParseFlags_DomainHostWithExplicitPort(t *testing.T) { - cfg, err := ParseFlags([]string{"--host", "vmanage.example.com:8443", "-u", "user"}, nil, promptHiddenStub) + cfg, err := ParseFlags([]string{"--host", "sdwan-manager.example.com:8443", "-u", "user"}, nil, promptHiddenStub) if err != nil { t.Fatalf("ParseFlags failed: %v", err) } - if cfg.Host != "vmanage.example.com" || cfg.Port != 8443 { - t.Errorf("Host/Port = %q/%d, want vmanage.example.com/8443", cfg.Host, cfg.Port) + if cfg.Host != "sdwan-manager.example.com" || cfg.Port != 8443 { + t.Errorf("Host/Port = %q/%d, want sdwan-manager.example.com/8443", cfg.Host, cfg.Port) } } @@ -58,27 +58,59 @@ func TestParseFlags_MissingHost(t *testing.T) { } func TestParseFlags_MissingUsername(t *testing.T) { - if _, err := ParseFlags([]string{"-h", "vmanage.example.com"}, nil, promptHiddenStub); err == nil { + if _, err := ParseFlags([]string{"-h", "sdwan-manager.example.com"}, nil, promptHiddenStub); err == nil { t.Fatal("expected error when --username is missing and no interactive prompt is available") } } +func TestParseFlags_RejectsPositionalArguments(t *testing.T) { + tests := []struct { + name string + args []string + }{ + {"bool flag with separate value", []string{"-h", "sdwan-manager.example.com", "-u", "admin", "--include-raw-body", "true", "--site", "100"}}, + {"stray site name", []string{"-h", "sdwan-manager.example.com", "-u", "admin", "BRANCH-00", "--site", "100"}}, + {"trailing argument", []string{"-h", "sdwan-manager.example.com", "-u", "admin", "--site", "100", "extra"}}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if _, err := ParseFlags(tt.args, nil, promptHiddenStub); err == nil { + t.Fatalf("ParseFlags(%v): expected an error for a positional argument", tt.args) + } + }) + } +} + +func TestParseFlags_SiteAfterBoolFlagIsKept(t *testing.T) { + args := []string{"-h", "sdwan-manager.example.com", "-u", "admin", "--purpose", "audit", "--include-raw-body", "--site", "100"} + cfg, err := ParseFlags(args, nil, promptHiddenStub) + if err != nil { + t.Fatalf("ParseFlags failed: %v", err) + } + if len(cfg.SiteFilter) != 1 || cfg.SiteFilter[0] != "100" { + t.Errorf("SiteFilter = %v, want [100]", cfg.SiteFilter) + } + if !cfg.IncludeRawBody { + t.Error("IncludeRawBody = false, want true") + } +} + func TestParseFlags_InvalidSafeFailureMode(t *testing.T) { - args := []string{"-h", "vmanage.example.com", "-u", "user", "--safe-failure-mode", "bogus"} + args := []string{"-h", "sdwan-manager.example.com", "-u", "user", "--safe-failure-mode", "bogus"} if _, err := ParseFlags(args, nil, promptHiddenStub); err == nil { t.Fatal("expected error for invalid --safe-failure-mode") } } func TestParseFlags_InvalidPurpose(t *testing.T) { - args := []string{"-h", "vmanage.example.com", "-u", "user", "--purpose", "bogus"} + args := []string{"-h", "sdwan-manager.example.com", "-u", "user", "--purpose", "bogus"} if _, err := ParseFlags(args, nil, promptHiddenStub); err == nil { t.Fatal("expected error for invalid --purpose") } } func TestParseFlags_DefaultOutputDir(t *testing.T) { - cfg, err := ParseFlags([]string{"-h", "vmanage.example.com", "-u", "user"}, nil, promptHiddenStub) + cfg, err := ParseFlags([]string{"-h", "sdwan-manager.example.com", "-u", "user"}, nil, promptHiddenStub) if err != nil { t.Fatalf("ParseFlags failed: %v", err) } @@ -89,7 +121,7 @@ func TestParseFlags_DefaultOutputDir(t *testing.T) { func TestParseFlags_SiteAllIsAliasForAllSites(t *testing.T) { for _, value := range []string{"all", "All", "ALL", " all "} { - args := []string{"-h", "vmanage.example.com", "-u", "user", "--site", value} + args := []string{"-h", "sdwan-manager.example.com", "-u", "user", "--site", value} cfg, err := ParseFlags(args, nil, promptHiddenStub) if err != nil { t.Fatalf("ParseFlags(--site %q) failed: %v", value, err) @@ -107,14 +139,14 @@ func TestParseFlags_SiteAllDoesNotConflictWithAllFlag(t *testing.T) { // --site all normalizes to AllSites before the --all/--site // mutual-exclusivity check, so it must not error even though both // end up "set". - args := []string{"-h", "vmanage.example.com", "-u", "user", "--site", "all", "--all"} + args := []string{"-h", "sdwan-manager.example.com", "-u", "user", "--site", "all", "--all"} if _, err := ParseFlags(args, nil, promptHiddenStub); err != nil { t.Errorf("ParseFlags(--site all --all) failed: %v", err) } } func TestParseFlags_DefaultSiteNameRateLimit(t *testing.T) { - cfg, err := ParseFlags([]string{"-h", "vmanage.example.com", "-u", "user"}, nil, promptHiddenStub) + cfg, err := ParseFlags([]string{"-h", "sdwan-manager.example.com", "-u", "user"}, nil, promptHiddenStub) if err != nil { t.Fatalf("ParseFlags failed: %v", err) } @@ -124,7 +156,7 @@ func TestParseFlags_DefaultSiteNameRateLimit(t *testing.T) { } func TestParseFlags_CustomSiteNameRateLimit(t *testing.T) { - args := []string{"-h", "vmanage.example.com", "-u", "user", "--site-name-rate", "50"} + args := []string{"-h", "sdwan-manager.example.com", "-u", "user", "--site-name-rate", "50"} cfg, err := ParseFlags(args, nil, promptHiddenStub) if err != nil { t.Fatalf("ParseFlags failed: %v", err) @@ -136,7 +168,7 @@ func TestParseFlags_CustomSiteNameRateLimit(t *testing.T) { func TestParseFlags_InvalidSiteNameRateLimit(t *testing.T) { for _, rate := range []string{"0", "-1"} { - args := []string{"-h", "vmanage.example.com", "-u", "user", "--site-name-rate", rate} + args := []string{"-h", "sdwan-manager.example.com", "-u", "user", "--site-name-rate", rate} if _, err := ParseFlags(args, nil, promptHiddenStub); err == nil { t.Errorf("expected error for --site-name-rate %s", rate) } @@ -147,7 +179,7 @@ func TestParseFlags_NoPasswordFlag(t *testing.T) { // -p/--password must not exist: passing it should be a flag parse // error, not silently accepted, since passwords must never be // supplied inline (visible in `ps` and shell history). - if _, err := ParseFlags([]string{"-h", "vmanage.example.com", "-u", "user", "-p", "changeme"}, nil, promptHiddenStub); err == nil { + if _, err := ParseFlags([]string{"-h", "sdwan-manager.example.com", "-u", "user", "-p", "changeme"}, nil, promptHiddenStub); err == nil { t.Fatal("expected error: -p/--password should not be a recognized flag") } } @@ -158,7 +190,7 @@ func TestParseFlags_PromptHiddenCalledWhenPasswordOmitted(t *testing.T) { called = true return "prompted-password", nil } - cfg, err := ParseFlags([]string{"-h", "vmanage.example.com", "-u", "user"}, nil, prompt) + cfg, err := ParseFlags([]string{"-h", "sdwan-manager.example.com", "-u", "user"}, nil, prompt) if err != nil { t.Fatalf("ParseFlags failed: %v", err) } @@ -175,7 +207,7 @@ func TestParseFlags_PromptVisibleCalledForMissingHostAndUsername(t *testing.T) { promptVisible := func(msg string) (string, error) { prompts = append(prompts, msg) if len(prompts) == 1 { - return "vmanage.example.com", nil + return "sdwan-manager.example.com", nil } return "user", nil } @@ -186,8 +218,8 @@ func TestParseFlags_PromptVisibleCalledForMissingHostAndUsername(t *testing.T) { if len(prompts) != 2 { t.Fatalf("expected promptVisible to be called twice (host, username), got %d calls", len(prompts)) } - if cfg.Host != "vmanage.example.com" { - t.Errorf("Host = %q, want %q", cfg.Host, "vmanage.example.com") + if cfg.Host != "sdwan-manager.example.com" { + t.Errorf("Host = %q, want %q", cfg.Host, "sdwan-manager.example.com") } if cfg.Username != "user" { t.Errorf("Username = %q, want %q", cfg.Username, "user") @@ -196,9 +228,9 @@ func TestParseFlags_PromptVisibleCalledForMissingHostAndUsername(t *testing.T) { func TestParseFlags_SecretsFileSuppliesHostUsernamePassword(t *testing.T) { dir := t.TempDir() - path := filepath.Join(dir, "cisco-vmanage-secrets.json") + path := filepath.Join(dir, "cisco-catalyst-sdwan-manager-secrets.json") contents := run.CredentialFile{ - Host: "vmanage.example.com", + Host: "sdwan-manager.example.com", Username: "user", Password: "changeme", } @@ -214,8 +246,8 @@ func TestParseFlags_SecretsFileSuppliesHostUsernamePassword(t *testing.T) { if err != nil { t.Fatalf("ParseFlags failed: %v", err) } - if cfg.Host != "vmanage.example.com" { - t.Errorf("Host = %q, want %q", cfg.Host, "vmanage.example.com") + if cfg.Host != "sdwan-manager.example.com" { + t.Errorf("Host = %q, want %q", cfg.Host, "sdwan-manager.example.com") } if cfg.Username != "user" { t.Errorf("Username = %q, want %q", cfg.Username, "user") @@ -227,11 +259,11 @@ func TestParseFlags_SecretsFileSuppliesHostUsernamePassword(t *testing.T) { func TestParseFlags_SecretsFileRulesShapeResolvesByHost(t *testing.T) { dir := t.TempDir() - path := filepath.Join(dir, "cisco-vmanage-secrets.json") + path := filepath.Join(dir, "cisco-catalyst-sdwan-manager-secrets.json") content := `{ "default": {"username": "default-user", "password": "secret-1"}, "rules": [ - {"hosts": "vmanage.example.com", "username": "user", "password": "secret-2"} + {"hosts": "sdwan-manager.example.com", "username": "user", "password": "secret-2"} ] }` if err := os.WriteFile(path, []byte(content), 0600); err != nil { @@ -239,7 +271,7 @@ func TestParseFlags_SecretsFileRulesShapeResolvesByHost(t *testing.T) { } // Matches the rule. - cfg, err := ParseFlags([]string{"-h", "vmanage.example.com", "--secrets-file", path}, nil, nil) + cfg, err := ParseFlags([]string{"-h", "sdwan-manager.example.com", "--secrets-file", path}, nil, nil) if err != nil { t.Fatalf("ParseFlags failed: %v", err) } @@ -258,16 +290,16 @@ func TestParseFlags_SecretsFileRulesShapeResolvesByHost(t *testing.T) { } func TestParseFlags_SecretsFileMissingFile(t *testing.T) { - if _, err := ParseFlags([]string{"--secrets-file", "/nonexistent/cisco-vmanage-secrets.json"}, nil, promptHiddenStub); err == nil { + if _, err := ParseFlags([]string{"--secrets-file", "/nonexistent/cisco-catalyst-sdwan-manager-secrets.json"}, nil, promptHiddenStub); err == nil { t.Fatal("expected error when --secrets-file does not exist") } } func TestParseFlags_FlagOverridesSecretsFile(t *testing.T) { dir := t.TempDir() - path := filepath.Join(dir, "cisco-vmanage-secrets.json") + path := filepath.Join(dir, "cisco-catalyst-sdwan-manager-secrets.json") contents := run.CredentialFile{ - Host: "vmanage.example.com", + Host: "sdwan-manager.example.com", Username: "from-file-user", Password: "secret-3", } @@ -279,11 +311,11 @@ func TestParseFlags_FlagOverridesSecretsFile(t *testing.T) { t.Fatalf("writing token file: %v", err) } - cfg, err := ParseFlags([]string{"-h", "vmanage.example.com", "--secrets-file", path}, nil, nil) + cfg, err := ParseFlags([]string{"-h", "sdwan-manager.example.com", "--secrets-file", path}, nil, nil) if err != nil { t.Fatalf("ParseFlags failed: %v", err) } - if cfg.Host != "vmanage.example.com" { + if cfg.Host != "sdwan-manager.example.com" { t.Errorf("Host = %q, want the explicit -h flag value, not the token file's", cfg.Host) } if cfg.Username != "from-file-user" { diff --git a/osiris/network/cisco/vmanage/golden_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/golden_test.go similarity index 61% rename from osiris/network/cisco/vmanage/golden_test.go rename to osiris/network/cisco/catalyst-sd-wan-manager/golden_test.go index b914183..6a9ddb7 100644 --- a/osiris/network/cisco/vmanage/golden_test.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/golden_test.go @@ -1,12 +1,13 @@ // golden_test.go - Source-to-golden test for the Cisco Catalyst SD-WAN -// Manager (vManage) OSIRIS JSON Producer. +// Manager OSIRIS JSON Producer. // // Drives runExport end to end, login included, against an in-memory -// HTTPS vManage that serves synthetic /dataservice response bodies and -// compares the emitted per-site document byte for byte with the -// expected document, at both --purpose flag levels. +// HTTPS SD-WAN Manager that serves synthetic /dataservice response +// bodies and compares the emitted per-site document byte for byte with +// the expected document, at both --purpose flag levels. // -// Fixtures live under testdata/osiris/network/cisco/vmanage/ at the +// Fixtures live under +// testdata/osiris/network/cisco/catalyst-sd-wan-manager/ at the // repository root: one snake_case directory per scenario, holding one // response body per endpoint (api/.json, see goldenServer for the // path mapping) and the expected document per purpose @@ -16,8 +17,9 @@ // review the diff: they are the producer's output contract. // // runExport stamps the wall clock into metadata.timestamp and the dial -// host into metadata.scope.clusters. The test checks that the dial -// host is the only cluster, then pins both fields to fixed values +// host into metadata.scope.clusters and every resource's +// provider.system. The test checks that the dial host is the only +// value, then pins these fields to fixed values // before the comparison, so the documents stay reproducible and carry // no loopback address. Every other byte is the producer's own output. // @@ -27,11 +29,11 @@ // TestGolden_GraphIntegrity proves every connection endpoint and every // group member of each golden document is an emitted resource. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import ( "bytes" @@ -51,15 +53,28 @@ import ( // goldenRoot holds one directory per scenario, relative to this package // directory. -const goldenRoot = "../../../../testdata/osiris/network/cisco/vmanage" +const goldenRoot = "../../../../testdata/osiris/network/cisco/catalyst-sd-wan-manager" -// goldenScenario is one scenario directory under goldenRoot and the -// site name its single emitted document is written under. -type goldenScenario struct{ dir, site string } +// goldenScenario is one site document of a scenario directory under +// goldenRoot: the site name it is written under and, for a scenario +// with several sites, the name prefix of its expected documents. +type goldenScenario struct{ dir, site, name string } -// goldenScenarios are the scenarios under goldenRoot: one control-plane -// site holding a Manager, a Controller and a Validator. -var goldenScenarios = []goldenScenario{{dir: "lab_sdwan", site: "MXP"}} +// goldenScenarios are the scenarios under goldenRoot: lab_sdwan, one +// control-plane site holding a Manager, a Controller and a Validator; +// lab_cross_site, two WAN edge sites and a controller site joined by a +// cross-site tunnel and OMP sessions, one document per site; +// contract_, the same fabric shape built from each documented +// release's example responses (see contract_test.go). +var goldenScenarios = []goldenScenario{ + {dir: "lab_sdwan", site: "MXP"}, + {dir: "lab_cross_site", site: "BRANCH-00", name: "branch_00"}, + {dir: "lab_cross_site", site: "OFFICE-00", name: "office_00"}, + {dir: "lab_cross_site", site: "MXP", name: "mxp"}, + {dir: "contract_20_18", site: "BRANCH-00", name: "branch_00"}, + {dir: "contract_26_1", site: "BRANCH-00", name: "branch_00"}, + {dir: "contract_26_2", site: "BRANCH-00", name: "branch_00"}, +} // goldenTimestamp and goldenCluster replace the wall-clock timestamp // and the dial host in every golden document. @@ -197,40 +212,103 @@ func collectGolden(t *testing.T, sc goldenScenario, purpose string) *sdk.Documen } doc.Metadata.Scope.Clusters = []string{goldenCluster} doc.Metadata.Timestamp = goldenTimestamp + for i := range doc.Topology.Resources { + p := &doc.Topology.Resources[i].Provider + if p.System != host { + t.Fatalf("resource %s provider.system = %q, want the dial host", doc.Topology.Resources[i].ID, p.System) + } + p.System = goldenCluster + } return &doc } // goldenPath is the expected document of sc at purpose. func goldenPath(sc goldenScenario, purpose string) string { + if sc.name != "" { + return filepath.Join(goldenRoot, sc.dir, "purpose", sc.name+"_golden_"+purpose+".json") + } return filepath.Join(goldenRoot, sc.dir, "purpose", "golden_"+purpose+".json") } func TestGolden(t *testing.T) { for _, sc := range goldenScenarios { for _, purpose := range []string{"documentation", "audit"} { - t.Run(sc.dir+"/"+purpose, func(t *testing.T) { + t.Run(sc.dir+"/"+sc.site+"/"+purpose, func(t *testing.T) { testharness.AssertGolden(t, collectGolden(t, sc, purpose), goldenPath(sc, purpose)) }) } } } -// auditOnlyKeys are the members TransformDevices emits at audit -// purpose only. -var auditOnlyKeys = []string{`"serial_number"`, `"certificate_validity"`} +// auditOnlyKeys are members the audit golden must carry and the +// documentation golden must not (see purpose.go). +var auditOnlyKeys = []string{ + `"serial_number"`, `"certificate_validity"`, `"ip_addresses"`, `"mac_address"`, + `"system_ip"`, `"geo_location"`, `"device_groups"`, `"up_since"`, +} +// TestGolden_PurposeContract proves the documentation goldens carry +// nothing outside the purpose.go allowlist, and that the audit goldens +// still carry the audit-only fields and the same graph. func TestGolden_PurposeContract(t *testing.T) { + seenInAudit := map[string]bool{} for _, sc := range goldenScenarios { - doc := testharness.LoadFixture(t, goldenPath(sc, "documentation")) - audit := testharness.LoadFixture(t, goldenPath(sc, "audit")) + docBytes := testharness.LoadFixture(t, goldenPath(sc, "documentation")) + auditBytes := testharness.LoadFixture(t, goldenPath(sc, "audit")) for _, key := range auditOnlyKeys { - if bytes.Contains(doc, []byte(key)) { - t.Errorf("%s documentation golden carries audit-only %s", sc.dir, key) + if bytes.Contains(docBytes, []byte(key)) { + t.Errorf("%s/%s documentation golden carries audit-only %s", sc.dir, sc.site, key) + } + if bytes.Contains(auditBytes, []byte(key)) { + seenInAudit[key] = true + } + } + + var doc, audit sdk.Document + if err := json.Unmarshal(docBytes, &doc); err != nil { + t.Fatal(err) + } + if err := json.Unmarshal(auditBytes, &audit); err != nil { + t.Fatal(err) + } + check := func(kind, id string, props, ext map[string]any, al fieldAllowlist) { + for k := range props { + if !al.properties[k] { + t.Errorf("%s documentation %s %s: properties.%s is not allowlisted", sc.dir, kind, id, k) + } } - if !bytes.Contains(audit, []byte(key)) { - t.Errorf("%s audit golden carries no %s", sc.dir, key) + for ns, v := range ext { + m, _ := v.(map[string]any) + if ns != extensionKey { + t.Errorf("%s documentation %s %s: foreign extension namespace %s", sc.dir, kind, id, ns) + } + for k := range m { + if !al.extension[k] { + t.Errorf("%s documentation %s %s: extension %s is not allowlisted", sc.dir, kind, id, k) + } + } } } + for _, r := range doc.Topology.Resources { + check("resource", r.ID, r.Properties, r.Extensions, resourceAllowlist(r.Type)) + } + for _, c := range doc.Topology.Connections { + check("connection", c.ID, c.Properties, c.Extensions, documentationConnection) + } + for _, g := range doc.Topology.Groups { + check("group", g.ID, g.Properties, g.Extensions, documentationGroup) + } + + if len(doc.Topology.Resources) != len(audit.Topology.Resources) || + len(doc.Topology.Connections) != len(audit.Topology.Connections) || + len(doc.Topology.Groups) != len(audit.Topology.Groups) { + t.Errorf("%s: documentation and audit goldens differ in graph size", sc.dir) + } + } + for _, key := range auditOnlyKeys { + if !seenInAudit[key] { + t.Errorf("no audit golden carries %s", key) + } } } diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/neighbors.go b/osiris/network/cisco/catalyst-sd-wan-manager/neighbors.go new file mode 100644 index 0000000..51d7fdf --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/neighbors.go @@ -0,0 +1,229 @@ +// neighbors.go - Cross-site endpoint resolution ("site plus neighbors") +// for the Cisco Catalyst SD-WAN Manager OSIRIS JSON Producer. +// +// Each site document is portable and self-contained (OSIRIS JSON +// section 2.2.3: no reference outside the document). An SD-WAN site, +// however, is mostly connected to other sites and to the controllers: +// OMP sessions and transport tunnels. Rather than dropping those +// relationships, a site document carries every remote endpoint they +// need as a neighbor resource: +// +// - a neighbor device keeps only its identity, type, name and +// provider fields, with extension site_role "neighbor" and its own +// site_id (provider.site only when that site was collected in the +// same run, since its name is otherwise unknown); it is never a +// member of the site group; +// - a neighbor transport interface (the remote end of a tunnel) keeps +// its identity, name and color, with the same "contains" +// connection from its device that its own site document emits; +// - a neighbor's ID is exactly the ID of the full resource in its own +// site document, so an OSIRIS JSON Consumer reading several site +// documents merges a neighbor with the full resource by ID (soft +// merge, preferring the full record) and a relationship carried by +// both site documents has the same connection ID in both. +// +// Remote endpoints are resolved against the whole controller inventory +// (GET /dataservice/device returns every device the credential can +// see), not just the selected sites. A system IP shared by several +// devices is ambiguous and never resolved. A remote transport interface +// needs that device's WAN interface listing: collect.go fetches it for +// tunnel peers outside the selected sites. An endpoint that cannot be +// resolved unambiguously is counted in the document's graph record and +// the relationship is omitted no endpoint is ever invented. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "sort" + + "go.osirisjson.org/producers/pkg/sdk" +) + +// siteRoleNeighbor marks a resource that belongs to another site. +const siteRoleNeighbor = "neighbor" + +// indexedDevice is one inventory device with its resolved identity. +type indexedDevice struct { + Device + resType string + key string // native key (see deviceNativeKey). + id string // resource ID. +} + +// fabricIndex indexes the whole controller inventory by system IP. +type fabricIndex struct { + bySystemIP map[string]*indexedDevice + ambiguous map[string]bool +} + +// newFabricIndex indexes every inventory device with a known +// personality, a native identity and a system IP. +func newFabricIndex(devices []Device) *fabricIndex { + fx := &fabricIndex{bySystemIP: map[string]*indexedDevice{}, ambiguous: map[string]bool{}} + for _, d := range devices { + resType, ok := personalityToType[d.Personality] + if !ok || d.SystemIP == "" { + continue + } + key := deviceNativeKey(d, resType) + if key == "" { + continue + } + x := &indexedDevice{Device: d, resType: resType, key: key, id: resourceID(key)} + if prev, dup := fx.bySystemIP[d.SystemIP]; dup && prev.id != x.id { + fx.ambiguous[d.SystemIP] = true + continue + } + fx.bySystemIP[d.SystemIP] = x + } + for ip := range fx.ambiguous { + delete(fx.bySystemIP, ip) + } + return fx +} + +// device returns the unambiguous device with systemIP. +func (fx *fabricIndex) device(systemIP string) (*indexedDevice, bool) { + x, ok := fx.bySystemIP[systemIP] + return x, ok +} + +// interfaceResourceType is the interface type for a device type. +func interfaceResourceType(deviceType string) string { + if deviceType == "network.router" { + return "network.router.port" + } + return "network.interface" +} + +// neighborSet collects the neighbor resources one site document needs. +// Candidates are proposed while endpoints are resolved only those an +// emitted connection actually uses are kept (see use). +type neighborSet struct { + host string + siteNames map[string]string // site-id -> name, for sites collected in this run. + devices map[string]*indexedDevice // resource ID -> device. + ifaces map[string]neighborIface // resource ID -> interface. + used map[string]bool + resources []sdk.Resource +} + +type neighborIface struct { + dev *indexedDevice + ifname, color string +} + +func newNeighborSet(host string, siteNames map[string]string) *neighborSet { + return &neighborSet{ + host: host, + siteNames: siteNames, + devices: map[string]*indexedDevice{}, + ifaces: map[string]neighborIface{}, + used: map[string]bool{}, + } +} + +// proposeDevice registers x as a candidate neighbor and returns its ID. +func (ns *neighborSet) proposeDevice(x *indexedDevice) string { + ns.devices[x.id] = x + return x.id +} + +// proposeInterface registers the transport interface ifname of x as a +// candidate neighbor and returns its ID. The ID is the plain-name +// interface ID its own document emits (see interfaceKey: a transport +// interface is in VPN 0, the lowest VPN). +func (ns *neighborSet) proposeInterface(x *indexedDevice, ifname, color string) string { + id := resourceID(resourceKey(x.key, ifname)) + ns.ifaces[id] = neighborIface{dev: x, ifname: ifname, color: color} + return id +} + +// use marks every candidate referenced by conns as needed. +func (ns *neighborSet) use(conns []sdk.Connection) { + for _, c := range conns { + for _, id := range []string{c.Source, c.Target} { + if _, ok := ns.devices[id]; ok { + ns.used[id] = true + } + if ni, ok := ns.ifaces[id]; ok { + ns.used[id] = true + ns.used[ni.dev.id] = true + ns.devices[ni.dev.id] = ni.dev + } + } + } +} + +// build returns the used neighbor resources and the "contains" +// connections of the used neighbor interfaces, in ID order. +func (ns *neighborSet) build() ([]sdk.Resource, []sdk.Connection, int, int) { + var resources []sdk.Resource + var conns []sdk.Connection + ids := make([]string, 0, len(ns.used)) + for id := range ns.used { + ids = append(ids, id) + } + sort.Strings(ids) + var nDevices, nIfaces int + for _, id := range ids { + if x, ok := ns.devices[id]; ok { + if _, isIface := ns.ifaces[id]; !isIface { + if r, ok := ns.deviceResource(x); ok { + resources = append(resources, r) + nDevices++ + } + continue + } + } + ni, ok := ns.ifaces[id] + if !ok { + continue + } + r, err := sdk.NewResource(id, interfaceResourceType(ni.dev.resType), sdk.Provider{ + Name: providerName, + NativeID: resourceKey(ni.dev.key, ni.ifname), + Type: ni.ifname, + Site: ns.siteNames[ni.dev.SiteID], + System: ns.host, + }) + if err != nil { + continue + } + r.Name = ni.ifname + r.Properties = map[string]any{"interface_name": ni.ifname} + ext := map[string]any{"site_role": siteRoleNeighbor} + if ni.color != "" { + ext["color"] = ni.color + } + r.Extensions = map[string]any{extensionKey: ext} + resources = append(resources, r) + nIfaces++ + if c, ok := containsConnection(ni.dev.id, ni.dev.key, id, ni.ifname); ok { + conns = append(conns, c) + } + } + return resources, conns, nDevices, nIfaces +} + +// deviceResource builds the reduced neighbor form of a device. +func (ns *neighborSet) deviceResource(x *indexedDevice) (sdk.Resource, bool) { + rs, _ := TransformDevices([]Device{x.Device}, "documentation") + if len(rs) != 1 { + return sdk.Resource{}, false + } + r := rs[0] + r.Properties = nil + r.Status, r.State = "", "" + r.Provider.Site = ns.siteNames[x.SiteID] + r.Provider.System = ns.host + ext := map[string]any{"site_role": siteRoleNeighbor} + if x.SiteID != "" { + ext["site_id"] = x.SiteID + } + r.Extensions = map[string]any{extensionKey: ext} + return r, true +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/neighbors_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/neighbors_test.go new file mode 100644 index 0000000..0c9716a --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/neighbors_test.go @@ -0,0 +1,430 @@ +// neighbors_test.go - Cross-site ("site plus neighbors") tests for the +// Cisco Catalyst SD-WAN Manager OSIRIS JSON Producer: a two-site fabric +// with a controller, exported per site, must keep its cross-site OMP +// sessions and tunnels in every site document that takes part, with +// identical IDs, so an OSIRIS JSON Consumer can merge the documents. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "encoding/json" + "fmt" + "math/rand" + "net" + "os" + "reflect" + "strings" + "testing" + + "go.osirisjson.org/producers/pkg/sdk" +) + +// fabricFake is two WAN edge sites (100, 200) plus an unsited +// controller. RTR01 and RTR02 hold an OMP session with the controller +// and a biz-internet tunnel with each other. +func fabricFake() *fakeAPI { + f := twoSiteFake() + f.devices = append(f.devices, Device{DeviceID: "192.0.2.1", SystemIP: "192.0.2.1", HostName: "LAB-CONTROLLER01", UUID: "TST-UUID-CTRL", Personality: "vsmart"}) + f.ifaces = map[string][]Interface{ + "192.0.2.11": {{IfName: "ge0/0", AFType: "ipv4", VPNID: "0", IPAddress: "198.51.100.11/24"}, {IfName: "ge0/1", AFType: "ipv4", VPNID: "10"}}, + "192.0.2.12": {{IfName: "ge0/0", AFType: "ipv4", VPNID: "0", IPAddress: "198.51.100.12/24"}}, + } + f.wan = map[string][]WANInterface{ + "192.0.2.11": {{Interface: "ge0/0", Color: "biz-internet"}}, + "192.0.2.12": {{Interface: "ge0/0", Color: "biz-internet"}}, + } + f.peers = map[string][]OMPPeer{ + "192.0.2.11": {{Peer: "192.0.2.1", State: "up"}}, + "192.0.2.12": {{Peer: "192.0.2.1", State: "up"}, {Peer: "192.0.2.99", State: "up"}}, // unknown peer. + } + f.topo = map[string][]SiteTopologyDevice{ + "100": {{DeviceID: "192.0.2.11", Circuits: []SiteCircuit{{Color: "biz-internet", Tunnels: []SiteTunnel{{Name: "192.0.2.11:biz-internet-192.0.2.12:biz-internet", State: "up"}}}}}}, + "200": {{DeviceID: "192.0.2.12", Circuits: []SiteCircuit{{Color: "biz-internet", Tunnels: []SiteTunnel{{Name: "192.0.2.12:biz-internet-192.0.2.11:biz-internet", State: "up"}}}}}}, + } + return f +} + +// exportDocs runs export and returns the documents by site name. +func exportDocs(t *testing.T, f *fakeAPI, cfg *Config) map[string]sdk.Document { + t.Helper() + if err := export(f, cfg, testLogger(t), fixedRun); err != nil { + t.Fatalf("export: %v", err) + } + docs := map[string]sdk.Document{} + for _, p := range writtenFiles(t, cfg.OutputDir) { + data, err := os.ReadFile(p) + if err != nil { + t.Fatal(err) + } + var d sdk.Document + if err := json.Unmarshal(data, &d); err != nil { + t.Fatal(err) + } + name := unsitedSegment + if len(d.Metadata.Scope.Sites) > 0 { + name = d.Metadata.Scope.Sites[0] + } + docs[name] = d + } + return docs +} + +func connsOfType(d sdk.Document, typ string) map[string]sdk.Connection { + out := map[string]sdk.Connection{} + for _, c := range d.Topology.Connections { + if c.Type == typ { + out[c.ID] = c + } + } + return out +} + +func extOf(m map[string]any) map[string]any { + e, _ := m[extensionKey].(map[string]any) + return e +} + +func TestNeighbors_CrossSiteRelationshipsInEverySiteDocument(t *testing.T) { + for _, purpose := range []string{"documentation", "audit"} { + t.Run(purpose, func(t *testing.T) { + cfg := testConfig(t) + cfg.Purpose = purpose + docs := exportDocs(t, fabricFake(), cfg) + branch, office := docs["BRANCH-00"], docs["OFFICE-00"] + + tb, to := connsOfType(branch, "network.vpn"), connsOfType(office, "network.vpn") + if len(tb) != 1 || len(to) != 1 { + t.Fatalf("tunnels per document = %d, %d; want 1 each", len(tb), len(to)) + } + for id, c := range tb { + o, ok := to[id] + if !ok || o.Source != c.Source || o.Target != c.Target { + t.Errorf("the cross-site tunnel differs between documents: %+v vs %+v", c, o) + } + } + + // RTR01 -> controller and RTR02 -> controller OMP sessions. + ob, oo := connsOfType(branch, "network"), connsOfType(office, "network") + if len(ob) != 1 || len(oo) != 1 { + t.Errorf("OMP sessions per document = %d, %d; want 1 each", len(ob), len(oo)) + } + + for name, d := range docs { + ids := map[string]sdk.Resource{} + for _, r := range d.Topology.Resources { + ids[r.ID] = r + } + for _, c := range d.Topology.Connections { + if _, ok := ids[c.Source]; !ok { + t.Errorf("%s: connection %s source is not in the document", name, c.ID) + } + if _, ok := ids[c.Target]; !ok { + t.Errorf("%s: connection %s target is not in the document", name, c.ID) + } + } + if len(d.Topology.Groups) != 1 || d.Topology.Groups[0].Type != "logical.site" { + t.Fatalf("%s: groups = %+v", name, d.Topology.Groups) + } + members := map[string]bool{} + for _, m := range d.Topology.Groups[0].Members { + members[m] = true + } + var neighbors int + for id, r := range ids { + isNeighbor := extOf(r.Extensions)["site_role"] == siteRoleNeighbor + if isNeighbor { + neighbors++ + if members[id] { + t.Errorf("%s: neighbor %s is a site group member", name, id) + } + if r.Properties["ip_addresses"] != nil || r.Status != "" { + t.Errorf("%s: neighbor %s carries more than identity: %+v", name, id, r) + } + } else if !members[id] { + t.Errorf("%s: site resource %s is not a group member", name, id) + } + if r.Provider.System != cfg.Host { + t.Errorf("%s: %s provider.system = %q", name, id, r.Provider.System) + } + } + // Controller + remote router + remote transport + // interface the unsited controller document has no + // session of its own in this fixture. + if name != unsitedSegment && neighbors != 3 { + t.Errorf("%s: %d neighbor resources, want 3", name, neighbors) + } + } + + graph := extOf(office.Metadata.Extensions)["graph"].(map[string]any) + if graph["unresolved_omp"] != float64(1) { + t.Errorf("OFFICE-00 unresolved_omp = %v, want 1 (the unknown peer)", graph["unresolved_omp"]) + } + }) + } +} + +// TestNeighbors_MergeByIDGivesOneEndToEndGraph merges the two site +// documents the way an OSIRIS JSON Consumer does (union by ID, full +// record preferred over a neighbor) and requires one complete graph. +func TestNeighbors_MergeByIDGivesOneEndToEndGraph(t *testing.T) { + cfg := testConfig(t) + cfg.Purpose = "audit" + docs := exportDocs(t, fabricFake(), cfg) + + res := map[string]sdk.Resource{} + conns := map[string]sdk.Connection{} + for _, d := range docs { + for _, r := range d.Topology.Resources { + prev, seen := res[r.ID] + if !seen || extOf(prev.Extensions)["site_role"] == siteRoleNeighbor { + if seen && prev.Type != r.Type { + t.Errorf("%s has type %s in one document and %s in another", r.ID, prev.Type, r.Type) + } + res[r.ID] = r + } + } + for _, c := range d.Topology.Connections { + if prev, seen := conns[c.ID]; seen && (prev.Source != c.Source || prev.Target != c.Target) { + t.Errorf("connection %s differs between documents", c.ID) + } + conns[c.ID] = c + } + } + var vpn, omp int + for _, c := range conns { + switch c.Type { + case "network.vpn": + vpn++ + case "network": + omp++ + } + } + if vpn != 1 || omp != 2 { + t.Errorf("merged graph: %d tunnels, %d OMP sessions; want 1 and 2", vpn, omp) + } + // Every site, the controller's unsited bucket included, was + // exported, so every neighbor is replaced by its full record. + for id, r := range res { + if extOf(r.Extensions)["site_role"] == siteRoleNeighbor { + t.Errorf("after merge %s should be its full site record", id) + } + } + if _, ok := res[resourceID("TST-UUID-CTRL")]; !ok { + t.Error("merged graph lacks the controller") + } +} + +func TestNeighbors_PeerOutsideSelectedSitesStillResolves(t *testing.T) { + f := fabricFake() + cfg := testConfig(t) + cfg.AllSites = false + cfg.SiteFilter = []string{"100"} + docs := exportDocs(t, f, cfg) + if len(docs) != 1 { + t.Fatalf("documents = %d, want 1", len(docs)) + } + if !f.called("wan_interface:192.0.2.12") { + t.Error("the tunnel peer's WAN interfaces were not fetched") + } + if f.called("device_interface:192.0.2.12") || f.called("omp_peers:192.0.2.12") { + t.Error("an unselected site's devices must not be fully collected") + } + if n := len(connsOfType(docs["BRANCH-00"], "network.vpn")); n != 1 { + t.Errorf("tunnels = %d, want 1", n) + } +} + +func TestMergeInterfaceRows_VPNAndAddressFamily(t *testing.T) { + rows := []Interface{ + {IfName: "ge0/1", AFType: "ipv6", VPNID: "10", Description: "uplink to LAB-SW01"}, + {IfName: "ge0/1", AFType: "ipv4", VPNID: "10", IPAddress: "198.51.100.1/24"}, + {IfName: "ge0/1", AFType: "ipv4", VPNID: "0"}, + {IfName: "ge0/2", AFType: "ipv4", VPNID: "512"}, + } + got := mergeInterfaceRows(rows) + keys := map[string]mergedInterface{} + for _, m := range got { + keys[m.key] = m + } + if len(got) != 3 { + t.Fatalf("merged = %d interfaces, want 3: %+v", len(got), got) + } + if _, ok := keys["ge0/1"]; !ok { + t.Error("VPN 0 ge0/1 must keep the plain key") + } + v10, ok := keys["ge0/1@vpn10"] + if !ok || v10.Description != "uplink to LAB-SW01" || v10.IPAddress != "198.51.100.1/24" { + t.Errorf("VPN 10 ge0/1 = %+v, want the IPv4 row with the IPv6 row's description", v10) + } + if _, ok := keys["ge0/2"]; !ok { + t.Error("an interface used in one VPN keeps its plain key") + } +} + +// TestIsPublicIP checks the classification boundaries. The non-public +// addresses are built from their octets: they are the protocol ranges +// under test (RFC 1918, RFC 6598, RFC 3927, RFC 4193), not data. +func TestIsPublicIP(t *testing.T) { + ula := net.IP{0xfd, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1} + for ip, want := range map[string]bool{ + "198.51.100.1": true, + "2001:db8::1": true, + "127.0.0.1": false, + net.IPv4(10, 0, 0, 1).String(): false, + net.IPv4(100, 64, 0, 1).String(): false, + net.IPv4(169, 254, 0, 1).String(): false, + ula.String(): false, + } { + if got := isPublicIP(ip); got != want { + t.Errorf("isPublicIP(%s) = %v, want %v", ip, got, want) + } + } +} + +// TestExport_DocumentsIndependentOfAPIOrder shuffles every API list of +// the two-site fabric 100 times and requires byte-identical documents. +func TestExport_DocumentsIndependentOfAPIOrder(t *testing.T) { + render := func(f *fakeAPI) map[string]string { + cfg := testConfig(t) + cfg.Purpose = "audit" + if err := export(f, cfg, testLogger(t), fixedRun); err != nil { + t.Fatal(err) + } + out := map[string]string{} + for _, p := range writtenFiles(t, cfg.OutputDir) { + data, err := os.ReadFile(p) + if err != nil { + t.Fatal(err) + } + out[p[len(cfg.OutputDir):]] = string(data) + } + return out + } + want := render(fabricFake()) + r := rand.New(rand.NewSource(7)) + for i := 0; i < 100; i++ { + f := fabricFake() + r.Shuffle(len(f.devices), func(a, b int) { f.devices[a], f.devices[b] = f.devices[b], f.devices[a] }) + for _, m := range []map[string][]Interface{f.ifaces} { + for k, v := range m { + r.Shuffle(len(v), func(a, b int) { v[a], v[b] = v[b], v[a] }) + m[k] = v + } + } + for k, v := range f.peers { + r.Shuffle(len(v), func(a, b int) { v[a], v[b] = v[b], v[a] }) + f.peers[k] = v + } + got := render(f) + if !reflect.DeepEqual(got, want) { + t.Fatalf("permutation %d changed the documents", i) + } + } +} + +func TestTransformInterfaces_SharedColorIsAmbiguous(t *testing.T) { + ifaces := []Interface{ + {IfName: "GigabitEthernet1", AFType: "ipv4", VPNID: "0"}, + {IfName: "GigabitEthernet2", AFType: "ipv4", VPNID: "0"}, + } + wan := []WANInterface{ + {Interface: "GigabitEthernet1", Color: "mpls"}, + {Interface: "GigabitEthernet2", Color: "mpls"}, + } + _, _, idx := TransformInterfaces(resourceID("TST0000011"), "network.router", "TST0000011", "192.0.2.11", ifaces, wan) + if id, ok := idx["192.0.2.11:mpls"]; !ok || id != "" { + t.Errorf("tunnel index for a color on two interfaces = %q, %v; want ambiguous", id, ok) + } +} + +func TestVPNLess(t *testing.T) { + for _, c := range []struct { + a, b string + want bool + }{{"0", "10", true}, {"10", "9", false}, {"2", "x", true}, {"x", "2", false}, {"a", "b", true}} { + if got := vpnLess(c.a, c.b); got != c.want { + t.Errorf("vpnLess(%q, %q) = %v, want %v", c.a, c.b, got, c.want) + } + } +} + +// TestRawTopology_OwnerBySystemIPAndUnownedCounted covers a Manager +// whose site topology "device-id" is not the inventory deviceId: the +// row attaches through its circuit's system IP, and a row nobody owns +// is counted in raw_omitted instead of being dropped silently. +func TestRawTopology_OwnerBySystemIPAndUnownedCounted(t *testing.T) { + f := fabricFake() + f.topo["100"] = []SiteTopologyDevice{ + {DeviceID: "TST-OTHER-ID", Circuits: []SiteCircuit{{Color: "biz-internet", SystemIP: "192.0.2.11", Tunnels: []SiteTunnel{{Name: "192.0.2.11:biz-internet-192.0.2.12:biz-internet", State: "up"}}}}}, + {DeviceID: "TST-NOBODY"}, + } + cfg := testConfig(t) + cfg.Purpose, cfg.IncludeRawBody = "audit", true + docs := exportDocs(t, f, cfg) + var router sdk.Resource + for _, r := range docs["BRANCH-00"].Topology.Resources { + if r.ID == resourceID("TST0000001") { + router = r + } + } + ext := extOf(router.Extensions) + if _, ok := ext["site_topology_raw"]; !ok { + t.Error("site_topology_raw not attached through the circuit system IP") + } + got, _ := json.Marshal(ext["raw_omitted"]) + if !reflect.DeepEqual(string(got), `[{"count":1,"endpoint":"site_topology_raw","reason":"unowned"}]`) { + t.Errorf("raw_omitted = %s, want one unowned site_topology_raw row", got) + } +} + +// TestNeighbors_HubWithManyPeersOutsideSelection exports only a hub +// site whose 100 spokes are in other sites: every spoke's WAN listing +// is fetched once (in parallel) and every tunnel is resolved. +func TestNeighbors_HubWithManyPeersOutsideSelection(t *testing.T) { + const spokes = 100 + hub := Device{DeviceID: "192.0.2.10", SystemIP: "192.0.2.10", HostName: "LAB-RTR00", BoardSerial: "TST0009999", SiteID: "100", Personality: "vedge"} + f := &fakeAPI{ + devices: []Device{hub}, + names: map[string]string{"100": "MXP"}, + ifaces: map[string][]Interface{hub.SystemIP: {{IfName: "GigabitEthernet1", AFType: "ipv4", VPNID: "0"}}}, + wan: map[string][]WANInterface{hub.SystemIP: {{Interface: "GigabitEthernet1", Color: "mpls"}}}, + topo: map[string][]SiteTopologyDevice{}, + } + var tunnels []SiteTunnel + for i := 0; i < spokes; i++ { + ip := fmt.Sprintf("198.51.100.%d", i+1) + f.devices = append(f.devices, Device{DeviceID: ip, SystemIP: ip, HostName: fmt.Sprintf("LAB-RTR%03d", i+1), BoardSerial: fmt.Sprintf("TST%07d", i+1), SiteID: fmt.Sprintf("%d", 1000+i), Personality: "vedge"}) + f.wan[ip] = []WANInterface{{Interface: "GigabitEthernet1", Color: "mpls"}} + tunnels = append(tunnels, SiteTunnel{Name: hub.SystemIP + ":mpls-" + ip + ":mpls", State: "up"}) + } + f.topo["100"] = []SiteTopologyDevice{{DeviceID: hub.DeviceID, Circuits: []SiteCircuit{{Color: "mpls", SystemIP: hub.SystemIP, Tunnels: tunnels}}}} + + cfg := testConfig(t) + cfg.AllSites, cfg.SiteFilter = false, []string{"100"} + docs := exportDocs(t, f, cfg) + d := docs["MXP"] + if n := len(connsOfType(d, "network.vpn")); n != spokes { + t.Errorf("tunnels = %d, want %d", n, spokes) + } + peerCalls := 0 + for _, c := range f.calls { + if strings.HasPrefix(c, "wan_interface:198.51.100.") { + peerCalls++ + } + } + if peerCalls != spokes { + t.Errorf("peer WAN lookups = %d, want %d (one per spoke)", peerCalls, spokes) + } + graph := extOf(d.Metadata.Extensions)["graph"].(map[string]any) + if graph["unresolved_tunnels"] != float64(0) || graph["neighbor_interfaces"] != float64(spokes) { + t.Errorf("graph = %v", graph) + } + for _, e := range extOf(d.Metadata.Extensions)["coverage"].([]any) { + if m := e.(map[string]any); m["operation"] == opNeighborWAN && m["attempts"] != float64(spokes) { + t.Errorf("neighbor_wan_interface attempts = %v, want %d (this site's peers only)", m["attempts"], spokes) + } + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/output.go b/osiris/network/cisco/catalyst-sd-wan-manager/output.go new file mode 100644 index 0000000..6205e92 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/output.go @@ -0,0 +1,142 @@ +// output.go - Private, contained and atomic publication of the Cisco +// Catalyst SD-WAN Manager OSIRIS JSON Producer documents. +// +// writeDocument publishes one serialized document at a path built by +// OutputPath: +// +// - containment: the path must resolve inside the output root, and +// the site directory must not be a symbolic link, so a site label +// can never steer a write outside --output; +// - privacy: directories this producer creates are 0700 and the +// document is 0600, independent of the process umask (an exported +// topology is sensitive even without secrets); +// - atomicity: the document is written to a temporary file in the +// target directory, synced and closed, then published under its +// final name, so a reader never sees a partial document and a +// failed write leaves every existing file untouched; +// - no silent overwrite: publication fails when the final name +// already exists (for example two runs of the same site within one +// second) instead of replacing it. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "errors" + "fmt" + "io/fs" + "os" + "path/filepath" + "strings" +) + +const ( + // outputDirMode is the mode of every directory this producer + // creates. + outputDirMode fs.FileMode = 0o700 + // outputFileMode is the mode of every published document. + outputFileMode fs.FileMode = 0o600 +) + +// errOutputExists is returned when the final document path already +// exists; nothing is overwritten. +var errOutputExists = errors.New("output file already exists") + +// writeDocument publishes data at path, which must lie strictly inside +// root (see the file comment for the guarantees). +func writeDocument(root, path string, data []byte) error { + root = filepath.Clean(root) + path = filepath.Clean(path) + rel, err := filepath.Rel(root, path) + if err != nil || rel == "." || rel == ".." || strings.HasPrefix(rel, ".."+string(filepath.Separator)) || filepath.IsAbs(rel) { + return fmt.Errorf("output path escapes the output directory") + } + + dir := filepath.Dir(path) + if err := os.MkdirAll(dir, outputDirMode); err != nil { + return fmt.Errorf("creating output directory: %w", err) + } + if dir != root { + fi, err := os.Lstat(dir) + if err != nil { + return fmt.Errorf("checking output directory: %w", err) + } + if fi.Mode()&fs.ModeSymlink != 0 || !fi.IsDir() { + return fmt.Errorf("output site directory is not a plain directory") + } + } + if _, err := os.Lstat(path); err == nil { + return errOutputExists + } else if !errors.Is(err, fs.ErrNotExist) { + return fmt.Errorf("checking output file: %w", err) + } + + tmp, err := os.CreateTemp(dir, ".osiris-*.tmp") + if err != nil { + return fmt.Errorf("creating temporary file: %w", err) + } + tmpName := tmp.Name() + published := false + defer func() { + if !published { + os.Remove(tmpName) + } + }() + + if err := tmp.Chmod(outputFileMode); err != nil { + tmp.Close() + return fmt.Errorf("setting file mode: %w", err) + } + if _, err := tmp.Write(data); err != nil { + tmp.Close() + return fmt.Errorf("writing temporary file: %w", err) + } + if err := tmp.Sync(); err != nil { + tmp.Close() + return fmt.Errorf("syncing temporary file: %w", err) + } + if err := tmp.Close(); err != nil { + return fmt.Errorf("closing temporary file: %w", err) + } + + if err := publish(tmpName, path); err != nil { + return err + } + published = true + syncDir(dir) + return nil +} + +// publish moves the completed temporary file to its final name without +// replacing an existing file. A hard link fails atomically when the +// target exists where hard links are unsupported (some network and +// FAT filesystems) it falls back to a rename after a fresh existence +// check, which narrows but cannot fully close the race on such +// filesystems. +func publish(tmpName, path string) error { + if err := os.Link(tmpName, path); err == nil { + os.Remove(tmpName) + return nil + } else if errors.Is(err, fs.ErrExist) { + return errOutputExists + } + if _, err := os.Lstat(path); err == nil { + return errOutputExists + } + if err := os.Rename(tmpName, path); err != nil { + return fmt.Errorf("publishing output file: %w", err) + } + return nil +} + +// syncDir flushes a directory entry change to disk where the platform +// supports it failures are ignored because the document itself is +// already synced and published. +func syncDir(dir string) { + if d, err := os.Open(dir); err == nil { + d.Sync() + d.Close() + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/output_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/output_test.go new file mode 100644 index 0000000..044624b --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/output_test.go @@ -0,0 +1,152 @@ +// output_test.go - Tests for the private, contained and atomic document +// publication of the Cisco Catalyst SD-WAN Manager OSIRIS JSON +// Producer and for the per-run output path component policy. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "errors" + "os" + "path/filepath" + "runtime" + "strings" + "testing" +) + +func TestSanitizeFilenameSegment(t *testing.T) { + tests := []struct{ in, want string }{ + {"BRANCH-00", "BRANCH-00"}, + {"..", ""}, + {".", ""}, + {"../../etc", "-..-etc"}, + {".hidden", "hidden"}, + {"trailing.", "trailing"}, + {"a/b", "a-b"}, + {"a\\b", "a-b"}, + {"tab\there", "tab-here"}, + {"bell\x07", "bell-"}, + {"line\nbreak", "line-break"}, + {"esc\x1b[31m", "esc-[31m"}, + {"OFFICE 00", "OFFICE-00"}, + } + for _, tt := range tests { + if got := sanitizeFilenameSegment(tt.in); got != tt.want { + t.Errorf("sanitizeFilenameSegment(%q) = %q, want %q", tt.in, got, tt.want) + } + } +} + +func TestOutputPath_DotSegmentsStayInsideRoot(t *testing.T) { + for _, name := range []string{"..", ".", "../..", "/", "\\.."} { + p := OutputPath("/out", "2026-08-08T10-00-00Z", name) + rel, err := filepath.Rel("/out", p) + if err != nil || strings.HasPrefix(rel, "..") || strings.Count(rel, string(filepath.Separator)) != 1 { + t.Errorf("OutputPath(%q) = %q escapes or nests under /out", name, p) + } + } +} + +func TestSiteSegments_DistinctPerSite(t *testing.T) { + var s siteSegments + a := s.segment("100", "a/b") + b := s.segment("200", "a:b") + c := s.segment("300", "A-B") + again := s.segment("100", "a/b") + if a != "a-b" { + t.Errorf("first site segment = %q, want a-b", a) + } + if b == a || c == a || c == b { + t.Errorf("colliding labels share a segment: %q %q %q", a, b, c) + } + if b != "a-b-200" || c != "A-B-300" { + t.Errorf("segments = %q, %q, want a-b-200, A-B-300", b, c) + } + if again != a { + t.Errorf("same site re-asked = %q, want %q", again, a) + } + if u := s.segment("", ""); u != unsitedSegment { + t.Errorf("unsited segment = %q, want %q", u, unsitedSegment) + } + if n := s.segment("400", unsitedSegment); n == unsitedSegment { + t.Errorf("a site named %q must not share the unsited directory", unsitedSegment) + } +} + +func TestWriteDocument_NeverOverwrites(t *testing.T) { + root := t.TempDir() + path := OutputPath(root, "2026-08-08T10-00-00Z", "BRANCH-00") + if err := writeDocument(root, path, []byte(`{"first":true}`)); err != nil { + t.Fatal(err) + } + if err := writeDocument(root, path, []byte(`{"second":true}`)); !errors.Is(err, errOutputExists) { + t.Fatalf("second write err = %v, want errOutputExists", err) + } + data, _ := os.ReadFile(path) + if string(data) != `{"first":true}` { + t.Errorf("existing file changed to %s", data) + } + assertNoTempFiles(t, filepath.Dir(path)) +} + +func TestWriteDocument_RejectsEscapeAndSymlinkedSiteDir(t *testing.T) { + root := t.TempDir() + for _, p := range []string{filepath.Join(root, "..", "x.json"), root, filepath.Join(root, "..")} { + if err := writeDocument(root, p, []byte(`{}`)); err == nil { + t.Errorf("writeDocument(%q) succeeded outside the root", p) + } + } + + if runtime.GOOS == "windows" { + t.Skip("symlink creation needs privileges on Windows") + } + elsewhere := t.TempDir() + if err := os.Symlink(elsewhere, filepath.Join(root, "BRANCH-00")); err != nil { + t.Fatal(err) + } + path := OutputPath(root, "2026-08-08T10-00-00Z", "BRANCH-00") + if err := writeDocument(root, path, []byte(`{}`)); err == nil { + t.Error("writeDocument followed a symlinked site directory") + } + if entries, _ := os.ReadDir(elsewhere); len(entries) != 0 { + t.Errorf("symlink target received %d entries", len(entries)) + } +} + +func TestWriteDocument_FailedWriteLeavesNothing(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Unix modes") + } + if os.Geteuid() == 0 { + t.Skip("root ignores directory permissions") + } + root := t.TempDir() + dir := filepath.Join(root, "BRANCH-00") + if err := os.Mkdir(dir, 0o500); err != nil { + t.Fatal(err) + } + defer os.Chmod(dir, 0o700) + path := OutputPath(root, "2026-08-08T10-00-00Z", "BRANCH-00") + if err := writeDocument(root, path, []byte(`{}`)); err == nil { + t.Fatal("expected a write into a read-only directory to fail") + } + os.Chmod(dir, 0o700) + if entries, _ := os.ReadDir(dir); len(entries) != 0 { + t.Errorf("failed write left %d entries", len(entries)) + } +} + +func assertNoTempFiles(t *testing.T, dir string) { + t.Helper() + entries, err := os.ReadDir(dir) + if err != nil { + t.Fatal(err) + } + for _, e := range entries { + if strings.HasPrefix(e.Name(), ".osiris-") { + t.Errorf("temporary file %s left behind", e.Name()) + } + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/output_unix_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/output_unix_test.go new file mode 100644 index 0000000..d2565b2 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/output_unix_test.go @@ -0,0 +1,50 @@ +//go:build unix + +// output_unix_test.go - Unix file mode tests for the Cisco Catalyst +// SD-WAN Manager OSIRIS JSON Producer document. Created directories are +// 0700 and documents 0600 under both a permissive (022) and a +// restrictive (077) umask. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "fmt" + "os" + "path/filepath" + "syscall" + "testing" +) + +func TestWriteDocument_PrivateAndAtomic(t *testing.T) { + for _, mask := range []int{0o022, 0o077} { + t.Run(fmt.Sprintf("umask-%03o", mask), func(t *testing.T) { + old := syscall.Umask(mask) + defer syscall.Umask(old) + root := filepath.Join(t.TempDir(), "out") + path := OutputPath(root, "2026-08-08T10-00-00Z", "BRANCH-00") + if err := writeDocument(root, path, []byte(`{"a":1}`)); err != nil { + t.Fatalf("writeDocument: %v", err) + } + for _, d := range []string{root, filepath.Dir(path)} { + fi, err := os.Stat(d) + if err != nil { + t.Fatal(err) + } + if fi.Mode().Perm() != outputDirMode { + t.Errorf("umask %03o: %s mode = %v, want %v", mask, d, fi.Mode().Perm(), outputDirMode) + } + } + fi, err := os.Stat(path) + if err != nil { + t.Fatal(err) + } + if fi.Mode().Perm() != outputFileMode { + t.Errorf("umask %03o: file mode = %v, want %v", mask, fi.Mode().Perm(), outputFileMode) + } + assertNoTempFiles(t, filepath.Dir(path)) + }) + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/purpose.go b/osiris/network/cisco/catalyst-sd-wan-manager/purpose.go new file mode 100644 index 0000000..a1b5087 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/purpose.go @@ -0,0 +1,132 @@ +// purpose.go - --purpose documentation field contract for the Cisco +// Catalyst SD-WAN Manager OSIRIS JSON Producer. +// +// OSIRIS JSON specification chapter 13.1.3 targets the documentation +// purpose at diagrams, inventories and high-level documentation and +// leaves out detailed IP addresses, serial numbers and configuration +// specifics. This producer keeps an explicit allowlist instead of the +// shared osirismeta.Project projection (which drops every property and +// extension), so a documentation document still labels interfaces, +// VPNs, transport colors and device models: +// +// device (network.router, osiris.cisco.controller) +// properties: model, manufacturer, version +// extension: site_id, health, site_role +// interface (network.interface, network.router.port) +// properties: interface_name, interface_type, admin_status, +// oper_status, speed_mbps, vpn_id +// extension: color, site_role +// connection +// extension: color, colors, protocol +// group: extension site_id, unsited; no properties +// +// Everything else (addresses, MAC addresses, management IPs, site +// coordinates, system IPs, device groups, connected managers, +// timestamps, state text, duplex, MTU, encapsulation, NAT type, serial +// and chassis numbers, certificate state, quality scores, OMP sources +// and observed states, raw rows) is audit only. Identity, names, +// descriptions, provider fields, connections and group membership are +// kept in both purposes. --purpose audit is unchanged, secrets are +// redacted in both (see raw.go). Documentation is minimized, not +// anonymized. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import "go.osirisjson.org/producers/pkg/sdk" + +// fieldAllowlist is the documentation field set for one element kind. +type fieldAllowlist struct { + properties map[string]bool + extension map[string]bool +} + +func keySet(keys ...string) map[string]bool { + m := make(map[string]bool, len(keys)) + for _, k := range keys { + m[k] = true + } + return m +} + +var ( + documentationDevice = fieldAllowlist{ + properties: keySet("model", "manufacturer", "version"), + extension: keySet("site_id", "health", "site_role"), + } + documentationInterface = fieldAllowlist{ + properties: keySet("interface_name", "interface_type", "admin_status", "oper_status", "speed_mbps", "vpn_id"), + extension: keySet("color", "site_role"), + } + documentationConnection = fieldAllowlist{ + extension: keySet("color", "colors", "protocol"), + } + documentationGroup = fieldAllowlist{ + extension: keySet("site_id", "unsited"), + } + // documentationOther applies to any element kind not listed above + // (for example a resource type added later): nothing beyond the + // core fields until it is reviewed into an allowlist. + documentationOther = fieldAllowlist{} +) + +// resourceAllowlist returns the documentation allowlist for a resource +// type. +func resourceAllowlist(resType string) fieldAllowlist { + switch resType { + case "network.router", "osiris.cisco.controller": + return documentationDevice + case "network.interface", "network.router.port": + return documentationInterface + } + return documentationOther +} + +// filterProperties keeps only the allowed keys; it returns nil when +// none remain so the member is omitted from the document. +func filterProperties(m map[string]any, allowed map[string]bool) map[string]any { + out := map[string]any{} + for k, v := range m { + if allowed[k] { + out[k] = v + } + } + if len(out) == 0 { + return nil + } + return out +} + +// filterExtensions applies allowed to the producer's own extension +// namespace and drops any other namespace. +func filterExtensions(m map[string]any, allowed map[string]bool) map[string]any { + ext, _ := m[extensionKey].(map[string]any) + kept := filterProperties(ext, allowed) + if kept == nil { + return nil + } + return map[string]any{extensionKey: kept} +} + +// applyPurpose enforces the documentation field contract in place. +// It is a no-op for audit. +func applyPurpose(purpose string, resources []sdk.Resource, connections []sdk.Connection, groups []sdk.Group) { + if purpose == "audit" { + return + } + for i := range resources { + al := resourceAllowlist(resources[i].Type) + resources[i].Properties = filterProperties(resources[i].Properties, al.properties) + resources[i].Extensions = filterExtensions(resources[i].Extensions, al.extension) + } + for i := range connections { + connections[i].Properties = filterProperties(connections[i].Properties, documentationConnection.properties) + connections[i].Extensions = filterExtensions(connections[i].Extensions, documentationConnection.extension) + } + for i := range groups { + groups[i].Properties = nil + groups[i].Extensions = filterExtensions(groups[i].Extensions, documentationGroup.extension) + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/raw.go b/osiris/network/cisco/catalyst-sd-wan-manager/raw.go new file mode 100644 index 0000000..1d7a893 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/raw.go @@ -0,0 +1,332 @@ +// raw.go - --include-raw-body support and producer-side secret +// redaction for the Cisco Catalyst SD-WAN Manager OSIRIS JSON Producer. +// +// With --include-raw-body (accepted only together with --purpose audit) +// each collected API row is attached to the device resource that owns +// it under extensions["osiris.cisco.catalystsdwanmanager"], keyed by +// endpoint (raw, interfaces_raw, wan_interfaces_raw, omp_peers_raw, +// site_topology_raw), as a fallback for fields this producer does not +// model into OSIRIS JSON yet. Rows are never attached unmodified: +// +// - every row is decoded and walked recursively (objects and arrays +// at any depth); the value under any key that sdk.IsSensitiveKey +// flags, or that is an SD-WAN credential attribute +// (rawSensitiveKeys), and every string value sdk.ScanValue flags, +// is replaced with sdk.RedactedValue; +// - a row that is not valid JSON cannot be redacted and is dropped; +// - one row is capped at maxRawRowBytes after redaction and all rows +// of one document at maxRawTotalBytes. +// +// Every withheld row is counted in raw_omitted on its owning device +// resource, by endpoint and reason, so the fallback never fails +// silently. +// +// The same redaction walk backs --safe-failure-mode log-and-redact and +// off: redactElements replaces detected values in every +// producer-defined field (name, description, properties, extensions) +// before Build, so neither mode can emit a detected secret. The +// document secret scan still runs over the result. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "bytes" + "encoding/json" + "fmt" + "sort" + "strings" + + "go.osirisjson.org/producers/pkg/sdk" +) + +const ( + // maxRawRowBytes caps the JSON size of one attached row. + maxRawRowBytes = 256 << 10 + // maxRawTotalBytes caps the JSON size of all rows of one document. + maxRawTotalBytes = 16 << 20 +) + +// Reasons a raw row is withheld, reported in raw_omitted. +const ( + rawOmitUnparseable = "unparseable" + rawOmitTooLarge = "row-too-large" + rawOmitTotalLimit = "total-limit" + rawOmitUnowned = "unowned" // no device resource of the document owns the row. +) + +// rawSensitiveKeys are SD-WAN Manager field names (lower case) that can +// carry credential or key material but match no shared sensitive-key +// pattern: shared keys, pre-shared keys, SNMP communities and password +// hashes. +var rawSensitiveKeys = map[string]bool{ + "pwd": true, + "passwd": true, + "key": true, + "psk": true, + "pre-shared-key": true, + "community": true, + "passphrase": true, + "hash": true, +} + +// sensitiveKey reports whether the value under key k must be redacted. +// Hyphenated SD-WAN names are also checked in their underscore form so +// they match the shared patterns (for example "auth-key"). +func sensitiveKey(k string) bool { + lower := strings.ToLower(k) + return rawSensitiveKeys[lower] || sdk.IsSensitiveKey(strings.ReplaceAll(lower, "-", "_")) +} + +// redactValue returns a copy of v (a decoded JSON value) with every +// value under a sensitive key and every secret-shaped string replaced +// with sdk.RedactedValue, recursing through objects and arrays. A null +// or empty value under a sensitive key is kept as is: it carries no +// secret. n counts the replacements. +func redactValue(v any, n *int) any { + switch t := v.(type) { + case map[string]any: + out := make(map[string]any, len(t)) + for k, val := range t { + if sensitiveKey(k) { + if s, ok := val.(string); val == nil || (ok && (s == "" || s == sdk.RedactedValue)) { + out[k] = val + continue + } + out[k] = sdk.RedactedValue + *n++ + continue + } + out[k] = redactValue(val, n) + } + return out + case []any: + out := make([]any, len(t)) + for i, val := range t { + out[i] = redactValue(val, n) + } + return out + case []map[string]any: + out := make([]any, len(t)) + for i, val := range t { + out[i] = redactValue(val, n) + } + return out + case []string: + out := make([]any, len(t)) + for i, val := range t { + out[i] = redactValue(val, n) + } + return out + case string: + if sdk.ScanValue(t) != "" { + *n++ + return sdk.RedactedValue + } + return t + } + return v +} + +// decodeRaw decodes one raw row, keeping numbers exact. +func decodeRaw(raw json.RawMessage) (any, error) { + dec := json.NewDecoder(bytes.NewReader(raw)) + dec.UseNumber() + var v any + if err := dec.Decode(&v); err != nil { + return nil, err + } + return v, nil +} + +// rawOmitKey identifies one raw_omitted counter. +type rawOmitKey struct { + resourceID string + endpoint string + reason string +} + +// rawCollector redacts and attaches raw rows for one document and +// accounts for every row it withholds. A nil *rawCollector attaches +// nothing, so callers can use it unconditionally. +type rawCollector struct { + total int + omitted map[rawOmitKey]int +} + +// newRawCollector returns a collector when enabled, otherwise nil. +func newRawCollector(enabled bool) *rawCollector { + if !enabled { + return nil + } + return &rawCollector{omitted: map[rawOmitKey]int{}} +} + +// redactRow decodes, redacts and size-checks one row for endpoint, +// charging omissions to resourceID. ok is false when the row is +// withheld. +func (rc *rawCollector) redactRow(resourceID, endpoint string, raw json.RawMessage) (any, bool) { + v, err := decodeRaw(raw) + if err != nil { + rc.omitted[rawOmitKey{resourceID, endpoint, rawOmitUnparseable}]++ + return nil, false + } + var n int + red := redactValue(v, &n) + b, err := json.Marshal(red) + if err != nil { + rc.omitted[rawOmitKey{resourceID, endpoint, rawOmitUnparseable}]++ + return nil, false + } + if len(b) > maxRawRowBytes { + rc.omitted[rawOmitKey{resourceID, endpoint, rawOmitTooLarge}]++ + return nil, false + } + if rc.total+len(b) > maxRawTotalBytes { + rc.omitted[rawOmitKey{resourceID, endpoint, rawOmitTotalLimit}]++ + return nil, false + } + rc.total += len(b) + return red, true +} + +// attachOne attaches a single redacted row under endpoint. +func (rc *rawCollector) attachOne(r *sdk.Resource, endpoint string, raw json.RawMessage) { + if rc == nil { + return + } + if red, ok := rc.redactRow(r.ID, endpoint, raw); ok { + setExtension(r, endpoint, red) + } +} + +// attachList attaches the redacted rows that pass under endpoint, +// preserving their order. Nothing is attached when every row is +// withheld. +func (rc *rawCollector) attachList(r *sdk.Resource, endpoint string, raws []json.RawMessage) { + if rc == nil || len(raws) == 0 { + return + } + rows := make([]any, 0, len(raws)) + for _, raw := range raws { + if red, ok := rc.redactRow(r.ID, endpoint, raw); ok { + rows = append(rows, red) + } + } + if len(rows) > 0 { + setExtension(r, endpoint, rows) + } +} + +// omit counts n rows of endpoint withheld for reason, charged to the +// resource resourceID. +func (rc *rawCollector) omit(resourceID, endpoint, reason string, n int) { + if rc == nil || n <= 0 { + return + } + rc.omitted[rawOmitKey{resourceID, endpoint, reason}] += n +} + +// finish records raw_omitted on every resource that had a row +// withheld, as a list of {endpoint, reason, count} ordered by endpoint +// then reason. +func (rc *rawCollector) finish(resources []sdk.Resource) { + if rc == nil || len(rc.omitted) == 0 { + return + } + byResource := map[string][]rawOmitKey{} + for k := range rc.omitted { + byResource[k.resourceID] = append(byResource[k.resourceID], k) + } + for i := range resources { + keys := byResource[resources[i].ID] + if len(keys) == 0 { + continue + } + sort.Slice(keys, func(a, b int) bool { + if keys[a].endpoint != keys[b].endpoint { + return keys[a].endpoint < keys[b].endpoint + } + return keys[a].reason < keys[b].reason + }) + list := make([]any, 0, len(keys)) + for _, k := range keys { + list = append(list, map[string]any{"endpoint": k.endpoint, "reason": k.reason, "count": rc.omitted[k]}) + } + setExtension(&resources[i], "raw_omitted", list) + } +} + +// redactString replaces s with sdk.RedactedValue when it matches a +// secret pattern. +func redactString(s string, n *int) string { + if s != "" && sdk.ScanValue(s) != "" { + *n++ + return sdk.RedactedValue + } + return s +} + +// redactMap redacts a properties or extensions map in place of a copy. +func redactMap(m map[string]any, n *int) map[string]any { + if m == nil { + return nil + } + out, _ := redactValue(m, n).(map[string]any) + return out +} + +// verifyRedacted enforces the no-secret invariant for log-and-redact: +// sdk.DocumentBuilder.Build only logs findings in that mode and marks +// the document redacted, so a finding left after redactElements (in a +// field the producer does not redact, such as an ID) must not be +// written under a redacted=true claim. Findings are reported by path +// and rule only, never by value. fail-closed is already enforced by +// Build and off disables the check by request. +func verifyRedacted(doc *sdk.Document, mode string) error { + if mode != sdk.LogAndRedact { + return nil + } + findings := sdk.ScanDocument(doc) + if len(findings) == 0 { + return nil + } + paths := make([]string, len(findings)) + for i, f := range findings { + paths[i] = f.Path + " (" + f.Rule + ")" + } + return fmt.Errorf("secret scanning detected %d unredacted finding(s) after redaction, aborting (log-and-redact): %s", len(findings), strings.Join(paths, "; ")) +} + +// redactElements replaces every detected secret in the +// producer-defined fields of resources, connections and groups (name, +// description, properties, extensions) with sdk.RedactedValue, and +// returns the number of replaced values. It backs +// --safe-failure-mode log-and-redact and off (see the file comment). +func redactElements(resources []sdk.Resource, connections []sdk.Connection, groups []sdk.Group) int { + var n int + for i := range resources { + r := &resources[i] + r.Name = redactString(r.Name, &n) + r.Description = redactString(r.Description, &n) + r.Properties = redactMap(r.Properties, &n) + r.Extensions = redactMap(r.Extensions, &n) + } + for i := range connections { + c := &connections[i] + c.Name = redactString(c.Name, &n) + c.Description = redactString(c.Description, &n) + c.Properties = redactMap(c.Properties, &n) + c.Extensions = redactMap(c.Extensions, &n) + } + for i := range groups { + g := &groups[i] + g.Name = redactString(g.Name, &n) + g.Description = redactString(g.Description, &n) + g.Properties = redactMap(g.Properties, &n) + g.Extensions = redactMap(g.Extensions, &n) + } + return n +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/raw_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/raw_test.go new file mode 100644 index 0000000..687ba18 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/raw_test.go @@ -0,0 +1,225 @@ +// raw_test.go - Tests for --include-raw-body redaction, raw row +// accounting and the producer-side log-and-redact pass of the Cisco +// Catalyst SD-WAN Manager OSIRIS JSON Producer. +// +// Secret-shaped inputs use the approved synthetic placeholders only. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "encoding/json" + "strings" + "testing" + + "go.osirisjson.org/producers/pkg/sdk" + "go.osirisjson.org/producers/pkg/testharness" +) + +const ( + canaryBearer = "Bearer abcdefghijklmnop" + canaryURI = "https://admin:changeme@sdwan-manager.example.com/" +) + +// noSecrets fails when any canary or the plain placeholder password +// survives in data. +func noSecrets(t *testing.T, data []byte) { + t.Helper() + for _, c := range []string{canaryBearer, canaryURI, "changeme"} { + if strings.Contains(string(data), c) { + t.Fatalf("secret %q survived redaction in %s", c, data) + } + } +} + +func TestRedactValue(t *testing.T) { + tests := []struct { + name string + in string + want string + }{ + {"sensitive key", `{"password":"changeme","ifname":"ge0/0"}`, `{"ifname":"ge0/0","password":"[REDACTED]"}`}, + {"hyphenated sensitive key", `{"auth-key":"changeme"}`, `{"auth-key":"[REDACTED]"}`}, + {"sd-wan credential key", `{"pre-shared-key":"changeme","community":"changeme"}`, `{"community":"[REDACTED]","pre-shared-key":"[REDACTED]"}`}, + {"nested object", `{"a":{"b":{"secret":"changeme"}}}`, `{"a":{"b":{"secret":"[REDACTED]"}}}`}, + {"object inside array", `{"rows":[{"token":"changeme"},{"x":1}]}`, `{"rows":[{"token":"[REDACTED]"},{"x":1}]}`}, + {"value pattern in string", `{"desc":"` + canaryBearer + `"}`, `{"desc":"[REDACTED]"}`}, + {"value pattern in array", `["` + canaryURI + `","ok"]`, `["[REDACTED]","ok"]`}, + {"sensitive key with object value", `{"credential":{"user":"admin","pass":"changeme"}}`, `{"credential":"[REDACTED]"}`}, + {"empty and null under sensitive key kept", `{"password":"","secret":null}`, `{"password":"","secret":null}`}, + {"numbers kept exact", `{"uptime":1634626320000,"mtu":1500}`, `{"mtu":1500,"uptime":1634626320000}`}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + v, err := decodeRaw(json.RawMessage(tt.in)) + if err != nil { + t.Fatalf("decodeRaw: %v", err) + } + var n int + got, err := json.Marshal(redactValue(v, &n)) + if err != nil { + t.Fatalf("marshal: %v", err) + } + if string(got) != tt.want { + t.Errorf("redactValue = %s, want %s", got, tt.want) + } + }) + } +} + +func TestRawCollector_AttachesRedactedRowsAndCountsOmissions(t *testing.T) { + rc := newRawCollector(true) + r := sdk.Resource{ID: "cisco.catalystsdwanmanager::TEST-1"} + other := sdk.Resource{ID: "cisco.catalystsdwanmanager::TEST-2"} + + rc.attachOne(&r, "raw", json.RawMessage(`{"host-name":"LAB-RTR01","password":"changeme"}`)) + rc.attachList(&r, "interfaces_raw", []json.RawMessage{ + json.RawMessage(`{"ifname":"ge0/0","description":"` + canaryBearer + `"}`), + json.RawMessage(`{not json`), + json.RawMessage(`{"ifname":"` + strings.Repeat("x", maxRawRowBytes) + `"}`), + }) + rc.attachList(&other, "omp_peers_raw", nil) + resources := []sdk.Resource{r, other} + rc.finish(resources) + + data, err := json.Marshal(resources) + if err != nil { + t.Fatal(err) + } + noSecrets(t, data) + + ext := resources[0].Extensions[extensionKey].(map[string]any) + rows, _ := ext["interfaces_raw"].([]any) + if len(rows) != 1 { + t.Fatalf("interfaces_raw rows = %d, want 1 (one unparseable and one oversized withheld)", len(rows)) + } + omitted, _ := ext["raw_omitted"].([]any) + got, _ := json.Marshal(omitted) + want := `[{"count":1,"endpoint":"interfaces_raw","reason":"row-too-large"},{"count":1,"endpoint":"interfaces_raw","reason":"unparseable"}]` + if string(got) != want { + t.Errorf("raw_omitted = %s, want %s", got, want) + } + if resources[1].Extensions != nil { + t.Errorf("resource without raw rows got extensions %v", resources[1].Extensions) + } +} + +func TestRawCollector_TotalLimit(t *testing.T) { + rc := newRawCollector(true) + rc.total = maxRawTotalBytes - 10 + r := sdk.Resource{ID: "cisco.catalystsdwanmanager::TEST-1"} + rc.attachOne(&r, "raw", json.RawMessage(`{"host-name":"LAB-RTR01-LONGER-THAN-TEN"}`)) + rs := []sdk.Resource{r} + rc.finish(rs) + ext := rs[0].Extensions[extensionKey].(map[string]any) + if _, ok := ext["raw"]; ok { + t.Error("row over the total limit was attached") + } + got, _ := json.Marshal(ext["raw_omitted"]) + if !strings.Contains(string(got), rawOmitTotalLimit) { + t.Errorf("raw_omitted = %s, want a %s entry", got, rawOmitTotalLimit) + } +} + +func TestRawCollector_NilIsNoop(t *testing.T) { + var rc *rawCollector = newRawCollector(false) + r := sdk.Resource{ID: "cisco.catalystsdwanmanager::TEST-1"} + rc.attachOne(&r, "raw", json.RawMessage(`{"password":"changeme"}`)) + rc.attachList(&r, "interfaces_raw", []json.RawMessage{json.RawMessage(`{}`)}) + rc.finish([]sdk.Resource{r}) + if r.Extensions != nil { + t.Errorf("disabled collector attached %v", r.Extensions) + } +} + +// TestRedactElements_EveryModeKeepsTheNoSecretInvariant builds the same +// secret-bearing document under each --safe-failure-mode: fail-closed +// must abort, log-and-redact and off must emit no detected value and +// log-and-redact must claim redaction only when it really redacted. +func TestRedactElements_EveryModeKeepsTheNoSecretInvariant(t *testing.T) { + build := func(mode string) ([]byte, error) { + resources := []sdk.Resource{{ + ID: "cisco.catalystsdwanmanager::TEST-1", + Type: "network.router", + Name: "LAB-RTR01", + Description: canaryURI, + Provider: sdk.Provider{Name: providerName, NativeID: "TEST-1"}, + Properties: map[string]any{"notes": []any{canaryBearer}}, + Extensions: map[string]any{extensionKey: map[string]any{"interfaces_raw": []any{map[string]any{"auth-key": "changeme"}}}}, + }} + groups := []sdk.Group{{ID: "group-test", Type: "physical.room", Name: "BRANCH-00", Description: canaryBearer, Members: []string{resources[0].ID}}} + if mode != sdk.FailClosed { + redactElements(resources, nil, groups) + } + ctx := testharness.NewTestContext(t) + ctx.Config.SafeFailureMode = mode + b := sdk.NewDocumentBuilder(ctx).WithGenerator(generatorName, generatorVersion, generatorURL) + for _, r := range resources { + b.AddResource(r) + } + for _, g := range groups { + b.AddGroup(g) + } + doc, err := b.Build() + if err == nil { + err = verifyRedacted(doc, mode) + } + if err != nil { + return nil, err + } + return sdk.MarshalDocument(doc) + } + + if _, err := build(sdk.FailClosed); err == nil { + t.Error("fail-closed: expected Build to abort on the secret-bearing document") + } + for _, mode := range []string{sdk.LogAndRedact, sdk.Off} { + data, err := build(mode) + if err != nil { + t.Fatalf("%s: %v", mode, err) + } + noSecrets(t, data) + if f := sdk.ScanDocument(mustDoc(t, data)); len(f) != 0 { + t.Errorf("%s: document still has findings %v", mode, f) + } + } +} + +// TestVerifyRedacted_RejectsLeftoverFinding proves log-and-redact never +// writes a document with a detected value under a redacted claim, even +// in a field the producer does not redact. +func TestVerifyRedacted_RejectsLeftoverFinding(t *testing.T) { + ctx := testharness.NewTestContext(t) + ctx.Config.SafeFailureMode = sdk.LogAndRedact + b := sdk.NewDocumentBuilder(ctx).WithGenerator(generatorName, generatorVersion, generatorURL) + b.AddResource(sdk.Resource{ + ID: "cisco.catalystsdwanmanager::TEST-1", + Type: "network.router", + Provider: sdk.Provider{Name: providerName, NativeID: canaryBearer}, + }) + doc, err := b.Build() + if err != nil { + t.Fatalf("Build: %v", err) + } + err = verifyRedacted(doc, sdk.LogAndRedact) + if err == nil { + t.Fatal("expected verifyRedacted to reject a leftover finding") + } + if strings.Contains(err.Error(), canaryBearer) { + t.Errorf("error echoes the secret value: %v", err) + } + if verifyRedacted(doc, sdk.Off) != nil || verifyRedacted(doc, sdk.FailClosed) != nil { + t.Error("verifyRedacted must only gate log-and-redact") + } +} + +func mustDoc(t *testing.T, data []byte) *sdk.Document { + t.Helper() + var doc sdk.Document + if err := json.Unmarshal(data, &doc); err != nil { + t.Fatal(err) + } + return &doc +} diff --git a/osiris/network/cisco/vmanage/sites_select.go b/osiris/network/cisco/catalyst-sd-wan-manager/sites_select.go similarity index 82% rename from osiris/network/cisco/vmanage/sites_select.go rename to osiris/network/cisco/catalyst-sd-wan-manager/sites_select.go index b0498a0..47d1caa 100644 --- a/osiris/network/cisco/vmanage/sites_select.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/sites_select.go @@ -1,8 +1,8 @@ // sites_select.go - Site selection for the Cisco Catalyst SD-WAN -// Manager (vManage) OSIRIS JSON producer. +// Manager OSIRIS JSON producer. // -// vManage still has no standalone sites API, site-id is only known -// per-device, from GET /dataservice/device. So site discovery and +// SD-WAN Manager still has no standalone sites API, site-id is only +// known per-device, from GET /dataservice/device. So site discovery and // selection necessarily happen after the device inventory has already // been fetched and grouped by site-id in runExport, not during flag // parsing. @@ -14,22 +14,22 @@ // credential prompt in cisco/run/tty.go, which uses /dev/tty so it // still works when stdin is piped and so the password can be hidden). // -// Deployments can have thousands of sites, so site-name resolution -// (one GetSiteName call per site) is done concurrently with a bounded -// worker pool and progress output rather than a sequential loop when it -// does happen only the interactive picker (which needs every -// discovered site's name to print its table) and a --site value that -// falls back to name matching trigger it. --all deliberately skips -// bulk resolution entirely: each site's name is instead resolved -// individually, lazily, as vmanage.go's export loop reaches that site, -// so the first document starts being written immediately instead of -// waiting on every site's name up front. +// Deployments can have thousands of sites, so site-name resolution (one +// GetSiteName call per site) is done concurrently with a bounded worker +// pool and progress output rather than a sequential loop when it does +// happen only the interactive picker (which needs every discovered +// site's name to print its table) and a --site value that falls back to +// name matching trigger it. --all deliberately skips bulk resolution +// entirely: each site's name is instead resolved individually, lazily, +// as catalystsdwanmanager.go's export loop reaches that site, so the +// first document starts being written immediately instead of waiting on +// every site's name up front. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import ( "bufio" @@ -44,7 +44,7 @@ import ( // siteNameWorkers bounds how many concurrent GetSiteName calls run at // once during bulk resolution (--all / interactive picker). Kept -// conservative since vManage rate-limits concurrent requests +// conservative since SD-WAN Manager rate-limits concurrent requests // client.go's get() retries 429s with backoff, so occasional // throttling at this concurrency degrades to "a bit slower," not // "falls back to site-id." @@ -68,19 +68,19 @@ type siteSummary struct { // // It also returns a site-id -> name map for whichever sites it already // had to resolve names for as part of selection. --all deliberately -// does not bulk-resolve names unlike the interactive picker, it has -// no table to print them into, so pre-resolving every site's name -// before the export loop even starts would only delay the first -// document being written, for no benefit (each site's name still gets -// resolved individually via vmanage.go's fallback once its own turn in -// the export loop comes up). A --site list that matches entirely by +// does not bulk-resolve names unlike the interactive picker, it has no +// table to print them into, so pre-resolving every site's name before +// the export loop even starts would only delay the first document being +// written, for no benefit (each site's name still gets resolved +// individually via catalystsdwanmanager.go's fallback once its own turn +// in the export loop comes up). A --site list that matches entirely by // raw site-id also returns a nil map for the same reason - a --site // list that needed name matching already has every name resolved -// though, so that map is returned instead of resolving the same sites -// a second time. client and logger are only used when name resolution +// though, so that map is returned instead of resolving the same sites a +// second time. client and logger are only used when name resolution // actually happens - both may be nil for --all or a --site list that // matches entirely by raw site-id. -func resolveSiteSelection(cfg *Config, groups map[string][]Device, client *Client, logger *slog.Logger) ([]string, map[string]string, error) { +func resolveSiteSelection(cfg *Config, groups map[string][]Device, client siteNamer, logger *slog.Logger) ([]string, map[string]string, error) { summaries := siteSummaries(groups) if cfg.AllSites { @@ -96,7 +96,7 @@ func resolveSiteSelection(cfg *Config, groups map[string][]Device, client *Clien // resolveSiteFilter matches --site's requested values against the // discovered sites. Each value may be the raw numeric site-id (as -// vManage reports it) or the resolved display name (what the +// SD-WAN Manager reports it) or the resolved display name (what the // interactive picker, OutputPath's directory segment and // metadata.scope.sites all actually show). // @@ -104,10 +104,10 @@ func resolveSiteSelection(cfg *Config, groups map[string][]Device, client *Clien // once at least one requested value fails to match a raw id does this // fall back to resolving every discovered site's name (via the same // bounded, rate-limited resolver --all and the interactive picker -// already use) and matching case-insensitively against those there -// is no vManage endpoint to look up a site-id by name directly, so +// already use) and matching case-insensitively against those there is +// no SD-WAN Manager endpoint to look up a site-id by name directly, so // finding one requires having resolved all of them. -func resolveSiteFilter(cfg *Config, groups map[string][]Device, summaries []siteSummary, client *Client, logger *slog.Logger) ([]string, map[string]string, error) { +func resolveSiteFilter(cfg *Config, groups map[string][]Device, summaries []siteSummary, client siteNamer, logger *slog.Logger) ([]string, map[string]string, error) { normalized := make([]string, len(cfg.SiteFilter)) allMatchByID := true for i, s := range cfg.SiteFilter { @@ -157,7 +157,7 @@ func resolveSiteFilter(cfg *Config, groups map[string][]Device, summaries []site // For resolving many sites at once, use resolveSiteNamesConcurrently // instead a sequential loop over hundreds/thousands of sites is too // slow to be usable. -func siteDisplayName(client *Client, siteID string, logger *slog.Logger) string { +func siteDisplayName(client siteNamer, siteID string, logger *slog.Logger) string { if siteID == "" { return unsitedSegment } @@ -187,7 +187,7 @@ func siteDisplayName(client *Client, siteID string, logger *slog.Logger) string // sites. Mutates summaries[i].name in place and also returns a // site-id -> name map for reuse by the caller (see // resolveSiteSelection's doc comment). -func resolveSiteNamesConcurrently(client *Client, summaries []siteSummary, logger *slog.Logger) map[string]string { +func resolveSiteNamesConcurrently(client siteNamer, summaries []siteSummary, logger *slog.Logger) map[string]string { total := len(summaries) names := make(map[string]string, total) if total == 0 { @@ -268,14 +268,14 @@ func siteIDs(summaries []siteSummary) []string { // The table shows No/Site name/Devices not the raw site-id, which // stays purely internal (selection is always by row number, never by // name or id text). -func selectSitesInteractive(summaries []siteSummary, client *Client, logger *slog.Logger) ([]string, map[string]string, error) { +func selectSitesInteractive(summaries []siteSummary, client siteNamer, logger *slog.Logger) ([]string, map[string]string, error) { if len(summaries) == 0 { return nil, nil, fmt.Errorf("no devices returned by the controller, nothing to select") } names := resolveSiteNamesConcurrently(client, summaries, logger) - fmt.Fprintf(os.Stderr, "\nSites discovered on this vManage controller:\n\n") + fmt.Fprintf(os.Stderr, "\nSites discovered on this Catalyst SD-WAN Manager controller:\n\n") maxName := len("Site name") for _, s := range summaries { @@ -285,7 +285,7 @@ func selectSitesInteractive(summaries []siteSummary, client *Client, logger *slo } noW := 4 - fmt.Fprintf(os.Stderr, "%-*s %-*s %s\n", noW, "No", maxName, "Site name", "Devices") + fmt.Fprintf(os.Stderr, "%-*s %-*s %s\n", noW, "ID", maxName, "Site name", "Number of devices") fmt.Fprintf(os.Stderr, "%-*s %-*s %s\n", noW, strings.Repeat("-", noW), maxName, strings.Repeat("-", maxName), strings.Repeat("-", 7)) for i, s := range summaries { fmt.Fprintf(os.Stderr, "%-*d %-*s %d\n", noW, i+1, maxName, s.name, s.count) diff --git a/osiris/network/cisco/vmanage/sites_select_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/sites_select_test.go similarity index 96% rename from osiris/network/cisco/vmanage/sites_select_test.go rename to osiris/network/cisco/catalyst-sd-wan-manager/sites_select_test.go index 97c0607..16d00fb 100644 --- a/osiris/network/cisco/vmanage/sites_select_test.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/sites_select_test.go @@ -1,11 +1,11 @@ // sites_select_test.go - Tests for site-id discovery, --site/--all // resolution, and the interactive picker's selection-string parsing. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import ( "fmt" @@ -46,9 +46,9 @@ func TestResolveSiteSelection_All(t *testing.T) { } // --all deliberately does not bulk-resolve names up front each // site's name is resolved individually, lazily, once the export - // loop reaches it (vmanage.go's fallback), so the first document - // starts being written immediately instead of waiting on every - // site's name first. + // loop reaches it (catalystsdwanmanager.go's fallback), so the + // first document starts being written immediately instead of + // waiting on every site's name first. if names != nil { t.Errorf("expected a nil names map (no bulk resolution for --all), got %v", names) } diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/transform.go b/osiris/network/cisco/catalyst-sd-wan-manager/transform.go new file mode 100644 index 0000000..b108045 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/transform.go @@ -0,0 +1,390 @@ +// transform.go - Pure SD-WAN Manager->OSIRIS JSON mapping functions. +// Converts Device records (from GET /dataservice/device) into OSIRIS +// SDK resource types. All functions are stateless: no I/O, no HTTP, +// just data transformation. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification + +package catalystsdwanmanager + +import ( + "maps" + "sort" + "strconv" + "strings" + "time" + + "go.osirisjson.org/producers/pkg/sdk" +) + +// providerName identifies this producer's product line within the +// Cisco vendor namespace (dotted form). +const providerName = "cisco.catalystsdwanmanager" + +// extensionKey namespaces every SD-WAN Manager-specific field placed +// under a resource or connection's extensions block (chapter 8 of +// OSIRIS JSON specification: vendor-specific data MUST use the +// osiris. prefix convention). +const extensionKey = "osiris.cisco.catalystsdwanmanager" + +// Device personality values as the Manager API reports them. They +// keep the component names from before the Catalyst rebranding and +// must match the API exactly, so they are not renamed. The same API +// values pass through unchanged into provider.type and +// properties.model (from device-model). +const ( + personalityManager = "vmanage" // Catalyst SD-WAN Manager + personalityController = "vsmart" // Catalyst SD-WAN Controller + personalityValidator = "vbond" // Catalyst SD-WAN Validator + personalityVEdge = "vedge" // WAN edge (vEdge platform) + personalityCEdge = "cedge" // WAN edge (IOS-XE platform) +) + +// personalityToType maps SD-WAN Manager device personalities to +// OSIRIS JSON resource types. +// +// OSIRIS JSON v1.0 Appendix C.2 has still no core controller type, so +// the three control-plane components use the namespaced +// "osiris.cisco.controller"; WAN edges use the core network.router. +// Unknown personalities are skipped until mapped. +var personalityToType = map[string]string{ + personalityManager: "osiris.cisco.controller", + personalityController: "osiris.cisco.controller", + personalityValidator: "osiris.cisco.controller", + personalityVEdge: "network.router", + personalityCEdge: "network.router", +} + +// TransformDevices converts SD-WAN Manager Device records into OSIRIS +// resources. purpose is "documentation" (default) or "audit" per +// pkg/osirismeta audit adds fields that are stable but higher detail +// (serial_number, certificate validity); purpose.go then applies the +// documentation allowlist. Geo-coordinates are not set here: SD-WAN +// Manager reports the same latitude/longitude for every device at a +// site, so they belong on the site group (see TransformSiteGroup). +// health/state_description/connected_manager/last_update/up_since are +// emitted here for both purposes; purpose.go keeps only health (and +// site_id) in documentation. +// +// Devices whose personality is not in personalityToType are skipped, +// following apic's nodeRoleToType precedent for unrecognized roles. +// +// id/provider.native_id use deviceNativeKey the hardware serial for +// network.router devices, unconditionally (identity fields are never +// purpose-gated), matching OSIRIS-JSON-v1.0 section 4.1.5 own +// on-premise-network-device example. +// +// provider.site (the raw site-id) and provider.system (the Manager the +// device was collected from) are set by the document stage (see +// setProvenance in document.go), which knows the run's Manager. +// +// Returns the resources plus a system-ip -> resource ID index, used by +// the caller to wire interfaces (transform_interfaces.go) and +// same-document connections (transform_connections.go) back to their +// owning device. +func TransformDevices(devices []Device, purpose string) ([]sdk.Resource, map[string]string) { + var resources []sdk.Resource + systemIPToID := make(map[string]string, len(devices)) + + for _, d := range devices { + resType, ok := personalityToType[d.Personality] + if !ok { + continue + } + + key := deviceNativeKey(d, resType) + if key == "" { + continue // no native identity: never emit an empty ID (see unidentifiedDevices). + } + id := resourceID(key) + + prov := sdk.Provider{ + Name: providerName, + NativeID: key, + Type: d.DeviceModel, + } + + r, err := sdk.NewResource(id, resType, prov) + if err != nil { + continue + } + r.Name = d.HostName + r.Status = mapDeviceStatus(d.Status, d.Reachability) + if d.Reachability != "" { + r.State = d.Reachability + } + + // manufacturer/model/version match OSIRIS JSON v1.0 + // specification 7.5.2 network.router "Common properties" table; + // manufacturer is a constant since SD-WAN Manager only manages + // Cisco/Viptela hardware. The system IP is the device's SD-WAN + // overlay identifier, not a proven management address, so it is + // kept as extension system_ip rather than management_ip. + props := map[string]any{"manufacturer": "Cisco"} + if d.DeviceModel != "" { + props["model"] = d.DeviceModel + } + if d.Version != "" { + props["version"] = d.Version + } + if purpose == "audit" { + if d.BoardSerial != "" { + props["serial_number"] = d.BoardSerial + } + } + r.Properties = props + + ext := map[string]any{} + if d.SiteID != "" { + ext["site_id"] = d.SiteID + } + if ip := sdk.NormalizeIP(d.SystemIP); ip != "" { + ext["system_ip"] = ip + } + if len(d.DeviceGroups) > 0 { + ext["device_groups"] = sortedCopy(d.DeviceGroups) + } + if resType == "network.router" && d.BoardSerial != "" && d.UUID != "" { + ext["chassis_number"] = d.UUID + } + if d.HealthState != "" { + ext["health"] = d.HealthState + } + if d.StateDescription != "" { + ext["state_description"] = d.StateDescription + } + if len(d.ConnectedManagers) > 0 { + ext["connected_manager"] = sortedCopy(d.ConnectedManagers) + } + if lastUpdate := epochMillisToRFC3339(int64(d.LastUpdated)); lastUpdate != "" { + ext["last_update"] = lastUpdate + } + if upSince := epochMillisToRFC3339(int64(d.UptimeDate)); upSince != "" { + ext["up_since"] = upSince + } + if purpose == "audit" { + if d.CertificateValidity != "" { + ext["certificate_validity"] = d.CertificateValidity + } + } + if len(ext) > 0 { + r.Extensions = map[string]any{extensionKey: ext} + } + + resources = append(resources, r) + if d.SystemIP != "" { + systemIPToID[d.SystemIP] = id + } + } + + return resources, systemIPToID +} + +// GroupDevicesBySiteID partitions devices by their site-id, for the +// per-site document split in catalystsdwanmanager.go. Devices with no +// site-id are grouped under the "" key (see unsitedSegment in +// config.go). +func GroupDevicesBySiteID(devices []Device) map[string][]Device { + groups := make(map[string][]Device) + for _, d := range devices { + groups[d.SiteID] = append(groups[d.SiteID], d) + } + return groups +} + +// TransformSiteGroup builds the "logical.site" group of one site's +// document. Its members are the site's own resources, devices and +// their interfaces, listed explicitly (OSIRIS JSON section 6.3); a +// neighbor device of another site that only appears to keep a +// cross-site relationship valid is never a member. +// +// logical.site, not physical.room: an SD-WAN site is the Manager's +// logical grouping of devices by site-id, and the API carries no +// evidence of a room, building or rack. logical.site is the type the +// specification's own section 6.3.2 example uses. The unsited bucket +// (devices with no site-id) is a logical.site named unsitedSegment and +// marked unsited, an operational grouping rather than a place. +// +// The group's ID is derived from the raw site-id (unsitedSegment for +// the unsited bucket), never from the display name, so a renamed site +// keeps its group ID. The raw site-id is also kept as extension +// site_id. properties.geo_location takes the first parsable device +// coordinate pair; it is audit-only (see purpose.go). ok is false when +// there is nothing to group. +func TransformSiteGroup(siteID, siteName string, devices []Device, memberIDs []string) (group sdk.Group, ok bool) { + if len(memberIDs) == 0 { + return sdk.Group{}, false + } + + boundaryToken := siteID + if boundaryToken == "" { + boundaryToken = unsitedSegment + } + gid := sdk.GroupID(sdk.GroupIDInput{Type: "logical.site", BoundaryToken: boundaryToken}) + + g, err := sdk.NewGroup(gid, "logical.site") + if err != nil { + return sdk.Group{}, false + } + g.Name = siteName + if g.Name == "" { + g.Name = unsitedSegment + } + g.AddMembers(memberIDs...) + if siteID != "" { + g.Extensions = map[string]any{extensionKey: map[string]any{"site_id": siteID}} + } else { + g.Extensions = map[string]any{extensionKey: map[string]any{"unsited": true}} + } + + for _, d := range devices { + lat, latOK := toFloat(d.Latitude) + lon, lonOK := toFloat(d.Longitude) + if latOK && lonOK && lat >= -90 && lat <= 90 && lon >= -180 && lon <= 180 { + g.Properties = map[string]any{ + "geo_location": map[string]any{ + "latitude": lat, + "longitude": lon, + }, + } + break + } + } + + return g, true +} + +// sortedCopy returns a sorted copy of an unordered API string list, so +// output does not depend on API order. +func sortedCopy(in []string) []string { + out := append([]string(nil), in...) + sort.Strings(out) + return out +} + +// mapDeviceStatus converts SD-WAN Manager status/reachability into an +// OSIRIS status enum value following OSIRIS JSON section 6.1.3 status +// field (active, inactive, degraded, retired, unknown). SD-WAN Manager +// own status enum is {error, warning, normal, new}; this is a +// first pass, pending validation against a wider range of devices. +func mapDeviceStatus(status, reachability string) string { + if reachability == "unreachable" { + return "inactive" + } + switch status { + case "normal": + return "active" + case "error", "warning": + return "degraded" + case "new": + return "unknown" + default: + return "unknown" + } +} + +// epochMillisToRFC3339 converts an SD-WAN Manager epoch-milliseconds +// timestamp (e.g. "lastupdated", "uptime-date") to an RFC3339 UTC +// string, or "" for an unset (zero/negative) value. +func epochMillisToRFC3339(ms int64) string { + if ms <= 0 { + return "" + } + return sdk.NormalizeRFC3339UTC(time.UnixMilli(ms)) +} + +// toFloat converts a decoded JSON value (string or float64) to a +// float64, handling the spec's own documented example mixing a string +// latitude with a numeric longitude for the same device object. +func toFloat(v any) (float64, bool) { + switch n := v.(type) { + case float64: + return n, true + case string: + f, err := strconv.ParseFloat(n, 64) + if err != nil { + return 0, false + } + return f, true + default: + return 0, false + } +} + +// deviceNativeKey picks the native-ID key for a device resource: +// board-serial for network.router devices, when available a real +// hardware serial, unlike "uuid", which SD-WAN Manager does not +// populate as an actual UUID for vEdge/cEdge platforms but as a +// "-" string instead (e.g. +// "C8200L-1N-4T-TST0000001"). That string is kept under +// extensions.chassis_number instead (see TransformDevices) rather than +// used as the resource identity. Falls back to uuid, then deviceId, +// when no serial is available the fallback path the Manager, +// Controller and Validator personalities always take, since the +// serial substitution only applies to resType == "network.router". +func deviceNativeKey(d Device, resType string) string { + if resType == "network.router" && d.BoardSerial != "" { + return d.BoardSerial + } + if d.UUID != "" { + return d.UUID + } + return d.DeviceID +} + +// setExtension merges a single key into a resource's +// extensions[osiris.cisco.catalystsdwanmanager] map, preserving +// whatever else is already there (e.g. TransformDevices own +// site_id/health fields) instead of replacing it used by the +// --include-raw-body attachment in catalystsdwanmanager.go (see +// wantRawBody) so raw-body keys never clobber fields a transform +// function already set, regardless of call order. +func setExtension(r *sdk.Resource, key string, value any) { + if r.Extensions == nil { + r.Extensions = map[string]any{} + } + ext, _ := r.Extensions[extensionKey].(map[string]any) + merged := make(map[string]any, len(ext)+1) + maps.Copy(merged, ext) + merged[key] = value + r.Extensions[extensionKey] = merged +} + +// resourceID builds a namespaced native-ID resource identifier +// OSIRIS-JSON-v1.0 section 2.1.2, strategy 2: "Namespaced native +// ID ::"), preferred here over a deterministic hash since +// SD-WAN Manager devices and interfaces always carry a stable native +// identifier (device serial/uuid/deviceId, see deviceNativeKey, or a +// device-key + interface-name composite for sub-resources see +// resourceKey). +func resourceID(nativeID string) string { + return providerName + "::" + nativeID +} + +// resourceKey builds the composite native ID for a device sub-resource. +func resourceKey(deviceKey, name string) string { + return deviceKey + "-" + name +} + +// stripCIDRHost returns the host portion of a CIDR-form address +// ("192.0.2.20/24" -> "192.0.2.20"), normalized via sdk.NormalizeIP. +// SD-WAN Manager's /dataservice/device/interface response encodes +// ip-address as host/prefix; returns "" for empty, "-" or "0.0.0.0" +// (both observed in responses as SD-WAN Manager's own placeholders for +// "no address configured" on an interface not a real address, and not +// private just because it fails an RFC 1918 check) or unparseable +// input. +func stripCIDRHost(s string) string { + if s == "" || s == "-" || s == "0.0.0.0" { + return "" + } + if idx := strings.IndexByte(s, '/'); idx >= 0 { + s = s[:idx] + } + if s == "0.0.0.0" { + return "" + } + return sdk.NormalizeIP(s) +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/transform_connections.go b/osiris/network/cisco/catalyst-sd-wan-manager/transform_connections.go new file mode 100644 index 0000000..168ed7b --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/transform_connections.go @@ -0,0 +1,250 @@ +// transform_connections.go - SD-WAN tunnel and OMP control-plane +// peering connection transforms. +// +// OSIRIS JSON section 2.2.3 requires a connection's source and target +// to resolve within the same document. The document stage +// (document.go, neighbors.go) resolves every endpoint against the whole +// controller inventory and adds a remote endpoint from another site as +// a neighbor resource, so a cross-site relationship stays in each site +// document that takes part in it. The functions here only build +// connections from already resolved endpoints. +// +// Both kinds of connection are bidirectional and emitted with their +// endpoints in canonical (sorted) order, so the same relationship has +// the same connection ID, source and target in every site document +// that carries it and an OSIRIS JSON Consumer merging documents can +// deduplicate it by ID. Nothing here depends on API row order. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification +package catalystsdwanmanager + +import ( + "regexp" + "sort" + "strings" + + "go.osirisjson.org/producers/pkg/sdk" +) + +// tunnelNameRe parses a site topology tunnel name of the form +// "{system-ip}:{color}-{system-ip}:{color}". Colors are matched +// non-greedily since real SD-WAN Manager color names commonly contain +// hyphens (e.g. "biz-internet", "public-internet"). Only IPv4 system +// IPs are recognized; any other name is left unresolved rather than +// guessed. +var tunnelNameRe = regexp.MustCompile(`^(\d{1,3}(?:\.\d{1,3}){3}):([a-z0-9-]+?)-(\d{1,3}(?:\.\d{1,3}){3}):([a-z0-9-]+)$`) + +// parseTunnelEndpoints splits a tunnel name into its two +// "{system-ip}:{color}" endpoint keys. +func parseTunnelEndpoints(name string) (keyA, keyB string, ok bool) { + m := tunnelNameRe.FindStringSubmatch(name) + if m == nil { + return "", "", false + } + return m[1] + ":" + m[2], m[3] + ":" + m[4], true +} + +// splitTunnelKey splits "{system-ip}:{color}" into its parts. +func splitTunnelKey(key string) (systemIP, color string) { + i := strings.IndexByte(key, ':') + if i < 0 { + return key, "" + } + return key[:i], key[i+1:] +} + +// canonicalPair orders two endpoint IDs for a bidirectional connection. +func canonicalPair(a, b string) (string, string) { + if a > b { + return b, a + } + return a, b +} + +// tunnelObservation is one resolved tunnel between two interface +// resources. +type tunnelObservation struct { + a, b string // interface resource IDs. + color, state string + vqoe float64 + hasVQoE bool +} + +// tunnelStats counts tunnel entries that did not become connections. +type tunnelStats struct { + unparsed int // name not in the documented form. + unresolved int // an endpoint could not be resolved unambiguously. +} + +// TransformTunnels builds one "network.vpn" connection per distinct +// interface pair from the site topology monitor entries. resolve maps +// a "{system-ip}:{color}" key to an interface resource ID; ok is false +// for an unknown or ambiguous endpoint. A pair observed several times +// (both ends report it) becomes one connection; differing observed +// states are kept in observed_states instead of letting row order +// decide. +func TransformTunnels(devices []SiteTopologyDevice, resolve func(key string) (string, bool)) ([]sdk.Connection, tunnelStats) { + var stats tunnelStats + byPair := map[[2]string][]tunnelObservation{} + for _, dev := range devices { + for _, circuit := range dev.Circuits { + for _, tunnel := range circuit.Tunnels { + keyA, keyB, ok := parseTunnelEndpoints(tunnel.Name) + if !ok { + stats.unparsed++ + continue + } + a, okA := resolve(keyA) + b, okB := resolve(keyB) + if !okA || !okB || a == b { + stats.unresolved++ + continue + } + a, b = canonicalPair(a, b) + o := tunnelObservation{ + a: a, b: b, color: circuit.Color, state: strings.ToLower(tunnel.State), + } + if tunnel.VqoeScore != nil { + o.vqoe, o.hasVQoE = *tunnel.VqoeScore, true + } + byPair[[2]string{a, b}] = append(byPair[[2]string{a, b}], o) + } + } + } + + pairs := make([][2]string, 0, len(byPair)) + for p := range byPair { + pairs = append(pairs, p) + } + sort.Slice(pairs, func(i, j int) bool { return pairs[i][0]+"\x00"+pairs[i][1] < pairs[j][0]+"\x00"+pairs[j][1] }) + + connections := make([]sdk.Connection, 0, len(pairs)) + for _, p := range pairs { + obs := byPair[p] + key := sdk.ConnectionCanonicalKey(sdk.ConnectionIDInput{ + Type: "network.vpn", Direction: "bidirectional", Source: p[0], Target: p[1], + }) + conn, err := sdk.NewConnection(sdk.BuildConnectionID(key, 16), "network.vpn", p[0], p[1]) + if err != nil { + continue + } + _ = conn.SetDirection("bidirectional") + conn.Name = "SD-WAN Site-to-Site Tunnel" + + states := map[string]bool{} + colors := map[string]bool{} + minVQoE, hasVQoE := 0.0, false + for _, o := range obs { + if o.state != "" { + states[o.state] = true + } + if o.color != "" { + colors[o.color] = true + } + if o.hasVQoE && (!hasVQoE || o.vqoe < minVQoE) { + minVQoE, hasVQoE = o.vqoe, true + } + } + ext := map[string]any{} + applyObservedState(&conn, sortedKeys(states), ext) + if c := sortedKeys(colors); len(c) == 1 { + ext["color"] = c[0] + } else if len(c) > 1 { + ext["colors"] = c + } + if hasVQoE { + ext["vqoe_score"] = minVQoE + } + conn.Extensions = map[string]any{extensionKey: ext} + connections = append(connections, conn) + } + return connections, stats +} + +// ompObservation is one observed OMP session between two resolved +// device resources, from source "omp_links" or "omp_peers". +type ompObservation struct { + a, b string + state string + source string +} + +// TransformOMP builds one bidirectional "network" connection with +// protocol "omp" per device pair from every observation of that pair, +// whichever API reported it and from whichever end. The connection ID +// is qualified by the protocol, so it cannot collide with another +// "network" relationship between the same devices. sources lists which +// operations reported the session; differing observed states are kept +// in observed_states. +func TransformOMP(observations []ompObservation) []sdk.Connection { + byPair := map[[2]string][]ompObservation{} + for _, o := range observations { + if o.a == "" || o.b == "" || o.a == o.b { + continue + } + a, b := canonicalPair(o.a, o.b) + byPair[[2]string{a, b}] = append(byPair[[2]string{a, b}], o) + } + pairs := make([][2]string, 0, len(byPair)) + for p := range byPair { + pairs = append(pairs, p) + } + sort.Slice(pairs, func(i, j int) bool { return pairs[i][0]+"\x00"+pairs[i][1] < pairs[j][0]+"\x00"+pairs[j][1] }) + + connections := make([]sdk.Connection, 0, len(pairs)) + for _, p := range pairs { + key := sdk.ConnectionCanonicalKey(sdk.ConnectionIDInput{ + Type: "network", Direction: "bidirectional", Source: p[0], Target: p[1], + Qualifiers: map[string]string{"protocol": "omp"}, + }) + conn, err := sdk.NewConnection(sdk.BuildConnectionID(key, 16), "network", p[0], p[1]) + if err != nil { + continue + } + _ = conn.SetDirection("bidirectional") + conn.Name = "OMP Peering" + + states := map[string]bool{} + sources := map[string]bool{} + for _, o := range byPair[p] { + if o.state != "" { + states[strings.ToLower(o.state)] = true + } + sources[o.source] = true + } + ext := map[string]any{"protocol": "omp", "sources": sortedKeys(sources)} + applyObservedState(&conn, sortedKeys(states), ext) + conn.Extensions = map[string]any{extensionKey: ext} + connections = append(connections, conn) + } + return connections +} + +// applyObservedState sets a connection's state and status from its +// observed states: a single state is used as is; disagreeing +// observations leave the status unknown and are listed in +// observed_states. +func applyObservedState(conn *sdk.Connection, states []string, ext map[string]any) { + switch len(states) { + case 0: + conn.Status = mapUpDownStatus("") + case 1: + conn.State = states[0] + conn.Status = mapUpDownStatus(states[0]) + default: + conn.Status = mapUpDownStatus("") + ext["observed_states"] = states + } +} + +// sortedKeys returns the keys of a string set in sorted order. +func sortedKeys(m map[string]bool) []string { + out := make([]string, 0, len(m)) + for k := range m { + out = append(out, k) + } + sort.Strings(out) + return out +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/transform_connections_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/transform_connections_test.go new file mode 100644 index 0000000..b7fb390 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/transform_connections_test.go @@ -0,0 +1,155 @@ +// transform_connections_test.go - Unit tests for tunnel and OMP peering +// connection mapping: canonical endpoint order, protocol-qualified OMP +// identity, merged observations and row-order independence. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification + +package catalystsdwanmanager + +import ( + "math/rand" + "reflect" + "testing" + + "go.osirisjson.org/producers/pkg/sdk" +) + +func TestParseTunnelEndpoints(t *testing.T) { + cases := []struct { + name string + wantA, wantB string + wantOK bool + }{ + {"198.51.100.1:lte-198.51.100.2:lte", "198.51.100.1:lte", "198.51.100.2:lte", true}, + {"203.0.113.1:biz-internet-203.0.113.2:public-internet", "203.0.113.1:biz-internet", "203.0.113.2:public-internet", true}, + {"not-a-valid-tunnel-name", "", "", false}, + {"2001:db8::1:lte-2001:db8::2:lte", "", "", false}, + } + for _, c := range cases { + gotA, gotB, ok := parseTunnelEndpoints(c.name) + if ok != c.wantOK { + t.Errorf("parseTunnelEndpoints(%q) ok = %v, want %v", c.name, ok, c.wantOK) + continue + } + if ok && (gotA != c.wantA || gotB != c.wantB) { + t.Errorf("parseTunnelEndpoints(%q) = (%q, %q), want (%q, %q)", c.name, gotA, gotB, c.wantA, c.wantB) + } + } +} + +func score(v float64) *float64 { return &v } + +// tunnelResolver resolves keys from a fixed map. +func tunnelResolver(m map[string]string) func(string) (string, bool) { + return func(k string) (string, bool) { + id, ok := m[k] + return id, ok && id != "" + } +} + +func TestTransformTunnels_CanonicalAndMerged(t *testing.T) { + idx := map[string]string{ + "198.51.100.1:lte": "cisco.catalystsdwanmanager::TST0000001-ge0/1", + "198.51.100.2:lte": "cisco.catalystsdwanmanager::TST0000002-ge0/1", + } + // Both ends report the tunnel, in opposite directions, with + // different states; one reports a zero quality score. + devices := []SiteTopologyDevice{ + {Circuits: []SiteCircuit{{Color: "lte", Tunnels: []SiteTunnel{{Name: "198.51.100.2:lte-198.51.100.1:lte", State: "Up", VqoeScore: score(0)}}}}}, + {Circuits: []SiteCircuit{{Color: "lte", Tunnels: []SiteTunnel{{Name: "198.51.100.1:lte-198.51.100.2:lte", State: "Down"}}}}}, + } + conns, stats := TransformTunnels(devices, tunnelResolver(idx)) + if len(conns) != 1 || stats != (tunnelStats{}) { + t.Fatalf("got %d connections, stats %+v; want 1, none skipped", len(conns), stats) + } + c := conns[0] + if c.Source > c.Target || c.Direction != "bidirectional" { + t.Errorf("endpoints not canonical: %s -> %s (%s)", c.Source, c.Target, c.Direction) + } + ext := c.Extensions[extensionKey].(map[string]any) + if !reflect.DeepEqual(ext["observed_states"], []string{"down", "up"}) || c.State != "" { + t.Errorf("conflicting states = %v / %q, want observed_states [down up] and no state", ext["observed_states"], c.State) + } + if ext["vqoe_score"] != 0.0 { + t.Errorf("a real zero quality score must be kept, got %v", ext["vqoe_score"]) + } +} + +func TestTransformTunnels_UnresolvedAndUnparsedAreCounted(t *testing.T) { + idx := map[string]string{"198.51.100.1:lte": "cisco.catalystsdwanmanager::TST0000001-ge0/1", "198.51.100.3:lte": ""} + devices := []SiteTopologyDevice{{Circuits: []SiteCircuit{{Tunnels: []SiteTunnel{ + {Name: "198.51.100.1:lte-198.51.100.2:lte"}, // unknown peer. + {Name: "198.51.100.1:lte-198.51.100.3:lte"}, // ambiguous peer. + {Name: "garbage"}, + }}}}} + conns, stats := TransformTunnels(devices, tunnelResolver(idx)) + if len(conns) != 0 || stats.unresolved != 2 || stats.unparsed != 1 { + t.Errorf("conns=%d stats=%+v, want 0 and {unparsed:1 unresolved:2}", len(conns), stats) + } +} + +func TestTransformOMP_OneConnectionPerPairAcrossSources(t *testing.T) { + a, b := "cisco.catalystsdwanmanager::TST0000002", "cisco.catalystsdwanmanager::CTRL-0001" + conns := TransformOMP([]ompObservation{ + {a: a, b: b, state: "up", source: opOMPLinks}, + {a: b, b: a, state: "up", source: opOMPPeers}, + {a: a, b: a, state: "up", source: opOMPPeers}, // self, ignored. + }) + if len(conns) != 1 { + t.Fatalf("got %d connections, want 1", len(conns)) + } + c := conns[0] + if c.Source != b || c.Target != a || c.Direction != "bidirectional" || c.State != "up" { + t.Errorf("connection = %s -> %s %s %s", c.Source, c.Target, c.Direction, c.State) + } + ext := c.Extensions[extensionKey].(map[string]any) + if ext["protocol"] != "omp" || !reflect.DeepEqual(ext["sources"], []string{opOMPLinks, opOMPPeers}) { + t.Errorf("ext = %v", ext) + } + // The protocol qualifier keeps OMP distinct from any other + // "network" relationship between the same devices. + plain := sdk.BuildConnectionID(sdk.ConnectionCanonicalKey(sdk.ConnectionIDInput{Type: "network", Direction: "bidirectional", Source: b, Target: a}), 16) + if c.ID == plain { + t.Error("OMP connection ID is not protocol-qualified") + } +} + +// TestTransforms_RowOrderIndependent shuffles the input 100 times and +// requires byte-identical connections. +func TestTransforms_RowOrderIndependent(t *testing.T) { + ids := []string{"cisco.catalystsdwanmanager::A", "cisco.catalystsdwanmanager::B", "cisco.catalystsdwanmanager::C"} + var obs []ompObservation + for i, x := range ids { + for _, y := range ids[i+1:] { + obs = append(obs, ompObservation{a: x, b: y, state: "up", source: opOMPLinks}, ompObservation{a: y, b: x, state: "down", source: opOMPPeers}) + } + } + idx := map[string]string{"198.51.100.1:lte": ids[0], "198.51.100.2:lte": ids[1], "198.51.100.3:mpls": ids[2], "198.51.100.1:mpls": ids[0] + "-m"} + var tunnels []SiteTunnel + for _, n := range []string{"198.51.100.1:lte-198.51.100.2:lte", "198.51.100.2:lte-198.51.100.1:lte", "198.51.100.3:mpls-198.51.100.1:mpls"} { + tunnels = append(tunnels, SiteTunnel{Name: n, State: "up", VqoeScore: score(7)}) + } + + marshal := func(o []ompObservation, ts []SiteTunnel) string { + tc, _ := TransformTunnels([]SiteTopologyDevice{{Circuits: []SiteCircuit{{Color: "lte", Tunnels: ts}}}}, tunnelResolver(idx)) + doc := &sdk.Document{Topology: sdk.Topology{Connections: append(TransformOMP(o), tc...)}} + b, err := sdk.MarshalDocument(doc) + if err != nil { + t.Fatal(err) + } + return string(b) + } + want := marshal(obs, tunnels) + r := rand.New(rand.NewSource(1)) + for i := 0; i < 100; i++ { + o := append([]ompObservation(nil), obs...) + ts := append([]SiteTunnel(nil), tunnels...) + r.Shuffle(len(o), func(i, j int) { o[i], o[j] = o[j], o[i] }) + r.Shuffle(len(ts), func(i, j int) { ts[i], ts[j] = ts[j], ts[i] }) + if got := marshal(o, ts); got != want { + t.Fatalf("permutation %d changed the output", i) + } + } +} diff --git a/osiris/network/cisco/catalyst-sd-wan-manager/transform_interfaces.go b/osiris/network/cisco/catalyst-sd-wan-manager/transform_interfaces.go new file mode 100644 index 0000000..5504700 --- /dev/null +++ b/osiris/network/cisco/catalyst-sd-wan-manager/transform_interfaces.go @@ -0,0 +1,425 @@ +// transform_interfaces.go - Interface resource and router-to-interface +// "contains" connection transforms. +// +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: +// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco +// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification + +package catalystsdwanmanager + +import ( + "fmt" + "net" + "sort" + "strconv" + "strings" + + "go.osirisjson.org/producers/pkg/sdk" +) + +// TransformInterfaces converts one device's interfaces into OSIRIS +// resources plus "contains" connections wiring each one back to +// deviceResourceID, the router/controller resource it belongs to. +// +// deviceResourceType is the owning device's own OSIRIS JSON type +// (personalityToType's value "network.router" or +// "osiris.cisco.controller"): interfaces belonging to a +// "network.router" become OSIRIS-JSON-v1.0 section 7.5.2's +// "network.router.port" (a router port is specifically a router-owned +// interface per that section's definition). +// +// ifaces is the device's GET /dataservice/device/interface rows +// (mergeInterfaceRows reconciles the per-address-family rows of each +// interface into one, and keeps equal interface names in different +// VPNs apart, see interfaceKey). +// wanIfaces is the device's GET +// /dataservice/device/control/waninterface rows, joined back to ifaces +// by interface name, used to enrich WAN-transport interfaces with a +// public/NAT address and SD-WAN color. +// +// Returns the resources, the "contains" connections, and a +// "{system-ip}:{color}" -> interface resource ID index consumed by +// TransformTunnels (transform_connections.go) to resolve SD-WAN tunnel +// endpoints. A color carried by more than one interface of the device +// maps to "" (ambiguous): a tunnel on it is left unresolved rather than +// attached to an arbitrary interface. +func TransformInterfaces(deviceResourceID, deviceResourceType, deviceNativeKey, systemIP string, ifaces []Interface, wanIfaces []WANInterface) ([]sdk.Resource, []sdk.Connection, map[string]string) { + var resources []sdk.Resource + var connections []sdk.Connection + tunnelIndex := make(map[string]string) + + resType := "network.interface" + if deviceResourceType == "network.router" { + resType = "network.router.port" + } + + wanByIfname := make(map[string]WANInterface, len(wanIfaces)) + for _, w := range wanIfaces { + wanByIfname[w.Interface] = w + } + + for _, m := range mergeInterfaceRows(ifaces) { + iface := m.Interface + nativeID := resourceKey(deviceNativeKey, m.key) + id := resourceID(nativeID) + + prov := sdk.Provider{ + Name: providerName, + NativeID: nativeID, + // The interface's own native identifier (e.g. + // "GigabitEthernet0/0/0") Cisco's interface-class-plus- + // slot/subslot/port naming already doubles as its native + // type within the device, distinct from the generic + // "Router Interface" category string + // OSIRIS-JSON-v1.0 section 7.5.2's own example uses. + Type: iface.IfName, + } + r, err := sdk.NewResource(id, resType, prov) + if err != nil { + continue + } + r.Name = iface.IfName + r.Description = iface.Description + r.Status = mapUpDownStatus(iface.IfOperStatus) + if iface.IfOperStatus != "" { + r.State = strings.ToLower(iface.IfOperStatus) + } + + // Transport (WAN) data joins only the interface that keeps the + // plain interface name: the lowest VPN, which is VPN 0 for a + // transport interface. + wan, isWAN := wanByIfname[iface.IfName] + isWAN = isWAN && m.key == iface.IfName + + // Candidate addresses are classified by what they actually are + // (RFC 1918/4193, via net.IP.IsPrivate) rather than trusted by + // which SD-WAN Manager field they came from GET + // /dataservice/device/control/waninterface's "private-ip"/ + // "public-ip" names mean "before NAT" vs "after NAT", not + // "RFC 1918 private" vs "public": a Direct Internet Access + // circuit with no NAT reports the same real, public + // ISP-assigned address in both fields, which would otherwise + // get mislabeled as private_ip. + var candidates []string + if base := stripCIDRHost(iface.IPAddress); base != "" { + candidates = append(candidates, base) + } + if isWAN { + if wp := sdk.NormalizeIP(wan.PrivateIP); wp != "" { + candidates = append(candidates, wp) + } + if wq := sdk.NormalizeIP(wan.PublicIP); wq != "" { + candidates = append(candidates, wq) + } + } + + ipAddrs := map[string]any{} + var privateIPs []string + var publicIP string + seen := make(map[string]bool, len(candidates)) + for _, ip := range candidates { + if seen[ip] { + continue + } + seen[ip] = true + if isPublicIP(ip) { + publicIP = ip + } else { + privateIPs = append(privateIPs, ip) + } + } + if len(privateIPs) > 0 { + ipAddrs["private_ip"] = privateIPs + } + if publicIP != "" { + ipAddrs["public_ip"] = publicIP + } + + // interface_name/admin_status/oper_status/speed_mbps/duplex/mtu + // match OSIRIS-JSON-v1.0 section 7.5.2 network.router.port + // "Common properties" table (description is set separately, on + // r.Description, per the OSIRIS-JSON-v1.0 section 4.1.3. See + // the field's own doc comment on Interface in client.go). + // vlan_id is still not included: no SD-WAN Manager endpoint + // reports a VLAN tag for a service-side sub-interface emitting + // a placeholder would misrepresent absent data as a real value. + props := map[string]any{"interface_name": iface.IfName} + if len(ipAddrs) > 0 { + props["ip_addresses"] = ipAddrs + } + if mac := sdk.NormalizeMAC(iface.HWAddr); mac != "" { + props["mac_address"] = mac + } + if iface.IfAdminStatus != "" { + props["admin_status"] = strings.ToLower(iface.IfAdminStatus) + } + if iface.IfOperStatus != "" { + props["oper_status"] = strings.ToLower(iface.IfOperStatus) + } + if speed, ok := parseIntField(string(iface.SpeedMbps)); ok { + props["speed_mbps"] = speed + } + if iface.Duplex != "" { + props["duplex"] = iface.Duplex + } + if mtu, ok := parseIntField(string(iface.Mtu)); ok { + props["mtu"] = mtu + } + if iface.EncapType != "" && iface.EncapType != "null" { + props["encapsulation"] = iface.EncapType + } + if it := interfaceType(iface.PortType); it != "" { + props["interface_type"] = it + } + if iface.VPNID != "" { + // SD-WAN Manager's raw response only ever reports "vpn-id" + // never any form of "vrf" so this is surfaced under SD-WAN + // Manager's own native field name: OSIRIS-JSON-v1.0 + // network.router.port Common Properties table does not + // document a vrf_id property either. + props["vpn_id"] = iface.VPNID + } + r.Properties = props + + if isWAN && wan.Color != "" { + ext := map[string]any{"color": wan.Color} + if wan.NatType != "" { + ext["nat_type"] = wan.NatType + } + r.Extensions = map[string]any{extensionKey: ext} + } + + resources = append(resources, r) + + if conn, ok := containsConnection(deviceResourceID, deviceNativeKey, id, iface.IfName); ok { + connections = append(connections, conn) + } + + if isWAN && wan.Color != "" && systemIP != "" { + addTunnelEndpoint(tunnelIndex, systemIP+":"+wan.Color, id) + } + } + + return resources, connections, tunnelIndex +} + +// mergedInterface is one reconciled interface and the key its +// resource ID derives from (see interfaceKey). +type mergedInterface struct { + Interface + key string +} + +// mergeInterfaceRows reconciles GET /dataservice/device/interface rows, +// which arrive one per (interface, address family), into one entry per +// interface. Rows belong to the same interface when they share the +// interface name and the VPN: an equal name in another VPN is another +// interface, never merged. Within one interface the IPv4 row supplies +// the fields and any field it leaves empty (description, MAC address, +// statuses, speed, MTU) is filled from the other rows, so a description +// carried only by the IPv6 row is kept. Rows are ordered by address +// family and address before reconciling, so the result does not depend +// on API row order. Rows without an interface name are skipped. +func mergeInterfaceRows(rows []Interface) []mergedInterface { + type groupKey struct{ vpn, name string } + groups := map[groupKey][]Interface{} + vpnsByName := map[string][]string{} + for _, r := range rows { + if r.IfName == "" { + continue + } + k := groupKey{r.VPNID, r.IfName} + if _, ok := groups[k]; !ok { + vpnsByName[r.IfName] = append(vpnsByName[r.IfName], r.VPNID) + } + groups[k] = append(groups[k], r) + } + + keys := make([]groupKey, 0, len(groups)) + for k := range groups { + keys = append(keys, k) + } + sort.Slice(keys, func(i, j int) bool { + if keys[i].name != keys[j].name { + return keys[i].name < keys[j].name + } + return vpnLess(keys[i].vpn, keys[j].vpn) + }) + + out := make([]mergedInterface, 0, len(keys)) + for _, k := range keys { + rs := groups[k] + sort.SliceStable(rs, func(i, j int) bool { + ai, aj := rs[i].AFType == "ipv4", rs[j].AFType == "ipv4" + if ai != aj { + return ai + } + if rs[i].AFType != rs[j].AFType { + return rs[i].AFType < rs[j].AFType + } + return rs[i].IPAddress < rs[j].IPAddress + }) + m := rs[0] + for _, r := range rs[1:] { + fillEmpty(&m.Description, r.Description) + fillEmpty(&m.HWAddr, r.HWAddr) + fillEmpty(&m.IfAdminStatus, r.IfAdminStatus) + fillEmpty(&m.IfOperStatus, r.IfOperStatus) + fillEmpty(&m.PortType, r.PortType) + fillEmpty(&m.Duplex, r.Duplex) + fillEmpty(&m.EncapType, r.EncapType) + if m.SpeedMbps == "" { + m.SpeedMbps = r.SpeedMbps + } + if m.Mtu == "" { + m.Mtu = r.Mtu + } + } + out = append(out, mergedInterface{Interface: m, key: interfaceKey(k.name, k.vpn, vpnsByName[k.name])}) + } + return out +} + +// interfaceKey is the per-device interface identity. An interface name +// used in a single VPN keeps the plain name, so its resource ID is +// unchanged from earlier releases. When one device uses the same name +// in several VPNs, the lowest VPN keeps the plain name and every other +// VPN appends "@vpn", so the interfaces stay distinct and the +// transport interface (VPN 0) keeps a stable ID that a neighbor +// reference in another site's document can reproduce. +func interfaceKey(name, vpn string, vpns []string) string { + if len(vpns) < 2 { + return name + } + lowest := vpns[0] + for _, v := range vpns[1:] { + if vpnLess(v, lowest) { + lowest = v + } + } + if vpn == lowest { + return name + } + return name + "@vpn" + vpn +} + +// vpnLess orders VPN IDs numerically, falling back to string order for +// non-numeric values. +func vpnLess(a, b string) bool { + ai, aerr := strconv.Atoi(a) + bi, berr := strconv.Atoi(b) + if aerr == nil && berr == nil { + return ai < bi + } + if (aerr == nil) != (berr == nil) { + return aerr == nil + } + return a < b +} + +// fillEmpty sets *dst to v when *dst is empty. +func fillEmpty(dst *string, v string) { + if *dst == "" { + *dst = v + } +} + +// addTunnelEndpoint records key -> id, marking key ambiguous ("") when +// a different interface already claims it. +func addTunnelEndpoint(index map[string]string, key, id string) { + if prev, ok := index[key]; ok && prev != id { + index[key] = "" + return + } + index[key] = id +} + +// containsConnection builds the "contains" connection from a device to +// one of its interfaces. The interface's own site document and any +// other site document that carries it as a neighbor build it the same +// way, so the connection ID is the same in every document. +func containsConnection(deviceResourceID, deviceNativeKey, ifaceID, ifname string) (sdk.Connection, bool) { + canonicalKey := sdk.ConnectionCanonicalKey(sdk.ConnectionIDInput{ + Type: "contains", + Direction: "forward", + Source: deviceResourceID, + Target: ifaceID, + }) + conn, err := sdk.NewConnection(sdk.BuildConnectionID(canonicalKey, 16), "contains", deviceResourceID, ifaceID) + if err != nil { + return sdk.Connection{}, false + } + conn.Name = fmt.Sprintf("%s -> %s", deviceNativeKey, ifname) + _ = conn.SetDirection("forward") + return conn, true +} + +// sharedAddressSpace is RFC 6598 carrier-grade NAT space, which +// net.IP.IsPrivate does not cover. +var sharedAddressSpace = &net.IPNet{IP: net.IPv4(100, 64, 0, 0), Mask: net.CIDRMask(10, 32)} + +// isPublicIP reports whether ip is a globally routable unicast address. +// Private (RFC 1918 / RFC 4193), shared (RFC 6598), loopback, +// link-local, multicast and unspecified addresses are not public. +func isPublicIP(ip string) bool { + p := net.ParseIP(ip) + if p == nil || !p.IsGlobalUnicast() || p.IsPrivate() { + return false + } + return !sharedAddressSpace.Contains(p) +} + +// parseIntField parses an SD-WAN Manager numeric-string field (e.g. +// mtu, speed_mbps, both returned as strings like "1500") into an int, +// matching OSIRIS-JSON-v1.0 section 7.5.2 integer type for these +// properties. Returns false for empty or non-numeric input. +func parseIntField(s string) (int, bool) { + if s == "" { + return 0, false + } + n, err := strconv.Atoi(s) + if err != nil { + return 0, false + } + return n, true +} + +// interfaceType maps SD-WAN Manager's port-type to the interface_type +// convention shown in OSIRIS-JSON-v1.0 7.5.3 ("primary"/"secondary"): +// "transport" (WAN uplink) is a device's primary interface, "service" +// (LAN-side) is secondary. Unrecognized values return "". +func interfaceType(portType string) string { + switch portType { + case "transport": + return "primary" + case "service": + return "secondary" + default: + return "" + } +} + +// mapUpDownStatus converts an SD-WAN Manager interface admin/oper +// state string into an OSIRIS-JSON-v1.0 section 4.5.2 status enum +// value. Two distinct vocabularies exist depending on platform: +// - classic vEdge (Viptela OS): simple "Up"/"Down". +// - cEdge (IOS-XE, e.g. C8000v/C8200L/ISR/ASR): the IOS-XE +// ietf-interfaces oper-status identity values +// ("if-oper-state-ready", "if-oper-state-no-pass", etc.) passed +// through verbatim - not documented anywhere in the SD-WAN Manager +// OpenAPI spec. +func mapUpDownStatus(state string) string { + switch strings.ToLower(state) { + case "up", "if-oper-state-ready": + return "active" + case "down", "if-oper-state-down", "if-oper-state-lower-layer-down", "if-oper-state-not-present": + return "inactive" + case "if-oper-state-no-pass": + // Administratively/physically up but not passing traffic (e.g. + // a sub-interface whose encapsulation/protocol isn't fully + // negotiated) - a real middle state, not plain up or down. + return "degraded" + default: + return "unknown" + } +} diff --git a/osiris/network/cisco/vmanage/transform_interfaces_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/transform_interfaces_test.go similarity index 86% rename from osiris/network/cisco/vmanage/transform_interfaces_test.go rename to osiris/network/cisco/catalyst-sd-wan-manager/transform_interfaces_test.go index 7af83a2..39af40b 100644 --- a/osiris/network/cisco/vmanage/transform_interfaces_test.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/transform_interfaces_test.go @@ -1,11 +1,11 @@ // transform_interfaces_test.go - Unit tests for interface resource and // "contains" connection mapping. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import "testing" @@ -33,13 +33,13 @@ func TestTransformInterfaces_WANInterfaceProperties(t *testing.T) { {Interface: "GigabitEthernet1", Color: "lte", PrivateIP: "203.0.113.10", PublicIP: "203.0.113.10", NatType: "E"}, } - resources, connections, tunnelIndex := TransformInterfaces("cisco.vmanage::TST0000001", "network.router", "TST0000001", "192.0.2.10", ifaces, wanIfaces) + resources, connections, tunnelIndex := TransformInterfaces("cisco.catalystsdwanmanager::TST0000001", "network.router", "TST0000001", "192.0.2.10", ifaces, wanIfaces) if len(resources) != 1 { t.Fatalf("expected 1 resource, got %d", len(resources)) } r := resources[0] - wantID := "cisco.vmanage::TST0000001-GigabitEthernet1" + wantID := "cisco.catalystsdwanmanager::TST0000001-GigabitEthernet1" if r.ID != wantID { t.Errorf("resource ID = %q, want %q", r.ID, wantID) } @@ -98,7 +98,7 @@ func TestTransformInterfaces_WANInterfaceProperties(t *testing.T) { t.Fatalf("expected 1 contains connection, got %d", len(connections)) } c := connections[0] - if c.Type != "contains" || c.Source != "cisco.vmanage::TST0000001" || c.Target != wantID { + if c.Type != "contains" || c.Source != "cisco.catalystsdwanmanager::TST0000001" || c.Target != wantID { t.Errorf("unexpected connection: %+v", c) } if c.Direction != "forward" { @@ -108,7 +108,7 @@ func TestTransformInterfaces_WANInterfaceProperties(t *testing.T) { // tunnelIndex is keyed by systemIP (the function's own 4th // argument, "192.0.2.10" here), not by the interface's resolved // public_ip a device can NAT its WAN circuit's public address - // independently of the system-ip vManage uses to identify it. + // independently of the system-ip SD-WAN Manager use to identify it. if got := tunnelIndex["192.0.2.10:lte"]; got != wantID { t.Errorf("tunnelIndex[192.0.2.10:lte] = %q, want %q", got, wantID) } @@ -129,7 +129,7 @@ func TestTransformInterfaces_DirectInternetAccessNotMislabeledPrivate(t *testing {Interface: "GigabitEthernet0", Color: "silver", PrivateIP: "203.0.113.50", PublicIP: "203.0.113.50", NatType: "N"}, } - resources, _, _ := TransformInterfaces("cisco.vmanage::TST0000001", "network.router", "TST0000001", "203.0.113.50", ifaces, wanIfaces) + resources, _, _ := TransformInterfaces("cisco.catalystsdwanmanager::TST0000001", "network.router", "TST0000001", "203.0.113.50", ifaces, wanIfaces) ipAddrs := resources[0].Properties["ip_addresses"].(map[string]any) if ipAddrs["public_ip"] != "203.0.113.50" { @@ -145,7 +145,7 @@ func TestTransformInterfaces_ControllerOwnerKeepsGenericType(t *testing.T) { {IfName: "eth0", AFType: "ipv4", IPAddress: "192.0.2.0/24"}, } - resources, _, _ := TransformInterfaces("cisco.vmanage::TST0000099", "osiris.cisco.controller", "TST0000099", "", ifaces, nil) + resources, _, _ := TransformInterfaces("cisco.catalystsdwanmanager::TST0000099", "osiris.cisco.controller", "TST0000099", "", ifaces, nil) if resources[0].Type != "network.interface" { t.Errorf("type = %q, want network.interface for a non-router owner", resources[0].Type) @@ -158,13 +158,13 @@ func TestTransformInterfaces_VPNID(t *testing.T) { {IfName: "GigabitEthernet3", AFType: "ipv4", IPAddress: "192.0.2.2/24", PortType: "service"}, } - resources, _, _ := TransformInterfaces("cisco.vmanage::TST0000001", "network.router", "TST0000001", "", ifaces, nil) + resources, _, _ := TransformInterfaces("cisco.catalystsdwanmanager::TST0000001", "network.router", "TST0000001", "", ifaces, nil) if resources[0].Properties["vpn_id"] != "10" { t.Errorf("properties.vpn_id = %v, want %q", resources[0].Properties["vpn_id"], "10") } if _, ok := resources[0].Properties["vrf_id"]; ok { - t.Error("vrf_id should not be emitted - vManage's raw data only ever reports vpn-id, never vrf") + t.Error("vrf_id should not be emitted - SD-WAN Manager's raw data only ever reports vpn-id, never vrf") } if _, ok := resources[1].Properties["vpn_id"]; ok { t.Error("empty vpn-id should not produce a vpn_id property") @@ -177,7 +177,7 @@ func TestTransformInterfaces_Description(t *testing.T) { {IfName: "GigabitEthernet3", AFType: "ipv4", IPAddress: "192.0.2.2/24", PortType: "service"}, } - resources, _, _ := TransformInterfaces("cisco.vmanage::TST0000001", "network.router", "TST0000001", "", ifaces, nil) + resources, _, _ := TransformInterfaces("cisco.catalystsdwanmanager::TST0000001", "network.router", "TST0000001", "", ifaces, nil) if resources[0].Description != "TEST WAN UPLINK" { t.Errorf("Description = %q, want %q", resources[0].Description, "TEST WAN UPLINK") @@ -201,7 +201,7 @@ func TestTransformInterfaces_BaseAddressClassifiedByIsPrivate(t *testing.T) { {IfName: "GigabitEthernet2", AFType: "ipv4", IPAddress: "192.0.2.1/24", PortType: "service", IfOperStatus: "Up"}, } - resources, _, tunnelIndex := TransformInterfaces("cisco.vmanage::TST0000001", "network.router", "TST0000001", "192.0.2.10", ifaces, nil) + resources, _, tunnelIndex := TransformInterfaces("cisco.catalystsdwanmanager::TST0000001", "network.router", "TST0000001", "192.0.2.10", ifaces, nil) if len(resources) != 1 { t.Fatalf("expected 1 resource, got %d", len(resources)) @@ -226,10 +226,10 @@ func TestTransformInterfaces_NoAddressPlaceholderOmitted(t *testing.T) { {IfName: "GigabitEthernet3", AFType: "ipv4", IPAddress: "0.0.0.0", PortType: "service"}, } - resources, _, _ := TransformInterfaces("cisco.vmanage::TST0000001", "network.router", "TST0000001", "", ifaces, nil) + resources, _, _ := TransformInterfaces("cisco.catalystsdwanmanager::TST0000001", "network.router", "TST0000001", "", ifaces, nil) if _, ok := resources[0].Properties["ip_addresses"]; ok { - t.Errorf("ip_addresses = %v, want absent - 0.0.0.0 is vManage's placeholder for no address configured", resources[0].Properties["ip_addresses"]) + t.Errorf("ip_addresses = %v, want absent - 0.0.0.0 is SD-WAN Manager's placeholder for no address configured", resources[0].Properties["ip_addresses"]) } } @@ -256,7 +256,7 @@ func TestSelectIPv4Interfaces_PrefersIPv4Row(t *testing.T) { {IfName: "GigabitEthernet1", AFType: "ipv6", IPAddress: "2001:DB8::/32"}, {IfName: "GigabitEthernet1", AFType: "ipv4", IPAddress: "192.0.2.0/24"}, } - selected := selectIPv4Interfaces(ifaces) + selected := mergeInterfaceRows(ifaces) if len(selected) != 1 { t.Fatalf("expected 1 deduplicated interface, got %d", len(selected)) } @@ -286,7 +286,7 @@ func TestMapUpDownStatus(t *testing.T) { {"Down", "inactive"}, {"", "unknown"}, // cEdge (IOS-XE) ietf-interfaces oper-status vocabulary not - // documented anywhere in the vManage OpenAPI spec. + // appear documented in the SD-WAN Manager OpenAPI spec. {"if-oper-state-ready", "active"}, {"if-oper-state-no-pass", "degraded"}, {"if-oper-state-down", "inactive"}, diff --git a/osiris/network/cisco/vmanage/transform_test.go b/osiris/network/cisco/catalyst-sd-wan-manager/transform_test.go similarity index 87% rename from osiris/network/cisco/vmanage/transform_test.go rename to osiris/network/cisco/catalyst-sd-wan-manager/transform_test.go index fa3d3c9..ac62885 100644 --- a/osiris/network/cisco/vmanage/transform_test.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/transform_test.go @@ -1,17 +1,17 @@ // transform_test.go - Unit tests for Device->OSIRIS JSON // resource mapping. // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import "testing" func TestTransformDevices_TypeMapping(t *testing.T) { devices := []Device{ - {UUID: "11111111-1111-1111-1111-111111111111", HostName: "TEST-VMANAGE1", SiteID: "100", Personality: "vmanage", DeviceModel: "vmanage", Status: "normal", Reachability: "reachable"}, + {UUID: "11111111-1111-1111-1111-111111111111", HostName: "TEST-SDWANMGR1", SiteID: "100", Personality: personalityManager, DeviceModel: personalityManager, Status: "normal", Reachability: "reachable"}, {UUID: "uuid-2", HostName: "TEST-VSMART1", SiteID: "100", Personality: "vsmart", DeviceModel: "vsmart", Status: "normal", Reachability: "reachable"}, {UUID: "uuid-3", HostName: "TEST-VBOND1", SiteID: "100", Personality: "vbond", DeviceModel: "vedge-cloud", Status: "normal", Reachability: "reachable"}, {UUID: "uuid-4", HostName: "TEST-VEDGE1", SiteID: "200", Personality: "vedge", DeviceModel: "vedge-100", Status: "normal", Reachability: "reachable"}, @@ -43,7 +43,7 @@ func TestTransformDevices_ResourceID(t *testing.T) { {UUID: "11111111-1111-1111-1111-111111111111", HostName: "TEST-VEDGE1", SiteID: "100", Personality: "vedge"}, } resources, systemIPToID := TransformDevices(devices, "documentation") - want := "cisco.vmanage::11111111-1111-1111-1111-111111111111" + want := "cisco.catalystsdwanmanager::11111111-1111-1111-1111-111111111111" if resources[0].ID != want { t.Errorf("resource ID = %q, want %q", resources[0].ID, want) } @@ -57,8 +57,8 @@ func TestTransformDevices_ResourceID(t *testing.T) { func TestTransformDevices_RouterIDUsesSerial(t *testing.T) { // network.router devices use board-serial for id/provider.native_id - // when available a real hardware serial, unlike "uuid" which - // vManage populates as a "-" string for + // when available a real hardware serial, unlike "uuid" which SD-WAN + // Manager populates as a "-" string for // vEdge/cEdge platforms, not an actual UUID. That string is // preserved separately as extensions.chassis_number. devices := []Device{ @@ -66,7 +66,7 @@ func TestTransformDevices_RouterIDUsesSerial(t *testing.T) { } resources, _ := TransformDevices(devices, "documentation") - want := "cisco.vmanage::TST123456789L" + want := "cisco.catalystsdwanmanager::TST123456789L" if resources[0].ID != want { t.Errorf("resource ID = %q, want %q", resources[0].ID, want) } @@ -99,10 +99,10 @@ func TestTransformDevices_RouterIDFallsBackWithoutSerial(t *testing.T) { } func TestTransformDevices_ControllerIDIgnoresSerial(t *testing.T) { - // Controllers (vmanage/vsmart/vbond) keep the uuid/deviceId key - // the serial substitution only applies to network.router. + // Controllers (SD-WAN Manager/vsmart/vbond) keep the uuid/deviceId + // key the serial substitution only applies to network.router. devices := []Device{ - {UUID: "11111111-1111-1111-1111-111111111111", HostName: "TEST-VMANAGE1", SiteID: "100", Personality: "vmanage", BoardSerial: "TST12345678"}, + {UUID: "11111111-1111-1111-1111-111111111111", HostName: "TEST-SDWANMGR1", SiteID: "100", Personality: personalityManager, BoardSerial: "TST12345678"}, } resources, _ := TransformDevices(devices, "documentation") @@ -162,23 +162,30 @@ func TestTransformDevices_SystemIPIndex(t *testing.T) { } } -func TestTransformDevices_ManagementIPOnly(t *testing.T) { - // The device's system-ip is represented once, as management_ip - // no separate ip_addresses object (it would just duplicate the same - // single value) and no bare system_ip key. +func TestTransformDevices_SystemIPIsOverlayIdentifier(t *testing.T) { + // The system-ip identifies the device in the SD-WAN overlay; it is + // not a proven management address, so it is emitted once, as + // extension system_ip, and never as management_ip or ip_addresses. devices := []Device{ {UUID: "11111111-1111-1111-1111-111111111111", HostName: "TEST-VEDGE1", SiteID: "100", Personality: "vedge", SystemIP: "192.0.2.1"}, } resources, _ := TransformDevices(devices, "documentation") - if resources[0].Properties["management_ip"] != "192.0.2.1" { - t.Errorf("management_ip = %v, want 192.0.2.1", resources[0].Properties["management_ip"]) + ext := resources[0].Extensions[extensionKey].(map[string]any) + if ext["system_ip"] != "192.0.2.1" { + t.Errorf("system_ip = %v, want 192.0.2.1", ext["system_ip"]) } - if _, ok := resources[0].Properties["ip_addresses"]; ok { - t.Error("ip_addresses should not be emitted it would duplicate management_ip") + for _, k := range []string{"management_ip", "ip_addresses", "system_ip"} { + if _, ok := resources[0].Properties[k]; ok { + t.Errorf("properties.%s must not be emitted", k) + } } - if _, ok := resources[0].Properties["system_ip"]; ok { - t.Error("system_ip should no longer be emitted as a bare property key") +} + +func TestTransformDevices_NoNativeIdentityIsSkipped(t *testing.T) { + resources, idx := TransformDevices([]Device{{HostName: "TEST-NOID", Personality: "vedge", SystemIP: "192.0.2.9"}}, "audit") + if len(resources) != 0 || len(idx) != 0 { + t.Errorf("a device with no serial, uuid or deviceId must not be emitted, got %v", resources) } } @@ -243,8 +250,9 @@ func TestTransformDevices_ExtensionsNamespace(t *testing.T) { func TestTransformDevices_NoExtensionsWhenEmpty(t *testing.T) { // No site-id, no device_groups, documentation purpose: ext ends up - // empty, and r.Extensions should stay nil rather than emit an - // empty placeholder object ("extensions": {"osiris.cisco.vmanage": {}}). + // empty, and r.Extensions should stay nil rather than emit an empty + // placeholder object ("extensions": + // {"osiris.cisco.catalystsdwanmanager": {}}). devices := []Device{ {UUID: "11111111-1111-1111-1111-111111111111", HostName: "TEST-VEDGE1", Personality: "vedge"}, } @@ -300,7 +308,7 @@ func TestTransformDevices_HealthAndInventoryExtensions(t *testing.T) { { UUID: "11111111-1111-1111-1111-111111111111", HostName: "TEST-CEDGE1", SiteID: "200", Personality: "cedge", HealthState: "green", StateDescription: "All daemons up", - ConnectedVManages: []string{"192.0.2.5"}, + ConnectedManagers: []string{"192.0.2.5"}, LastUpdated: 1634627015139, UptimeDate: 1634626320000, }, @@ -424,10 +432,10 @@ func TestStripCIDRHost(t *testing.T) { {"", ""}, {"-", ""}, {"not-an-ip/24", ""}, - // vManage's placeholder for "no address configured" on a down - // interface, observed both bare and CIDR-suffixed in real - // responses not a real address, and not private just because - // it fails an RFC 1918 check. + // SD-WAN Manager's placeholder for "no address configured" on a + // down interface, observed both bare and CIDR-suffixed in real + // responses not a real address, and not private just because it + // fails an RFC 1918 check. {"0.0.0.0", ""}, {"0.0.0.0/32", ""}, } @@ -439,12 +447,15 @@ func TestStripCIDRHost(t *testing.T) { } func TestTransformSiteGroup_Basic(t *testing.T) { - g, ok := TransformSiteGroup("100", "MXP", nil, []string{"cisco.vmanage::a", "cisco.vmanage::b"}) + g, ok := TransformSiteGroup("100", "MXP", nil, []string{"cisco.catalystsdwanmanager::a", "cisco.catalystsdwanmanager::b"}) if !ok { t.Fatal("expected ok=true with non-empty deviceResourceIDs") } - if g.Type != "physical.room" { - t.Errorf("Type = %q, want %q", g.Type, "physical.room") + if g.Type != "logical.site" { + t.Errorf("Type = %q, want %q", g.Type, "logical.site") + } + if ext, _ := g.Extensions[extensionKey].(map[string]any); ext["site_id"] != "100" { + t.Errorf("site_id extension = %v, want 100", g.Extensions) } if g.Name != "MXP" { t.Errorf("Name = %q, want %q", g.Name, "MXP") @@ -458,7 +469,7 @@ func TestTransformSiteGroup_UnsitedFallback(t *testing.T) { // No siteID and no siteName (the "unclaimed" bucket): group still // gets a stable boundary token and a display name instead of an // empty one. - g, ok := TransformSiteGroup("", "", nil, []string{"cisco.vmanage::a"}) + g, ok := TransformSiteGroup("", "", nil, []string{"cisco.catalystsdwanmanager::a"}) if !ok { t.Fatal("expected ok=true") } @@ -468,15 +479,15 @@ func TestTransformSiteGroup_UnsitedFallback(t *testing.T) { // The boundary token (and therefore the group ID) must be stable // and distinct from any real site-id same group across runs. - g2, _ := TransformSiteGroup("", "", nil, []string{"cisco.vmanage::a"}) + g2, _ := TransformSiteGroup("", "", nil, []string{"cisco.catalystsdwanmanager::a"}) if g.ID != g2.ID { t.Errorf("group ID not deterministic: %q != %q", g.ID, g2.ID) } } func TestTransformSiteGroup_GeoLocation(t *testing.T) { - // vManage reports the same coordinates for every device at a site - // the first resolvable pair is used, matching OSIRIS-JSON-v1.0 + // SD-WAN Manager reports the same coordinates for every device at a + // site the first resolvable pair is used, matching OSIRIS-JSON-v1.0 // section 6.5 common properties.geo_location shape for groups. Not // purpose-gated: a site's coordinates are not sensitive the way a // serial number or certificate validity is. @@ -485,7 +496,7 @@ func TestTransformSiteGroup_GeoLocation(t *testing.T) { {Latitude: "45.5433411", Longitude: 10.2241237}, } - g, _ := TransformSiteGroup("100", "MXP", devices, []string{"cisco.vmanage::a"}) + g, _ := TransformSiteGroup("100", "MXP", devices, []string{"cisco.catalystsdwanmanager::a"}) geo, ok := g.Properties["geo_location"].(map[string]any) if !ok { t.Fatalf("expected properties.geo_location to be an object, got %T", g.Properties["geo_location"]) @@ -500,7 +511,7 @@ func TestTransformSiteGroup_GeoLocation(t *testing.T) { func TestTransformSiteGroup_NoGeoLocationWhenUnresolvable(t *testing.T) { devices := []Device{{Latitude: nil, Longitude: nil}} - g, _ := TransformSiteGroup("100", "MXP", devices, []string{"cisco.vmanage::a"}) + g, _ := TransformSiteGroup("100", "MXP", devices, []string{"cisco.catalystsdwanmanager::a"}) if _, ok := g.Properties["geo_location"]; ok { t.Error("geo_location should be omitted when no device resolves coordinates") } diff --git a/osiris/network/cisco/vmanage/tty.go b/osiris/network/cisco/catalyst-sd-wan-manager/tty.go similarity index 64% rename from osiris/network/cisco/vmanage/tty.go rename to osiris/network/cisco/catalyst-sd-wan-manager/tty.go index e6c6496..8b2bda0 100644 --- a/osiris/network/cisco/vmanage/tty.go +++ b/osiris/network/cisco/catalyst-sd-wan-manager/tty.go @@ -1,19 +1,14 @@ -// tty.go - Interactive host/username prompt for the Cisco vManage -// OSIRIS JSON producer. +// tty.go - Interactive host/username prompt for the Cisco Catalyst +// SD-WAN Manager OSIRIS JSON producer. // // Password prompting reuses osiris/network/cisco/run.PromptPassword -// (hidden echo, shared with apic/nxos/iosxe). Host/username are visible -// prompts specific to vmanage's fuller interactive login flow (see -// flags.go's ParseFlags fallback chain: flag, then --secrets-file, then -// this prompt) - apic/nxos/iosxe never need to ask for host/username -// interactively, so this stays local to vmanage rather than living in -// the shared run package. +// (hidden echo, shared with apic/nxos/iosxe). // -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: +// OSIRIS JSON Producer for Cisco Catalyst SD-WAN Manager introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco // [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage +package catalystsdwanmanager import ( "bufio" diff --git a/osiris/network/cisco/cisco.go b/osiris/network/cisco/cisco.go index 71c3bef..6849ffc 100644 --- a/osiris/network/cisco/cisco.go +++ b/osiris/network/cisco/cisco.go @@ -1,20 +1,21 @@ // Package cisco implements the Cisco vendor entry point for the // OSIRIS JSON producer CLI. // -// Dispatches to sub-producers (APIC, NX-OS, IOS-XE, vManage). Each -// sub-producer owns its own CLI flag parsing, Config type, and -// single/batch runner (see each producer's own flags.go/dispatch.go -// doc comments) this package only routes a subcommand name to the -// right one and prints the top-level --help summary. The shared -// osiris/network/cisco/run package remains only for genuinely -// vendor-agnostic mechanisms (TargetConfig, CSV parsing, credential- -// file handling, prompting, path/timestamp helpers, template -// generation) that every producer still reuses directly. +// Dispatches to sub-producers (APIC, NX-OS, IOS-XE, Catalyst SD-WAN +// Manager). Each sub-producer owns its own CLI flag parsing, Config +// type, and single/batch runner (see each producer's own +// flags.go/dispatch.go doc comments) this package only routes a +// subcommand name to the right one and prints the top-level --help +// summary. The shared osiris/network/cisco/run package remains only for +// genuinely vendor-agnostic mechanisms (TargetConfig, CSV parsing, +// credential- file handling, prompting, path/timestamp helpers, +// template generation) that every OSIRIS JSON Producer still reuses +// directly. // // Usage: // -// osirisjson-producer cisco [flags] -// osirisjson-producer cisco template --generate +// osirisjson-producer cisco [flags] +// osirisjson-producer cisco template --generate // // OSIRIS JSON Producer for Cisco introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco @@ -25,9 +26,9 @@ import ( "fmt" "go.osirisjson.org/producers/osiris/network/cisco/apic" + catalystsdwanmanager "go.osirisjson.org/producers/osiris/network/cisco/catalyst-sd-wan-manager" "go.osirisjson.org/producers/osiris/network/cisco/iosxe" "go.osirisjson.org/producers/osiris/network/cisco/nxos" - "go.osirisjson.org/producers/osiris/network/cisco/vmanage" ) // subProducer describes a Cisco sub-producer for the top-level --help @@ -40,9 +41,9 @@ type subProducer struct { var subProducers = []subProducer{ {"apic", "Cisco ACI/APIC", apic.Run}, - {"nxos", "Cisco NX-OS", nxos.Run}, {"iosxe", "Cisco IOS-XE", iosxe.Run}, - {"vmanage", "Cisco Catalyst SD-WAN Manager (vManage)", vmanage.Run}, + {"nxos", "Cisco NX-OS", nxos.Run}, + {"sdwan", "Cisco Catalyst SD-WAN Manager", catalystsdwanmanager.Run}, } // Run is the entry point called by the CLI dispatcher. @@ -85,7 +86,7 @@ Subcommands: fmt.Print(` Each subcommand owns its own flags and has its own --help run -'osirisjson-producer cisco --help' for the full flag list. +'osirisjson-producer cisco --help for the full flag list. All four share the same broad shape: -h, --host Target host (IP or FQDN, optionally with :port); @@ -95,25 +96,26 @@ All four share the same broad shape: --secrets-file JSON file with {host, username, password}; overrides -h/-u when they omit a field --purpose Output per OSIRIS JSON chapter 13.1.3 - --include-raw-body Attach each collected command's full, unmodified - response (requires --purpose audit). - For development purpose. + --include-raw-body Attach each collected response, with secrets + redacted (requires --purpose audit). + For development purpose as the data is raw + exported still not map to OSIRIS JSON. --safe-failure-mode Secret handling: fail-closed, log-and-redact, or off (default: fail-closed). apic accepts fail-closed or off only. --insecure Skip TLS/SSH host-key verification apic/nxos/iosxe additionally support CSV batch mode (-s/--source, --o/--output) see each producer's own --help for the CSV column -layout and output path convention. vmanage has no CSV batch mode: one -run targets one controller and fans out into one document per -WAN edge site. +-o/--output) see each producer's own --help for the CSV column layout +and output path convention. catalyst-sdwan-manager has no CSV batch mode +one run targets one controller and fans out into one document per WAN +edge site. Examples: osirisjson-producer cisco apic -h 192.0.2.1 -u username osirisjson-producer cisco nxos -h 192.0.2.1 -u username --insecure osirisjson-producer cisco apic -s datacenter.csv -o ./output -u username - osirisjson-producer cisco vmanage -h vmanage.example.com -u username + osirisjson-producer cisco sdwan -h sdwan-manager.example.com -u username osirisjson-producer cisco template --generate `) } diff --git a/osiris/network/cisco/nxos/client_test.go b/osiris/network/cisco/nxos/client_test.go index 19af62d..cb0ac6e 100644 --- a/osiris/network/cisco/nxos/client_test.go +++ b/osiris/network/cisco/nxos/client_test.go @@ -282,7 +282,7 @@ func TestShowMulti_SingleCommand(t *testing.T) { func TestShowMulti_PerCommandFailureIsolated(t *testing.T) { // one command failing within a multi-command batch must // not erase, or be reported as, a failure of the whole batch its - // siblings' results (success or failure) must be unaffected. + // siblings results (success or failure) must be unaffected. ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") resp := map[string]any{ diff --git a/osiris/network/cisco/nxos/config.go b/osiris/network/cisco/nxos/config.go index aa3d686..a9e3790 100644 --- a/osiris/network/cisco/nxos/config.go +++ b/osiris/network/cisco/nxos/config.go @@ -2,16 +2,17 @@ // Cisco NX-OS OSIRIS JSON producer. // // NX-OS is normally one independently authenticated switch per -// collection target, so, this producer keeps ideally a CSV -// batch mode (many devices, one document each). This package owns its -// own flag surface and Config type (see flags.go) instead of going -// through the shared osiris/network/cisco/run.ParseFlags/RunConfig -// orchestrator only genuinely vendor-agnostic mechanisms are reused -// from that package directly (TargetConfig, ParseHostPort, prompting, +// collection target, so, this producer keeps ideally a CSV batch mode +// (many devices, one document each). This package owns its own flag +// surface and Config type (see flags.go) instead of going through the +// shared osiris/network/cisco/run.ParseFlags/RunConfig orchestrator +// only genuinely vendor-agnostic mechanisms are reused from that +// package directly (TargetConfig, ParseHostPort, prompting, // credential-file loading/resolution, CSV parsing, path sanitization, -// timestamp formatting), matching the same reuse pattern vmanage -// already established and the parent Cisco architecture review's own -// direction to move orchestration into each producer. +// timestamp formatting), matching the same reuse pattern +// catalyst-sdwan-manager already established and the parent Cisco +// architecture review's own direction to move orchestration into each +// producer. // // OSIRIS JSON Producer for Cisco NX-OS introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco diff --git a/osiris/network/cisco/nxos/nxos.go b/osiris/network/cisco/nxos/nxos.go index 68a8ed9..9366f77 100644 --- a/osiris/network/cisco/nxos/nxos.go +++ b/osiris/network/cisco/nxos/nxos.go @@ -4,10 +4,11 @@ // // This file holds the whole CLI surface (Run, the single/batch runners, // --help, template generation) alongside the Producer type and its -// Collect the same one-file shape osiris/network/cisco/vmanage uses -// instead of a separate dispatch.go. The per-domain NX-API -> OSIRIS -// mapping lives in the transform_.go files; wire handling and the -// typed response DTOs are in client.go and dto.go. +// Collect the same one-file shape +// osiris/network/cisco/catalyst-sd-wan-manager uses instead of a +// separate dispatch.go. The per-domain NX-API -> OSIRIS mapping lives +// in the transform_.go files; wire handling and the typed +// response DTOs are in client.go and dto.go. // // OSIRIS JSON Producer for Cisco introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco @@ -42,10 +43,11 @@ const templateExampleHost = "192.0.2.1" func Run(args []string) error { // Only the long form is checked here: -h is the documented short // flag for --host (see flags.go), so it must reach ParseFlags - // instead of being intercepted as a help request the same - // -h/--host vs. -h/help ambiguity osiris/network/cisco/cisco.go's - // runSubProducer already handles for apic/iosxe, and vmanage.go's - // own Run handles for vmanage. + // instead of being intercepted as a help request the same -h/--host + // vs. -h/help ambiguity osiris/network/cisco/cisco.go's + // runSubProducer already handles for apic/iosxe, and + // catalystsdwanmanager.go's own Run handles for + // catalyst-sdwan-manager. if len(args) > 0 { switch args[0] { case "--help": @@ -71,10 +73,10 @@ func Run(args []string) error { // runTemplate writes this producer's CSV batch template // (cisco-nxos-template.csv) and both --secrets-file shapes // (cisco-nxos-secrets.json, cisco-nxos-secrets-multihost.json) via the -// shared run.GenerateTemplates CSV batch mode is still this -// producer's own feature (unlike vmanage), so unlike vmanage's -// runTemplate this does call GenerateTemplates, not just the two -// --secrets-file variants. +// shared run.GenerateTemplates CSV batch mode is still this producer's +// own feature (unlike catalyst-sdwan-manager), so unlike +// catalyst-sdwan-manager's runTemplate this does call +// GenerateTemplates, not just the two --secrets-file variants. func runTemplate(args []string) error { if len(args) == 0 || (args[0] != "--generate" && args[0] != "-g") { fmt.Println("Usage: osirisjson-producer cisco nxos template --generate") @@ -251,7 +253,7 @@ func (p *Producer) Collect(ctx *sdk.Context) (*sdk.Document, error) { // transport-level failure (device unreachable, malformed envelope) // an individual command being rejected by the CLI becomes that // command's own ShowResult.Err instead (see decodeBody), so one - // command failing here never erases the others' data. + // command failing here never erases the others data. batch1Commands := []string{ "show inventory", "show module", diff --git a/osiris/network/cisco/nxos/nxos_test.go b/osiris/network/cisco/nxos/nxos_test.go index b689c80..e3f9ff3 100644 --- a/osiris/network/cisco/nxos/nxos_test.go +++ b/osiris/network/cisco/nxos/nxos_test.go @@ -249,7 +249,7 @@ func fixtureServer(t *testing.T) *httptest.Server { // failCmd fail (CLI code 400) instead of returning its normal fixture, // while every other command in the same batch still succeeds: one // command failing inside a multi-command batch must not erase its -// siblings' data from the emitted document. +// siblings data from the emitted document. func fixtureServerWithFailingCommand(t *testing.T, failCmd string) *httptest.Server { t.Helper() return newFixtureServer(t, failCmd, nil) diff --git a/osiris/network/cisco/run/batch.go b/osiris/network/cisco/run/batch.go index d936253..093e2f5 100644 --- a/osiris/network/cisco/run/batch.go +++ b/osiris/network/cisco/run/batch.go @@ -22,7 +22,7 @@ import ( // csvExampleRows gives CSVTemplate its one example row per producer // apic gets an APIC controller, nxos an NX-OS switch, iosxe an // IOS-XE router, each in the context that producer actually collects -// from. Showing the other two producers' rows in, like, an +// from. Showing the other two producers rows in, like, an // "iosxe template --generate" output was confusing (a user running // iosxe producer has no reason to see apic/nxos examples) one row, // matching the producer that generated the file, is clearer. diff --git a/osiris/network/cisco/run/credentials.go b/osiris/network/cisco/run/credentials.go index ade38d5..6dbf5cb 100644 --- a/osiris/network/cisco/run/credentials.go +++ b/osiris/network/cisco/run/credentials.go @@ -1,15 +1,14 @@ -// credentials.go - Credential-file loading -// for Cisco OSIRIS JSON Producer. -// Replaces (present in the initial release) plaintext -p/--password CLI -// flags (visible via ps and shell history) with a JSON file the caller -// points at via --secrets-file (apic/iosxe/nxos and vmanage all use -// this same flag name, aligning with the --secrets-file convention -// already established). -// Loading enforces that the file cannot be read back by anyone but the -// user who created it: no symlinks, no group/other permission bits, and -// (where the platform exposes ownership) no owner other than the -// current user. See credentials_unix.go and credentials_other.go for -// the platform-specific half of that check. +// credentials.go - Credential-file loading for Cisco OSIRIS JSON +// Producer. Replaces (present in the initial release) plaintext +// -p/--password CLI flags (visible via ps and shell history) with a +// JSON file the caller points at via --secrets-file (apic/iosxe/nxos +// and catalyst-sdwan-manager all use this same flag name, aligning with +// the --secrets-file convention already established). Loading enforces +// that the file cannot be read back by anyone but the user who created +// it: no symlinks, no group/other permission bits, and (where the +// platform exposes ownership) no owner other than the current user. See +// credentials_unix.go and credentials_other.go for the +// platform-specific half of that check. // // OSIRIS JSON Producer for Cisco introduction: // [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco @@ -26,13 +25,14 @@ import ( ) // CredentialFile is the on-disk JSON shape read by every cisco producer -// --secrets-file (apic/iosxe/nxos via LoadCredentialFile below, vmanage -// via its own ParseFlags). Two shapes are accepted, distinguished by -// whether Default or Rules is present (either one alone is enough to -// select the rules shape a file with only "default" and no "rules" -// array at all is valid and common, e.g. a batch that shares one login -// across every target but was authored using the rules shape's -// wrapper instead of the flat shape's bare fields): +// --secrets-file (apic/iosxe/nxos via LoadCredentialFile below, +// catalyst-sdwan-manager via its own ParseFlags). Two shapes are +// accepted, distinguished by whether Default or Rules is present +// (either one alone is enough to select the rules shape a file with +// only "default" and no "rules" array at all is valid and common, e.g. +// a batch that shares one login across every target but was authored +// using the rules shape's wrapper instead of the flat shape's bare +// fields): // // - flat (the original single host target shape): // {host, username, password} one credential set used for a diff --git a/osiris/network/cisco/run/templates.go b/osiris/network/cisco/run/templates.go index 194f832..851174c 100644 --- a/osiris/network/cisco/run/templates.go +++ b/osiris/network/cisco/run/templates.go @@ -6,7 +6,7 @@ // Centralized here so that behavior (0600 permissions, the confirmation // message, the credential skeletons JSON shapes) is implemented once // instead of once per producer apic/iosxe/nxos call GenerateTemplates -// directly; vmanage (which has no CSV batch mode) calls +// directly; catalyst-sdwan-manager (which has no CSV batch mode) calls // WriteTemplateFile, CredentialFileTemplate and // CredentialRulesFileTemplate individually, see its own runTemplate. // @@ -53,13 +53,13 @@ type credentialFileTemplateDoc struct { // CredentialFileTemplate returns a skeleton flat-shape --secrets-file // JSON document (the same flag name and shape apic/iosxe/nxos and -// vmanage all share): a single login, for one target or shared by -// every target in a batch. exampleHost is shown as the "host" value -// callers pass whatever best illustrates their own target (an RFC 5737 -// documentation address for apic/iosxe/nxos, a documentation domain -// for vmanage's controller-style host). See CredentialRulesFileTemplate -// for the alternate per-host/CIDR shape, generated as its own separate -// file. +// catalyst-sdwan-manager all share): a single login, for one target or +// shared by every target in a batch. exampleHost is shown as the "host" +// value callers pass whatever best illustrates their own target (an RFC +// 5737 documentation address for apic/iosxe/nxos, a documentation +// domain for catalyst-sdwan-manager's controller-style host). See +// CredentialRulesFileTemplate for the alternate per-host/CIDR shape, +// generated as its own separate file. func CredentialFileTemplate(exampleHost string) string { doc := credentialFileTemplateDoc{ Comment: `osirisjson-producer --secrets-file: one login, used for a single target or shared by every target in a batch. Leave a field out to fall back to its own flag or an interactive prompt. For different credentials per target, see the companion "-multihost" template instead.`, @@ -89,9 +89,9 @@ type credentialRulesFileTemplateDoc struct { // CredentialRulesFileTemplate returns a skeleton rules-shape // --secrets-file JSON document: different credentials for different // targets in one batch, matched by host or CIDR. hostsA and hostsB are -// the two example rules' "hosts" patterns callers pass whatever best +// the two example rules "hosts" patterns callers pass whatever best // illustrates their own targets (RFC 5737 CIDR/exact-IP patterns for -// apic/iosxe/nxos, example.com-based FQDNs for vmanage's +// apic/iosxe/nxos, example.com-based FQDNs for catalyst-sdwan-manager's // controller-style hosts). Every username/password placeholder in the // output is the same "user"/"changeme" pair CredentialFileTemplate // uses, deliberately not a per-rule name like "user" the @@ -113,12 +113,12 @@ func CredentialRulesFileTemplate(hostsA, hostsB string) string { // GenerateTemplates writes a CSV batch template // (cisco--template.csv) plus both --secrets-file shapes // flat (cisco--secrets.json) and rules -// (cisco--secrets-multihost.json) for producerName, -// used by apic/iosxe/nxos's " template --generate". vmanage -// has no CSV batch mode, so it does not use this helper see its own -// runTemplate, which writes only the two --secrets-file variants via -// WriteTemplateFile, CredentialFileTemplate and -// CredentialRulesFileTemplate directly. +// (cisco--secrets-multihost.json) for producerName, used +// by apic/iosxe/nxos's " template --generate". +// catalyst-sdwan-manager has no CSV batch mode, so it does not use this +// helper see its own runTemplate, which writes only the two +// --secrets-file variants via WriteTemplateFile, CredentialFileTemplate +// and CredentialRulesFileTemplate directly. func GenerateTemplates(producerName, exampleHost string) error { csvFilename := fmt.Sprintf("cisco-%s-template.csv", producerName) if err := WriteTemplateFile(csvFilename, CSVTemplate(producerName)); err != nil { diff --git a/osiris/network/cisco/run/templates_test.go b/osiris/network/cisco/run/templates_test.go index 5cb8dea..58a51b4 100644 --- a/osiris/network/cisco/run/templates_test.go +++ b/osiris/network/cisco/run/templates_test.go @@ -120,24 +120,25 @@ func TestCredentialRulesFileTemplate_ParsesAndResolves(t *testing.T) { } func TestCredentialRulesFileTemplate_DomainHosts(t *testing.T) { - // vmanage passes example.com-based FQDNs (RFC 2606) instead of RFC - // 5737 IP/CIDR patterns, since its targets are controller hostnames - // not bare IPs. Exact-string matching (hostMatches' non-CIDR - // branch) must work identically for a domain name as for an IP. - got := CredentialRulesFileTemplate("vmanage01.example.com", "vmanage02.example.com") + // catalyst-sdwan-manager passes example.com-based FQDNs (RFC 2606) + // instead of RFC 5737 IP/CIDR patterns, since its targets are + // controller hostnames not bare IPs. + // Exact-string matching (hostMatches non-CIDR branch) must work + // identically for a domain name as for an IP. + got := CredentialRulesFileTemplate("sdwan-manager01.example.com", "sdwan-manager02.example.com") var cf CredentialFile if err := json.Unmarshal([]byte(got), &cf); err != nil { t.Fatalf("generated template is not valid JSON for CredentialFile: %v", err) } - u, p := cf.ResolveForHost("vmanage01.example.com") + u, p := cf.ResolveForHost("sdwan-manager01.example.com") if u != "user" || p != "changeme" { - t.Errorf("ResolveForHost(vmanage01.example.com) = %q/%q, want user/changeme", u, p) + t.Errorf("ResolveForHost(sdwan-manager01.example.com) = %q/%q, want user/changeme", u, p) } - u, p = cf.ResolveForHost("vmanage02.example.com") + u, p = cf.ResolveForHost("sdwan-manager02.example.com") if u != "user" || p != "changeme" { - t.Errorf("ResolveForHost(vmanage02.example.com) = %q/%q, want user/changeme", u, p) + t.Errorf("ResolveForHost(sdwan-manager02.example.com) = %q/%q, want user/changeme", u, p) } } diff --git a/osiris/network/cisco/vmanage/client.go b/osiris/network/cisco/vmanage/client.go deleted file mode 100644 index d6a8507..0000000 --- a/osiris/network/cisco/vmanage/client.go +++ /dev/null @@ -1,681 +0,0 @@ -// client.go - vManage REST API client for the -// Cisco SD-WAN Manager OSIRIS JSON Producer. -// -// Authentication is the standard vManage session-cookie + XSRF flow: -// POST /j_security_check (form-encoded username/password) establishes -// a JSESSIONID session cookie (handled automatically by the cookie jar -// from run.NewHTTPClient), then GET /dataservice/client/token mints an -// XSRF token that must be sent as the X-XSRF-TOKEN header on every -// subsequent /dataservice call. /j_security_check is a servlet outside -// /dataservice and is not part of the vManage OpenAPI spec, so its -// failure heuristic (an HTML login page being re-served) follows the -// commonly documented vManage automation pattern rather than a spec -// definition. -// -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: -// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco -// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification - -package vmanage - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "log/slog" - "net/http" - "net/url" - "strconv" - "strings" - "sync" - "time" - - "go.osirisjson.org/producers/osiris/network/cisco/run" -) - -// requestTimeout bounds every HTTP call this client makes. Deployments -// with many sites resolve site names via one call per site (see -// GetSiteName / siteDisplayName in sites_select.go) without a -// timeout, a single slow or silently-dropped request can hang the -// whole run indefinitely. run.NewHTTPClient sets no timeout (shared by -// apic/nxos/iosxe too), so it is applied here, scoped to vmanage only. -const requestTimeout = 15 * time.Second - -// Client is a thin HTTP client for the vManage dataservice REST API. -type Client struct { - baseURL string - httpClient *http.Client - xsrfToken string - logger *slog.Logger - - // siteNameMu/siteNameLastRequest/siteNameMinInterval throttle - // GetSiteName specifically (bulk site-name resolution in - // sites_select.go issues one call per discovered site across a - // worker pool concurrency alone does not bound requests/second). - // Every other endpoint on this client is unthrottled. - siteNameMu sync.Mutex - siteNameLastRequest time.Time - siteNameMinInterval time.Duration -} - -// Device is the subset of the GET /dataservice/device response fields -// (tag "Monitoring - Device Details") this producer maps to OSIRIS -// resources. Field names and shapes are taken verbatim from the -// vManage OpenAPI spec's documented example for this endpoint. -// -// Latitude/Longitude are typed any because the spec's own example -// mixes a string latitude ("37.666684") with a numeric longitude -// (-122.777023) for the same object. -// -// HealthState ("state") is the dashboard health rollup -// (green/red/yellow), distinct from Reachability and Status. -type Device struct { - DeviceID string `json:"deviceId"` - SystemIP string `json:"system-ip"` - HostName string `json:"host-name"` - UUID string `json:"uuid"` - SiteID string `json:"site-id"` - Personality string `json:"personality"` - DeviceType string `json:"device-type"` - DeviceModel string `json:"device-model"` - Reachability string `json:"reachability"` - Status string `json:"status"` - Validity string `json:"validity"` - Version string `json:"version"` - Platform string `json:"platform"` - BoardSerial string `json:"board-serial"` - CertificateValidity string `json:"certificate-validity"` - DeviceGroups []string `json:"device-groups"` - Latitude any `json:"latitude"` - Longitude any `json:"longitude"` - LastUpdated int64 `json:"lastupdated"` - HealthState string `json:"state"` - StateDescription string `json:"state_description"` - UptimeDate int64 `json:"uptime-date"` - ConnectedVManages []string `json:"connectedVManages"` -} - -// NewClient creates a vManage client targeting the given controller. -func NewClient(cfg *Config, logger *slog.Logger) *Client { - addr := cfg.Host - if strings.Contains(addr, ":") { - addr = "[" + addr + "]" - } - httpClient := run.NewHTTPClient(cfg.InsecureTLS) - httpClient.Timeout = requestTimeout - return &Client{ - baseURL: fmt.Sprintf("https://%s:%d", addr, cfg.Port), - httpClient: httpClient, - logger: logger, - siteNameMinInterval: rateToInterval(cfg.SiteNameRateLimit), - } -} - -// rateToInterval converts a requests/second rate to the minimum -// interval between requests. perSecond <= 0 is treated as 1 (never -// fully disabled pass a large value instead if throttling genuinely -// isn't wanted). -func rateToInterval(perSecond int) time.Duration { - if perSecond <= 0 { - perSecond = 1 - } - return time.Second / time.Duration(perSecond) -} - -// throttleSiteName blocks until at least siteNameMinInterval has -// passed since the previous GetSiteName call, so concurrent bulk -// resolution (resolveSiteNamesConcurrently in sites_select.go) never -// exceeds --site-name-rate requests/second regardless of worker count. -func (c *Client) throttleSiteName() { - c.siteNameMu.Lock() - defer c.siteNameMu.Unlock() - wait := c.siteNameMinInterval - time.Since(c.siteNameLastRequest) - if wait > 0 { - time.Sleep(wait) - } - c.siteNameLastRequest = time.Now() -} - -// Login authenticates against the vManage controller: session-cookie -// login via /j_security_check, followed by minting an XSRF token via -// GET /dataservice/client/token. The XSRF token is stored and attached -// as X-XSRF-TOKEN on every subsequent request. -func (c *Client) Login(username, password string) error { - form := url.Values{ - "j_username": {username}, - "j_password": {password}, - } - req, err := http.NewRequest(http.MethodPost, c.baseURL+"/j_security_check", strings.NewReader(form.Encode())) - if err != nil { - return fmt.Errorf("vManage login: failed to create request: %w", err) - } - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - - resp, err := c.httpClient.Do(req) - if err != nil { - return fmt.Errorf("vManage login request failed: %w", err) - } - defer resp.Body.Close() - - body, err := io.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("vManage login: failed to read response: %w", err) - } - - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("vManage login failed (HTTP %d): %s", resp.StatusCode, truncateBody(body)) - } - // A re-served HTML login page is the commonly documented vManage - // indicator of a rejected username/password (j_security_check - // itself always answers 200 either way). - if bytes.Contains(bytes.ToLower(body), []byte("= 0 { - return time.Duration(secs) * time.Second - } - } - delay := baseRetryDelay * time.Duration(1< maxRetryDelay { - delay = maxRetryDelay - } - return delay -} - -// GetDevices fetches the full device inventory via GET -// /dataservice/device. -func (c *Client) GetDevices() ([]Device, error) { - devices, _, err := c.GetDevicesWithRaw() - return devices, err -} - -// GetDevicesWithRaw is GetDevices plus each device's own raw JSON -// object, aligned index-for-index with the returned []Device used -// for --include-raw-body (see wantRawBody in vmanage.go), a lossless -// fallback for fields this producer doesn't model yet. -func (c *Client) GetDevicesWithRaw() ([]Device, []json.RawMessage, error) { - body, err := c.get("/dataservice/device") - if err != nil { - return nil, nil, err - } - return decodeListResponseWithRaw[Device]("/dataservice/device", body) -} - -// decodeListResponse parses a vManage list endpoint response, trying -// the common {"data": [...]} envelope first (decided by the first -// non-whitespace byte) and falling back to a bare JSON array. Shared by -// every list endpoint on this client so the envelope-vs-bare-array -// defensiveness isn't duplicated per endpoint. The spec's own -// documented examples show a bare array for most of these endpoints, -// but real vManage deployments commonly wrap list responses as -// {"data": [...]} instead, this handles either shape without guessing -// which one a given controller version actually returns. -func decodeListResponse[T any](path string, body []byte) ([]T, error) { - trimmed := bytes.TrimSpace(body) - if len(trimmed) == 0 { - return nil, nil - } - - if trimmed[0] == '{' { - var envelope struct { - Data []T `json:"data"` - } - if err := json.Unmarshal(trimmed, &envelope); err != nil { - return nil, fmt.Errorf("vManage %s: failed to parse envelope response: %w", path, err) - } - return envelope.Data, nil - } - - var items []T - if err := json.Unmarshal(trimmed, &items); err != nil { - return nil, fmt.Errorf("vManage %s: failed to parse response: %w", path, err) - } - return items, nil -} - -// decodeListResponseWithRaw parses body exactly like decodeListResponse -// into []T, and additionally decodes the same body a second time into -// each item's own raw json.RawMessage (json.RawMessage's UnmarshalJSON -// just captures the original bytes, so this is a second cheap decode -// pass, not a second HTTP round-trip) used only when -// --include-raw-body is requested (see wantRawBody in vmanage.go), so -// a field this producer doesn't model yet is never silently lost. -func decodeListResponseWithRaw[T any](path string, body []byte) ([]T, []json.RawMessage, error) { - items, err := decodeListResponse[T](path, body) - if err != nil { - return nil, nil, err - } - raws, err := decodeListResponse[json.RawMessage](path, body) - if err != nil { - return nil, nil, err - } - return items, raws, nil -} - -// flexString unmarshals a JSON string or a bare JSON number into a Go -// string. vManage's OpenAPI spec documents fields like mtu/speed-mbps -// as quoted strings (e.g. "1500"), but some controllers return -// speed-mbps as a bare JSON number instead which a string-typed -// struct field rejects outright, failing the whole response's -// unmarshal and silently dropping every interface for the device, not -// just the one field. flexString tolerates either representation so -// one inconsistently-typed field can't take out the entire response. -type flexString string - -func (f *flexString) UnmarshalJSON(data []byte) error { - if len(data) > 0 && data[0] == '"' { - var s string - if err := json.Unmarshal(data, &s); err != nil { - return err - } - *f = flexString(s) - return nil - } - *f = flexString(bytes.TrimSpace(data)) - return nil -} - -// Interface is the subset of the GET /dataservice/device/interface -// response fields (tag "Monitoring - Interface") this producer maps to -// OSIRIS network.router.port/network.interface resources. Field names -// taken verbatim from the vManage OpenAPI spec's documented example. -// The endpoint returns one row per (interface, address-family) pair -// af-type distinguishes an interface's IPv4 row from its IPv6 row -// see selectIPv4Interfaces in transform_interfaces.go for how these -// are deduplicated. Mtu/SpeedMbps use flexString (not string) since -// vManage does not consistently type these as JSON strings across -// controller versions/platforms, see flexString's doc comment. -// Description is absent from the vManage OpenAPI spec's own documented -// example for this endpoint, but is present on real interfaces in -// practice, not every interface sets it, an unconfigured one simply -// omits the field. -type Interface struct { - VDeviceHostName string `json:"vdevice-host-name"` - IfName string `json:"ifname"` - AFType string `json:"af-type"` - IPAddress string `json:"ip-address"` - HWAddr string `json:"hwaddr"` - IfAdminStatus string `json:"if-admin-status"` - IfOperStatus string `json:"if-oper-status"` - VPNID string `json:"vpn-id"` - PortType string `json:"port-type"` - Duplex string `json:"duplex"` - Mtu flexString `json:"mtu"` - SpeedMbps flexString `json:"speed-mbps"` - EncapType string `json:"encap-type"` - Description string `json:"description"` -} - -// GetDeviceInterfaces fetches per-device interface details via GET -// /dataservice/device/interface?deviceId={system-ip}, used for the base -// network.interface resource (MAC, private IP, admin/oper state). -func (c *Client) GetDeviceInterfaces(systemIP string) ([]Interface, error) { - ifaces, _, err := c.GetDeviceInterfacesWithRaw(systemIP) - return ifaces, err -} - -// GetDeviceInterfacesWithRaw is GetDeviceInterfaces plus each row's own -// raw JSON object, for --include-raw-body (see wantRawBody in -// vmanage.go). -func (c *Client) GetDeviceInterfacesWithRaw(systemIP string) ([]Interface, []json.RawMessage, error) { - path := "/dataservice/device/interface?deviceId=" + url.QueryEscape(systemIP) - body, err := c.get(path) - if err != nil { - return nil, nil, err - } - return decodeListResponseWithRaw[Interface]("/dataservice/device/interface", body) -} - -// WANInterface is the subset of the GET -// /dataservice/device/control/waninterface response fields (tag -// "Monitoring - WAN Interface") used to enrich a transport-facing -// network.interface resource with its public/NAT address and color. -// Field names taken verbatim from the vManage OpenAPI spec's documented -// example. -type WANInterface struct { - VDeviceHostName string `json:"vdevice-host-name"` - Interface string `json:"interface"` - Color string `json:"color"` - PrivateIP string `json:"private-ip"` - PublicIP string `json:"public-ip"` - NatType string `json:"nat-type"` - OperationState string `json:"operation-state"` -} - -// GetWANInterfaces fetches per-device WAN transport details via GET -// /dataservice/device/control/waninterface?deviceId={system-ip}, joined -// back to GetDeviceInterfaces results by interface name in -// transform_interfaces.go. -func (c *Client) GetWANInterfaces(systemIP string) ([]WANInterface, error) { - wanIfaces, _, err := c.GetWANInterfacesWithRaw(systemIP) - return wanIfaces, err -} - -// GetWANInterfacesWithRaw is GetWANInterfaces plus each row's own raw -// JSON object, for --include-raw-body (see wantRawBody in vmanage.go). -func (c *Client) GetWANInterfacesWithRaw(systemIP string) ([]WANInterface, []json.RawMessage, error) { - path := "/dataservice/device/control/waninterface?deviceId=" + url.QueryEscape(systemIP) - body, err := c.get(path) - if err != nil { - return nil, nil, err - } - return decodeListResponseWithRaw[WANInterface]("/dataservice/device/control/waninterface", body) -} - -// SiteTunnel is a single SD-WAN tunnel entry within a SiteCircuit, as -// returned by GET /dataservice/topology/monitor/site/{siteId}. Name -// encodes both tunnel endpoints as "{ipA}:{colorA}-{ipB}:{colorB}" - -// see parseTunnelEndpoints in transform_connections.go. -type SiteTunnel struct { - Name string `json:"name"` - Health string `json:"health"` - State string `json:"state"` - VqoeScore float64 `json:"vqoe_score"` -} - -// SiteCircuit is a per-color transport circuit within a -// SiteTopologyDevice. -type SiteCircuit struct { - Color string `json:"color"` - SystemIP string `json:"system_ip"` - CircuitHealth string `json:"circuit-health"` - Tunnels []SiteTunnel `json:"tunnels"` -} - -// SiteTopologyDevice is a single device entry within a GET -// /dataservice/topology/monitor/site/{siteId} response. Field names -// taken verbatim from the vManage OpenAPI spec's documented example. -type SiteTopologyDevice struct { - DeviceID string `json:"device-id"` - DeviceHealth string `json:"device-health"` - Circuits []SiteCircuit `json:"circuits"` -} - -// GetSiteTopologyMonitor fetches SD-WAN tunnel/circuit data for a site -// via GET /dataservice/topology/monitor/site/{siteId}. -func (c *Client) GetSiteTopologyMonitor(siteID string) ([]SiteTopologyDevice, error) { - devices, _, err := c.GetSiteTopologyMonitorWithRaw(siteID) - return devices, err -} - -// GetSiteTopologyMonitorWithRaw is GetSiteTopologyMonitor plus each -// device entry's own raw JSON object, for --include-raw-body (see -// wantRawBody in vmanage.go). -func (c *Client) GetSiteTopologyMonitorWithRaw(siteID string) ([]SiteTopologyDevice, []json.RawMessage, error) { - path := "/dataservice/topology/monitor/site/" + url.PathEscape(siteID) - body, err := c.get(path) - if err != nil { - return nil, nil, err - } - return decodeListResponseWithRaw[SiteTopologyDevice]("/dataservice/topology/monitor/site", body) -} - -// OMPLink is a single global OMP control-plane connection pair, as -// returned by GET /dataservice/device/omp/links. Unlike most -// /dataservice/device/* endpoints this is not scoped to a single -// deviceId, one call covers every device the credential can see. -// Field names taken verbatim from the vManage OpenAPI spec's documented -// example. -type OMPLink struct { - State string `json:"state"` - ADeviceID string `json:"adeviceId"` - BDeviceID string `json:"bdeviceId"` - ASystemIP string `json:"asystem-ip"` - BSystemIP string `json:"bsystem-ip"` - ASiteID string `json:"asite-id"` - BSiteID string `json:"bsite-id"` - AHostName string `json:"ahost-name"` - BHostName string `json:"bhost-name"` - APersonality string `json:"apersonality"` - BPersonality string `json:"bpersonality"` -} - -// ompLinkStates are the two values GetOMPLinks queries for. The -// endpoint's "state" query parameter is required, but the vManage -// OpenAPI spec never documents its accepted values, no enum, no -// component schema, just the free-text description "Connection state". -// Only "up" and "down" appear in the spec's own examples; "all" is not -// documented as accepted, so this queries both states explicitly and -// merges the results rather than gambling on an unverified value. -var ompLinkStates = []string{"up", "down"} - -// GetOMPLinks fetches the global OMP control-plane peering list via GET -// /dataservice/device/omp/links, once per state in ompLinkStates -// (merged). A failure on either call returns immediately, "some -// states, silently incomplete" is worse than a clear error for data -// meant to represent the full OMP peering topology. -func (c *Client) GetOMPLinks() ([]OMPLink, error) { - var links []OMPLink - for _, state := range ompLinkStates { - body, err := c.get("/dataservice/device/omp/links?state=" + url.QueryEscape(state)) - if err != nil { - return nil, err - } - batch, err := decodeListResponse[OMPLink]("/dataservice/device/omp/links", body) - if err != nil { - return nil, err - } - links = append(links, batch...) - } - return links, nil -} - -// OMPPeer is a single OMP peer entry for one device, as returned by GET -// /dataservice/device/omp/peers?deviceId={system-ip}, typically a WAN -// edge's control-plane sessions to its vsmart/vbond controllers. Field -// names taken verbatim from the vManage OpenAPI spec's documented -// example. -type OMPPeer struct { - VDeviceHostName string `json:"vdevice-host-name"` - Peer string `json:"peer"` - Type string `json:"type"` - State string `json:"state"` -} - -// GetOMPPeers fetches a device's OMP peer list via GET -// /dataservice/device/omp/peers?deviceId={system-ip}. -func (c *Client) GetOMPPeers(systemIP string) ([]OMPPeer, error) { - peers, _, err := c.GetOMPPeersWithRaw(systemIP) - return peers, err -} - -// GetOMPPeersWithRaw is GetOMPPeers plus each peer's own raw JSON -// object, for --include-raw-body (see wantRawBody in vmanage.go). -func (c *Client) GetOMPPeersWithRaw(systemIP string) ([]OMPPeer, []json.RawMessage, error) { - path := "/dataservice/device/omp/peers?deviceId=" + url.QueryEscape(systemIP) - body, err := c.get(path) - if err != nil { - return nil, nil, err - } - return decodeListResponseWithRaw[OMPPeer]("/dataservice/device/omp/peers", body) -} - -// GetSiteName fetches the human-readable site name for a site-id via -// GET /dataservice/topology/device/site/{siteId}. Unlike GetDevices, -// this endpoint's response shape is not documented in the vManage -// OpenAPI spec (the schema is a bare, empty {"type": "object"}); the -// {"site_name": "...", "data": [...]} shape used here is the observed -// response. Callers should treat this as best-effort (see -// siteDisplayName in sites_select.go): some credentials may lack -// access to this endpoint, and a failure here should never block -// collection. -func (c *Client) GetSiteName(siteID string) (string, error) { - c.throttleSiteName() - body, err := c.get("/dataservice/topology/device/site/" + url.PathEscape(siteID)) - if err != nil { - return "", err - } - - var parsed struct { - SiteName string `json:"site_name"` - } - if err := json.Unmarshal(body, &parsed); err != nil { - return "", fmt.Errorf("vManage /dataservice/topology/device/site/%s: failed to parse response: %w", siteID, err) - } - return parsed.SiteName, nil -} - -// Tenant is an opaque vManage tenant record. The spec documents -// GET /dataservice/tenant as returning an array of untyped objects (no -// field names documented anywhere), so tenants are kept as raw maps -// and only used for best-effort metadata.scope population, never for -// switching/iterating into a tenant's own device inventory (see -// package doc comment in vmanage.go). -type Tenant map[string]any - -// ListTenants fetches the tenant list via GET /dataservice/tenant, for -// metadata.scope population only. Per the spec's documented example, -// this endpoint returns a bare JSON array (unlike GetDevices, whose -// envelope shape is ambiguous). -func (c *Client) ListTenants() ([]Tenant, error) { - body, err := c.get("/dataservice/tenant") - if err != nil { - return nil, err - } - - trimmed := bytes.TrimSpace(body) - if len(trimmed) == 0 { - return nil, nil - } - - var tenants []Tenant - if err := json.Unmarshal(trimmed, &tenants); err != nil { - return nil, fmt.Errorf("vManage /dataservice/tenant: failed to parse response: %w", err) - } - return tenants, nil -} - -// tenantLabel returns a best-effort display string for a tenant -// record, trying the commonly used identity keys in priority order -// since the spec does not document any field names for this schema. -func tenantLabel(t Tenant) string { - for _, key := range []string{"name", "tenantName", "orgName", "tenantId", "id"} { - if v, ok := t[key]; ok { - switch s := v.(type) { - case string: - if s != "" { - return s - } - case float64: - return strconv.FormatFloat(s, 'f', -1, 64) - } - } - } - return "" -} - -// truncateBody returns the first 200 bytes of a response body for error messages. -func truncateBody(body []byte) string { - if len(body) > 200 { - return string(body[:200]) + "..." - } - return string(body) -} diff --git a/osiris/network/cisco/vmanage/config.go b/osiris/network/cisco/vmanage/config.go deleted file mode 100644 index 54bb52d..0000000 --- a/osiris/network/cisco/vmanage/config.go +++ /dev/null @@ -1,122 +0,0 @@ -// config.go - Configuration types for the Cisco Catalyst SD-WAN Manager -// (vManage) OSIRIS JSON producer. -// -// vManage is a single WAN-overlay controller: one login authenticates -// against one controller (reachable at a customer-specific domain such -// as vmanage.example.com) which manages many WAN edge sites. A single -// vManage run fans out into many documents: one per WAN edge site, -// grouped by device site-id. -// -// Output hierarchy (see OutputPath below), one document per site -// regardless of how many sites the controller reports: -// -// / -// / -// cisco-vmanage--.json -// -// defaults to defaultOutputDir when --output is not given. -// A fixed, non-timestamped directory name lets a re-run from the same -// working directory (or the same explicit --output) naturally reuse it: -// os.MkdirAll is a no-op against an existing directory, so a second run -// adds each site's new timestamped file alongside the previous ones -// instead of scattering a new dated directory per run. -// -// vManage's device inventory (GET /dataservice/device) has no -// human-readable site name field, only a numeric site-id, the display -// name used here and in metadata.scope.sites is resolved separately via -// GET /dataservice/topology/device/site/{siteId} (see sites_select.go); -// OutputPath falls back to the "unsited" segment when no name is -// available (empty siteName), the same fallback used for devices with -// no site-id at all. -// -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: -// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco -// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification - -package vmanage - -import ( - "fmt" - "path/filepath" - "strings" -) - -// defaultOutputDir is the --output value used when the flag is omitted. -const defaultOutputDir = "osirisjson-cisco-vmanage" - -// defaultSiteNameRateLimit is the --site-name-rate value used when the -// flag is omitted: 10 requests/second. vManage's rate limit is -// typically shared across every consumer polling the same controller -// (monitoring systems, other automation, not just this producer), so -// this defaults conservatively, tune with --site-name-rate based on -// your own environment's actual headroom, see client.go's -// throttleSiteName. -const defaultSiteNameRateLimit = 10 - -// unsitedSegment is the OutputPath/scope fallback for devices vManage -// has not assigned to a site (empty site-id). -const unsitedSegment = "unclaimed" - -// Config carries runtime settings resolved from CLI flags. -type Config struct { - Host string // controller FQDN or IP. - Port int // 0 = use defaultPort. - Username string - Password string - InsecureTLS bool // --insecure: skip TLS verify. - - OutputDir string - SafeFailureMode string - - // Purpose is the OSIRIS JSON spec section 13.1.3 output grade. - Purpose string - - // SiteFilter is the explicit --site value (site-id list, unsitedSegment - // selects devices with no site-id). Empty when --site was not given. - SiteFilter []string - // AllSites is --all: collect every discovered site non-interactively, - // skipping the picker. Mutually exclusive with SiteFilter. - AllSites bool - - // SiteNameRateLimit caps requests/second for bulk site-name - // resolution (see client.go's throttleSiteName), independent of - // worker concurrency. Defaults to defaultSiteNameRateLimit. - SiteNameRateLimit int - - // IncludeRawBody attaches each collected endpoint's full, - // unmodified API response body under - // extensions["osiris.cisco.vmanage"] on the owning device resource - // (see wantRawBody in vmanage.go), a lossless fallback for fields - // this producer doesn't model yet. Only takes effect when - // '--purpose audit' flag is declared. - IncludeRawBody bool -} - -// OutputPath returns the hierarchical output path for one site's -// document: //cisco-vmanage--.json -// -// Empty site name or no site-id at all, or a site-id whose display name -// could not be resolved) maps to the "unclaimed" segment. The directory -// is not required to be new: os.MkdirAll (called by the caller before -// writing) is a no-op if already exists, so this simply -// adds the new timestamped file alongside whatever is already there. -func OutputPath(outputDir, timestamp, siteName string) string { - segment := sanitizeFilenameSegment(siteName) - if segment == "" { - segment = unsitedSegment - } - filename := fmt.Sprintf("cisco-vmanage-%s-%s.json", timestamp, segment) - return filepath.Join(outputDir, segment, filename) -} - -// sanitizeFilenameSegment replaces characters that are unsafe in a -// filename (on any of Linux/macOS/Windows) with "-". -func sanitizeFilenameSegment(s string) string { - return strings.Map(func(r rune) rune { - switch r { - case '/', '\\', ':', '*', '?', '"', '<', '>', '|', ' ': - return '-' - } - return r - }, s) -} diff --git a/osiris/network/cisco/vmanage/transform.go b/osiris/network/cisco/vmanage/transform.go deleted file mode 100644 index e5ad658..0000000 --- a/osiris/network/cisco/vmanage/transform.go +++ /dev/null @@ -1,392 +0,0 @@ -// transform.go - Pure vManage->OSIRIS JSON mapping functions. -// Converts Device records (from GET /dataservice/device) into OSIRIS -// SDK resource types. All functions are stateless: no I/O, no HTTP, -// just data transformation. -// -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: -// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco -// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification - -package vmanage - -import ( - "maps" - "strconv" - "strings" - "time" - - "go.osirisjson.org/producers/pkg/sdk" -) - -// providerName identifies this producer's product line within the -// Cisco vendor namespace (dotted form). -const providerName = "cisco.vmanage" - -// extensionKey namespaces every vManage-specific field placed under a -// resource or connection's extensions block (chapter 8 of OSIRIS-JSON -// specification: vendor-specific data MUST use the -// osiris. prefix convention). -const extensionKey = "osiris.cisco.vmanage" - -// personalityToType maps vManage device "personality" values to OSIRIS -// resource types. -// -// osiris/network/cisco/apic/transform.go already extends the taxonomy -// with "osiris.cisco.controller" for controller-role fabric nodes, -// since OSIRIS-JSON-v1.0 Appendix C.2 has no core network.controller -// type reused here (same osiris.cisco namespace) for the vManage -// control-plane personalities. WAN edges reuse the core network.router. -// -// This is a first pass for producer release 0.1.0 to be extended as new -// personality values are identified. -var personalityToType = map[string]string{ - "vmanage": "osiris.cisco.controller", - "vsmart": "osiris.cisco.controller", - "vbond": "osiris.cisco.controller", - "vedge": "network.router", - "cedge": "network.router", -} - -// TransformDevices converts vManage Device records into OSIRIS -// resources. purpose is "documentation" (default) or "audit" per -// pkg/osirismeta audit adds fields that are stable but higher detail -// (serial_number, certificate validity). Geo-coordinates are not set -// here vManage reports the same latitude/longitude for every device -// at a site, so that data belongs on the site's physical.room group -// (properties.geo_location, OSIRIS-JSON-v1.0 section 6.5.1.1) since the -// device is installed in a room, rather han duplicated per device; -// see TransformSiteGroup. -// health/state_description/connected_manager/last_update/up_since are -// basic device state, not higher-detail data, so they are emitted -// regardless of purpose same tier as site_id/device_groups and the -// top-level state/status fields. -// -// Devices whose personality is not in personalityToType are skipped, -// following apic's nodeRoleToType precedent for unrecognized roles. -// -// id/provider.native_id use deviceNativeKey the hardware serial for -// network.router devices, unconditionally (identity fields are never -// purpose-gated), matching OSIRIS-JSON-v1.0 section 4.1.5 own -// on-premise-network-device example. -// -// provider.site (the resolved site display name) is deliberately not -// set here, OSIRIS-JSON-v1.0 section 7.5.2 own network.router example -// carries site placement under a top-level "location" object, which -// this producer doesn't emit yet (sdk.Resource has no Location field; -// adding one is a shared, cross-producer pkg/sdk change, deferred to a -// future roadmap). The site name is still available at the document -// level via metadata.scope.sites; the raw numeric site-id lives in -// extensions.osiris.cisco.vmanage.site_id. -// -// Returns the resources plus a system-ip -> resource ID index, used by -// the caller to wire interfaces (transform_interfaces.go) and -// same-document connections (transform_connections.go) back to their -// owning device. -func TransformDevices(devices []Device, purpose string) ([]sdk.Resource, map[string]string) { - var resources []sdk.Resource - systemIPToID := make(map[string]string, len(devices)) - - for _, d := range devices { - resType, ok := personalityToType[d.Personality] - if !ok { - continue - } - - key := deviceNativeKey(d, resType) - id := resourceID(key) - - prov := sdk.Provider{ - Name: providerName, - NativeID: key, - Type: d.DeviceModel, - } - - r, err := sdk.NewResource(id, resType, prov) - if err != nil { - continue - } - r.Name = d.HostName - r.Status = mapDeviceStatus(d.Status, d.Reachability) - if d.Reachability != "" { - r.State = d.Reachability - } - - // manufacturer/model/version/management_ip match - // OSIRIS-JSON-v1.0 specification 7.5.2 network.router "Common - // properties" table, manufacturer is a constant since vManage - // only manages Cisco/Viptela hardware; management_ip is - // d.SystemIP, vManage's own management/control-plane address - // for the device. No separate ip_addresses object it would - // just duplicate management_ip with the same single value. - props := map[string]any{"manufacturer": "Cisco"} - if d.DeviceModel != "" { - props["model"] = d.DeviceModel - } - if d.Version != "" { - props["version"] = d.Version - } - if ip := sdk.NormalizeIP(d.SystemIP); ip != "" { - props["management_ip"] = ip - } - if purpose == "audit" { - if d.BoardSerial != "" { - props["serial_number"] = d.BoardSerial - } - } - r.Properties = props - - ext := map[string]any{} - if d.SiteID != "" { - ext["site_id"] = d.SiteID - } - if len(d.DeviceGroups) > 0 { - ext["device_groups"] = d.DeviceGroups - } - if resType == "network.router" && d.BoardSerial != "" && d.UUID != "" { - ext["chassis_number"] = d.UUID - } - if d.HealthState != "" { - ext["health"] = d.HealthState - } - if d.StateDescription != "" { - ext["state_description"] = d.StateDescription - } - if len(d.ConnectedVManages) > 0 { - ext["connected_manager"] = d.ConnectedVManages - } - if lastUpdate := epochMillisToRFC3339(d.LastUpdated); lastUpdate != "" { - ext["last_update"] = lastUpdate - } - if upSince := epochMillisToRFC3339(d.UptimeDate); upSince != "" { - ext["up_since"] = upSince - } - if purpose == "audit" { - if d.CertificateValidity != "" { - ext["certificate_validity"] = d.CertificateValidity - } - } - if len(ext) > 0 { - r.Extensions = map[string]any{extensionKey: ext} - } - - resources = append(resources, r) - if d.SystemIP != "" { - systemIPToID[d.SystemIP] = id - } - } - - return resources, systemIPToID -} - -// GroupDevicesBySiteID partitions devices by their site-id, for the -// per-site document split in vmanage.go. Devices with no site-id are -// grouped under the "" key (see unsitedSegment in config.go). -func GroupDevicesBySiteID(devices []Device) map[string][]Device { - groups := make(map[string][]Device) - for _, d := range devices { - groups[d.SiteID] = append(groups[d.SiteID], d) - } - return groups -} - -// TransformSiteGroup builds the "physical.room" group for one site's -// document, with membership set to every device resource (router or -// controller) TransformDevices produced for that site. Interfaces are -// not added directly their "contains" connection to the owning -// device already implies site membership transitively. -// -// physical.room (OSIRIS-JSON-v1.0 section 7.6.5), not logical.site -// (section 6.2.3) or a coarser physical.* type: a WAN edge site is a -// real single physical location with its own coordinates the -// "location-based and facility-based" family 6.2.3 describes physical.* -// for, not the organizational/conceptual grouping logical.* is meant -// for (6.3.2's own logical.site example is "AWS us-east-1", an -// hyperscaler region spanning many facilities, not one place with one -// lat/long). Within physical.*, vManage WAN edges are network equipment -// installed in a rack that is not necessarily inside a datacenter or -// even a dedicated building often a network closet or equipment room in -// a small office or factory. 7.6.5's own physical.room definition names -// exactly that ("network closets", "equipment rooms"), a closer fit -// than physical.building/datacenter (which describe whole structures/ -// campuses) or physical.rack which will fit perfectly but unfortunately -// vManage still reports no rack-level detail at all. -// -// This stays a lightweight group (membership + geo_location only), not -// the fuller physical.room resource shape 7.6.5's own example shows -// (location, room_number, room_sqft, room_type, cooling_capacity_tons) -// vManage's device data has none of that, and inventing placeholder -// values would misrepresent absent data as real. -// -// siteID is the raw numeric site-id ("" for the unclaimed fallback -// group, using unsitedSegment as the boundary token instead). siteName -// is the resolved display name, used as the group's Name when -// available. ok is false when there are no device resources to group -// (nothing to add to the document). -// -// devices is the site's device list, used only to source -// properties.geo_location: vManage reports the same latitude/longitude -// for every device at a site (confirmed against a real site's -// devices), so the first resolvable pair is used rather than repeating -// identical coordinates per device. geo_location is not purpose-gated -// a site's coordinates are not sensitive the way a serial number or -// certificate validity is, so it is emitted regardless of --purpose. -func TransformSiteGroup(siteID, siteName string, devices []Device, deviceResourceIDs []string) (group sdk.Group, ok bool) { - if len(deviceResourceIDs) == 0 { - return sdk.Group{}, false - } - - boundaryToken := siteID - if boundaryToken == "" { - boundaryToken = unsitedSegment - } - gid := sdk.GroupID(sdk.GroupIDInput{Type: "physical.room", BoundaryToken: boundaryToken}) - - g, err := sdk.NewGroup(gid, "physical.room") - if err != nil { - return sdk.Group{}, false - } - g.Name = siteName - if g.Name == "" { - g.Name = unsitedSegment - } - g.AddMembers(deviceResourceIDs...) - - for _, d := range devices { - lat, latOK := toFloat(d.Latitude) - lon, lonOK := toFloat(d.Longitude) - if latOK && lonOK { - g.Properties = map[string]any{ - "geo_location": map[string]any{ - "latitude": lat, - "longitude": lon, - }, - } - break - } - } - - return g, true -} - -// mapDeviceStatus converts vManage status/reachability into an OSIRIS -// status enum value following OSIRIS JSON section 6.1.3 status field -// (active, inactive, degraded, retired, unknown). -// vManage's own status enum is {error, warning, normal, new}; this is -// a first pass, pending validation against a wider range of devices. -func mapDeviceStatus(status, reachability string) string { - if reachability == "unreachable" { - return "inactive" - } - switch status { - case "normal": - return "active" - case "error", "warning": - return "degraded" - case "new": - return "unknown" - default: - return "unknown" - } -} - -// epochMillisToRFC3339 converts a vManage epoch-milliseconds timestamp -// (e.g. "lastupdated", "uptime-date") to an RFC3339 UTC string, or "" -// for an unset (zero/negative) value. -func epochMillisToRFC3339(ms int64) string { - if ms <= 0 { - return "" - } - return sdk.NormalizeRFC3339UTC(time.UnixMilli(ms)) -} - -// toFloat converts a decoded JSON value (string or float64) to a -// float64, handling the spec's own documented example mixing a string -// latitude with a numeric longitude for the same device object. -func toFloat(v any) (float64, bool) { - switch n := v.(type) { - case float64: - return n, true - case string: - f, err := strconv.ParseFloat(n, 64) - if err != nil { - return 0, false - } - return f, true - default: - return 0, false - } -} - -// deviceNativeKey picks the native-ID key for a device resource: -// board-serial for network.router devices, when available a real -// hardware serial, unlike "uuid", which vManage does not populate as -// an actual UUID for vEdge/cEdge platforms but as a -// "-" string instead (e.g. -// "C8200L-1N-4T-S123456789L"). That string is kept under -// extensions.chassis_number instead (see TransformDevices) rather than -// used as the resource identity. Falls back to uuid, then deviceId, -// when no serial is available - the fallback path controller -// personalities (vmanage/vsmart/vbond) always take, since the serial -// substitution only applies to resType == "network.router". -func deviceNativeKey(d Device, resType string) string { - if resType == "network.router" && d.BoardSerial != "" { - return d.BoardSerial - } - if d.UUID != "" { - return d.UUID - } - return d.DeviceID -} - -// setExtension merges a single key into a resource's -// extensions[osiris.cisco.vmanage] map, preserving whatever else is -// already there (e.g. TransformDevices' own site_id/health fields) -// instead of replacing it used by the --include-raw-body attachment -// in vmanage.go (see wantRawBody) so raw-body keys never clobber -// fields a transform function already set, regardless of call order. -func setExtension(r *sdk.Resource, key string, value any) { - if r.Extensions == nil { - r.Extensions = map[string]any{} - } - ext, _ := r.Extensions[extensionKey].(map[string]any) - merged := make(map[string]any, len(ext)+1) - maps.Copy(merged, ext) - merged[key] = value - r.Extensions[extensionKey] = merged -} - -// resourceID builds a namespaced native-ID resource identifier -// OSIRIS-JSON-v1.0 section 2.1.2, strategy 2: "Namespaced native -// ID ::"), preferred here over a deterministic hash since -// vManage devices and interfaces always carry a stable native -// identifier (device serial/uuid/deviceId, see deviceNativeKey, or a -// device-key + interface-name composite for sub-resources see -// resourceKey). -func resourceID(nativeID string) string { - return providerName + "::" + nativeID -} - -// resourceKey builds the composite native ID for a device sub-resource. -func resourceKey(deviceKey, name string) string { - return deviceKey + "-" + name -} - -// stripCIDRHost returns the host portion of a CIDR-form address -// ("192.0.2.20/24" -> "192.0.2.20"), normalized via sdk.NormalizeIP. -// vManage's /dataservice/device/interface response encodes ip-address -// as host/prefix; returns "" for empty, "-" or "0.0.0.0" (both observed -// in responses as vManage's own placeholders for "no address -// configured" on an interface not a real address, and not private -// just because it fails an RFC 1918 check) or unparseable input. -func stripCIDRHost(s string) string { - if s == "" || s == "-" || s == "0.0.0.0" { - return "" - } - if idx := strings.IndexByte(s, '/'); idx >= 0 { - s = s[:idx] - } - if s == "0.0.0.0" { - return "" - } - return sdk.NormalizeIP(s) -} diff --git a/osiris/network/cisco/vmanage/transform_connections.go b/osiris/network/cisco/vmanage/transform_connections.go deleted file mode 100644 index 07ccaab..0000000 --- a/osiris/network/cisco/vmanage/transform_connections.go +++ /dev/null @@ -1,209 +0,0 @@ -// transform_connections.go - SD-WAN tunnel and OMP control-plane -// peering connection transforms. -// -// vmanage.go writes one OSIRIS JSON document per site (grouped by -// device site-id). OSIRIS-JSON-v1.0 section 2.2.3 requires a -// connection's source and target to both resolve within the same -// document, so every function here only emits a connection when both -// endpoints are already present in the current site's resource index -// a peer belonging to a different site is silently skipped (logged by -// the caller, not here, since these are pure transform functions with -// no I/O), never fabricated as a stub. See CHANGELOG.md's "Known -// limitations". -// -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: -// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco -// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification - -package vmanage - -import ( - "regexp" - "strings" - - "go.osirisjson.org/producers/pkg/sdk" -) - -// tunnelNameRe parses a GET /dataservice/topology/monitor/site/{siteId} -// tunnel "name" field: "{ipA}:{colorA}-{ipB}:{colorB}". colorA/colorB -// are matched non-greedily since real vManage color names commonly -// contain hyphens themselves (e.g. "biz-internet", "public-internet") - -// a naive strings.Split on "-" would misparse those. -var tunnelNameRe = regexp.MustCompile(`^(\d{1,3}(?:\.\d{1,3}){3}):([a-z0-9-]+?)-(\d{1,3}(?:\.\d{1,3}){3}):([a-z0-9-]+)$`) - -// parseTunnelEndpoints splits a tunnel name into its two -// "{system-ip}:{color}" endpoint keys, matching the index keys -// TransformInterfaces builds in its returned tunnelIndex. -func parseTunnelEndpoints(name string) (keyA, keyB string, ok bool) { - m := tunnelNameRe.FindStringSubmatch(name) - if m == nil { - return "", "", false - } - return m[1] + ":" + m[2], m[3] + ":" + m[4], true -} - -// TransformTunnels converts GET -// /dataservice/topology/monitor/site/{siteId} circuit/tunnel data into -// network.vpn connections between the two WAN-transport interfaces the -// tunnel runs over. ifaceIndex is the merged "{system-ip}:{color}" -> -// interface resource ID index from every device's TransformInterfaces -// call for the current site. -func TransformTunnels(devices []SiteTopologyDevice, ifaceIndex map[string]string) []sdk.Connection { - var connections []sdk.Connection - seen := make(map[string]bool) - - for _, dev := range devices { - for _, circuit := range dev.Circuits { - for _, tunnel := range circuit.Tunnels { - keyA, keyB, ok := parseTunnelEndpoints(tunnel.Name) - if !ok { - continue - } - sourceID, okA := ifaceIndex[keyA] - targetID, okB := ifaceIndex[keyB] - if !okA || !okB { - continue - } - - canonicalKey := sdk.ConnectionCanonicalKey(sdk.ConnectionIDInput{ - Type: "network.vpn", - Direction: "bidirectional", - Source: sourceID, - Target: targetID, - }) - connID := sdk.BuildConnectionID(canonicalKey, 16) - if seen[connID] { - continue - } - - conn, err := sdk.NewConnection(connID, "network.vpn", sourceID, targetID) - if err != nil { - continue - } - conn.Name = "SD-WAN Site-to-Site Tunnel" - conn.Status = mapUpDownStatus(tunnel.State) - if tunnel.State != "" { - conn.State = strings.ToLower(tunnel.State) - } - ext := map[string]any{} - if circuit.Color != "" { - ext["color"] = circuit.Color - } - if tunnel.VqoeScore != 0 { - ext["vqoe_score"] = tunnel.VqoeScore - } - if len(ext) > 0 { - conn.Extensions = map[string]any{extensionKey: ext} - } - - connections = append(connections, conn) - seen[connID] = true - } - } - } - - return connections -} - -// TransformOMPLinks converts the global GET -// /dataservice/device/omp/links result into "network" connections -// between two devices' OMP control-plane sessions. systemIPToDeviceID -// is the merged system-ip -> resource ID index built by -// TransformDevices for the current site. -func TransformOMPLinks(links []OMPLink, systemIPToDeviceID map[string]string) []sdk.Connection { - var connections []sdk.Connection - seen := make(map[string]bool) - - for _, link := range links { - sourceID, okA := systemIPToDeviceID[link.ASystemIP] - targetID, okB := systemIPToDeviceID[link.BSystemIP] - if !okA || !okB || sourceID == targetID { - continue - } - - conn, connID, ok := buildOMPConnection(sourceID, targetID, link.State, seen) - if !ok { - continue - } - connections = append(connections, conn) - seen[connID] = true - } - - return connections -} - -// TransformOMPPeers converts one device's GET -// /dataservice/device/omp/peers result into "network" connections to -// its vsmart/vbond controllers. Uses the same canonical-key shape as -// TransformOMPLinks (endpoints sorted for a bidirectional key) so that -// a pair already covered by the global omp/links call collapses onto -// the same connection ID instead of producing a duplicate callers -// should merge and re-dedupe both functions' output (see -// dedupeConnections) when both are used for the same site. -func TransformOMPPeers(deviceResourceID string, peers []OMPPeer, systemIPToDeviceID map[string]string) []sdk.Connection { - var connections []sdk.Connection - seen := make(map[string]bool) - - for _, peer := range peers { - targetID, ok := systemIPToDeviceID[peer.Peer] - if !ok || targetID == deviceResourceID { - continue - } - - conn, connID, ok := buildOMPConnection(deviceResourceID, targetID, peer.State, seen) - if !ok { - continue - } - _ = conn.SetDirection("forward") - connections = append(connections, conn) - seen[connID] = true - } - - return connections -} - -// buildOMPConnection is the shared "network" connection builder for -// TransformOMPLinks and TransformOMPPeers both use a bidirectional -// canonical key (regardless of the emitted connection's own Direction -// field) so the same device pair always resolves to the same -// connection ID across either source. -func buildOMPConnection(sourceID, targetID, state string, seen map[string]bool) (sdk.Connection, string, bool) { - canonicalKey := sdk.ConnectionCanonicalKey(sdk.ConnectionIDInput{ - Type: "network", - Direction: "bidirectional", - Source: sourceID, - Target: targetID, - }) - connID := sdk.BuildConnectionID(canonicalKey, 16) - if seen[connID] { - return sdk.Connection{}, "", false - } - - conn, err := sdk.NewConnection(connID, "network", sourceID, targetID) - if err != nil { - return sdk.Connection{}, "", false - } - conn.Name = "OMP Peering" - conn.Status = mapUpDownStatus(state) - if state != "" { - conn.State = strings.ToLower(state) - } - return conn, connID, true -} - -// dedupeConnections drops connections with a duplicate ID, keeping the -// first occurrence. Used when merging OMP peering connections gathered -// from more than one source (global omp/links plus per-device -// omp/peers can describe the same edge<->controller pair). -func dedupeConnections(conns []sdk.Connection) []sdk.Connection { - seen := make(map[string]bool, len(conns)) - result := make([]sdk.Connection, 0, len(conns)) - for _, c := range conns { - if seen[c.ID] { - continue - } - seen[c.ID] = true - result = append(result, c) - } - return result -} diff --git a/osiris/network/cisco/vmanage/transform_connections_test.go b/osiris/network/cisco/vmanage/transform_connections_test.go deleted file mode 100644 index bc06649..0000000 --- a/osiris/network/cisco/vmanage/transform_connections_test.go +++ /dev/null @@ -1,173 +0,0 @@ -// transform_connections_test.go - Unit tests for tunnel and OMP peering -// connection mapping. -// -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: -// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco -// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification - -package vmanage - -import "testing" - -func TestParseTunnelEndpoints(t *testing.T) { - cases := []struct { - name string - wantA, wantB string - wantOK bool - }{ - {"198.51.100.1:lte-198.51.100.2:lte", "198.51.100.1:lte", "198.51.100.2:lte", true}, - {"203.0.113.1:biz-internet-203.0.113.2:public-internet", "203.0.113.1:biz-internet", "203.0.113.2:public-internet", true}, - {"not-a-valid-tunnel-name", "", "", false}, - } - for _, c := range cases { - gotA, gotB, ok := parseTunnelEndpoints(c.name) - if ok != c.wantOK { - t.Errorf("parseTunnelEndpoints(%q) ok = %v, want %v", c.name, ok, c.wantOK) - continue - } - if !ok { - continue - } - if gotA != c.wantA || gotB != c.wantB { - t.Errorf("parseTunnelEndpoints(%q) = (%q, %q), want (%q, %q)", c.name, gotA, gotB, c.wantA, c.wantB) - } - } -} - -func TestTransformTunnels_ResolvesBothEndpoints(t *testing.T) { - devices := []SiteTopologyDevice{ - { - DeviceID: "TST0000001", - Circuits: []SiteCircuit{ - { - Color: "lte", - SystemIP: "192.0.2.10", - Tunnels: []SiteTunnel{ - {Name: "198.51.100.1:lte-198.51.100.2:lte", State: "Up", VqoeScore: 9}, - }, - }, - }, - }, - } - ifaceIndex := map[string]string{ - "198.51.100.1:lte": "cisco.vmanage::TST0000001-GigabitEthernet1", - "198.51.100.2:lte": "cisco.vmanage::TST0000002-GigabitEthernet1", - } - - connections := TransformTunnels(devices, ifaceIndex) - if len(connections) != 1 { - t.Fatalf("expected 1 connection, got %d", len(connections)) - } - c := connections[0] - if c.Type != "network.vpn" { - t.Errorf("type = %q, want network.vpn", c.Type) - } - if c.Status != "active" || c.State != "up" { - t.Errorf("status/state = %q/%q, want active/up", c.Status, c.State) - } - ext := c.Extensions[extensionKey].(map[string]any) - if ext["color"] != "lte" || ext["vqoe_score"] != float64(9) { - t.Errorf("unexpected extensions: %+v", ext) - } -} - -func TestTransformTunnels_SkipsUnresolvedPeer(t *testing.T) { - devices := []SiteTopologyDevice{ - { - Circuits: []SiteCircuit{ - { - Color: "lte", - SystemIP: "192.0.2.10", - // 198.51.100.99 belongs to different site document - // and is not in ifaceIndex read OSIRIS-JSON-v1.0 section 2.2.3. - Tunnels: []SiteTunnel{{Name: "198.51.100.1:lte-198.51.100.99:lte", State: "Up"}}, - }, - }, - }, - } - ifaceIndex := map[string]string{ - "198.51.100.1:lte": "cisco.vmanage::TST0000001-GigabitEthernet1", - } - - connections := TransformTunnels(devices, ifaceIndex) - if len(connections) != 0 { - t.Fatalf("expected 0 connections for an unresolvable peer, got %d", len(connections)) - } -} - -func TestTransformTunnels_DedupesSymmetricEntries(t *testing.T) { - // The same tunnel appears once under each device's own circuit - // list, in opposite name order. - devices := []SiteTopologyDevice{ - {Circuits: []SiteCircuit{{Color: "lte", SystemIP: "192.0.2.10", Tunnels: []SiteTunnel{{Name: "198.51.100.1:lte-198.51.100.2:lte", State: "Up"}}}}}, - {Circuits: []SiteCircuit{{Color: "lte", SystemIP: "192.0.2.11", Tunnels: []SiteTunnel{{Name: "198.51.100.2:lte-198.51.100.1:lte", State: "Up"}}}}}, - } - ifaceIndex := map[string]string{ - "198.51.100.1:lte": "cisco.vmanage::TST0000001-GigabitEthernet1", - "198.51.100.2:lte": "cisco.vmanage::TST0000002-GigabitEthernet1", - } - - connections := TransformTunnels(devices, ifaceIndex) - if len(connections) != 1 { - t.Fatalf("expected symmetric tunnel entries to dedupe to 1 connection, got %d", len(connections)) - } -} - -func TestTransformOMPLinks_ResolvesBothEndpoints(t *testing.T) { - links := []OMPLink{ - {State: "up", ASystemIP: "192.0.2.10", BSystemIP: "192.0.2.11"}, - } - systemIPToDeviceID := map[string]string{ - "192.0.2.10": "cisco.vmanage::TST0000001", - "192.0.2.11": "cisco.vmanage::TST0000099", - } - - connections := TransformOMPLinks(links, systemIPToDeviceID) - if len(connections) != 1 { - t.Fatalf("expected 1 connection, got %d", len(connections)) - } - if connections[0].Type != "network" { - t.Errorf("type = %q, want network", connections[0].Type) - } -} - -func TestTransformOMPPeers_SkipsUnresolvedAndSelf(t *testing.T) { - peers := []OMPPeer{ - {Peer: "192.0.2.11", State: "up"}, // resolvable - {Peer: "198.51.100.99", State: "up"}, // unresolvable (different site) - {Peer: "192.0.2.10", State: "up"}, // self-loop - } - systemIPToDeviceID := map[string]string{ - "192.0.2.10": "cisco.vmanage::TST0000001", - "192.0.2.11": "cisco.vmanage::TST0000099", - } - - connections := TransformOMPPeers("cisco.vmanage::TST0000001", peers, systemIPToDeviceID) - if len(connections) != 1 { - t.Fatalf("expected 1 connection, got %d", len(connections)) - } - if connections[0].Direction != "forward" { - t.Errorf("direction = %q, want forward", connections[0].Direction) - } -} - -func TestTransformOMPLinksAndPeers_DedupeAcrossSources(t *testing.T) { - links := []OMPLink{ - {State: "up", ASystemIP: "192.0.2.10", BSystemIP: "192.0.2.11"}, - } - peers := []OMPPeer{ - {Peer: "198.51.100.1", State: "up"}, - } - systemIPToDeviceID := map[string]string{ - "192.0.2.10": "cisco.vmanage::TST0000001", - "192.0.2.11": "cisco.vmanage::TST0000099", - } - - linkConns := TransformOMPLinks(links, systemIPToDeviceID) - peerConns := TransformOMPPeers("cisco.vmanage::TST0000001", peers, systemIPToDeviceID) - - merged := dedupeConnections(append(linkConns, peerConns...)) - if len(merged) != 1 { - t.Fatalf("expected omp/links and omp/peers describing the same pair to dedupe to 1 connection, got %d", len(merged)) - } -} diff --git a/osiris/network/cisco/vmanage/transform_interfaces.go b/osiris/network/cisco/vmanage/transform_interfaces.go deleted file mode 100644 index 9566412..0000000 --- a/osiris/network/cisco/vmanage/transform_interfaces.go +++ /dev/null @@ -1,289 +0,0 @@ -// transform_interfaces.go - Interface resource and router-to-interface -// "contains" connection transforms. -// -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: -// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco -// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification - -package vmanage - -import ( - "fmt" - "net" - "strconv" - "strings" - - "go.osirisjson.org/producers/pkg/sdk" -) - -// TransformInterfaces converts one device's interfaces into OSIRIS -// resources plus "contains" connections wiring each one back to -// deviceResourceID, the router/controller resource it belongs to. -// -// deviceResourceType is the owning device's own OSIRIS JSON type -// (personalityToType's value "network.router" or -// "osiris.cisco.controller"): interfaces belonging to a -// "network.router" become OSIRIS-JSON-v1.0 section 7.5.2's -// "network.router.port" (a router port is specifically a router-owned -// interface per that section's definition). -// -// ifaces is the device's GET /dataservice/device/interface rows -// (selectIPv4Interfaces collapses the ipv4/ipv6 address-family row -// pairs the endpoint returns per interface down to one row each). -// wanIfaces is the device's GET -// /dataservice/device/control/waninterface rows, joined back to ifaces -// by interface name, used to enrich WAN-transport interfaces with a -// public/NAT address and SD-WAN color. -// -// Returns the resources, the "contains" connections, and a -// "{system-ip}:{color}" -> interface resource ID index consumed by -// TransformTunnels (transform_connections.go) to resolve SD-WAN tunnel -// endpoints. -func TransformInterfaces(deviceResourceID, deviceResourceType, deviceNativeKey, systemIP string, ifaces []Interface, wanIfaces []WANInterface) ([]sdk.Resource, []sdk.Connection, map[string]string) { - var resources []sdk.Resource - var connections []sdk.Connection - tunnelIndex := make(map[string]string) - - resType := "network.interface" - if deviceResourceType == "network.router" { - resType = "network.router.port" - } - - wanByIfname := make(map[string]WANInterface, len(wanIfaces)) - for _, w := range wanIfaces { - wanByIfname[w.Interface] = w - } - - for _, iface := range selectIPv4Interfaces(ifaces) { - if iface.IfName == "" { - continue - } - nativeID := resourceKey(deviceNativeKey, iface.IfName) - id := resourceID(nativeID) - - prov := sdk.Provider{ - Name: providerName, - NativeID: nativeID, - // The interface's own native identifier (e.g. - // "GigabitEthernet0/0/0") Cisco's interface-class-plus- - // slot/subslot/port naming already doubles as its native - // type within the device, distinct from the generic - // "Router Interface" category string - // OSIRIS-JSON-v1.0 section 7.5.2's own example uses. - Type: iface.IfName, - } - r, err := sdk.NewResource(id, resType, prov) - if err != nil { - continue - } - r.Name = iface.IfName - r.Description = iface.Description - r.Status = mapUpDownStatus(iface.IfOperStatus) - if iface.IfOperStatus != "" { - r.State = strings.ToLower(iface.IfOperStatus) - } - - wan, isWAN := wanByIfname[iface.IfName] - - // Candidate addresses are classified by what they actually are - // (RFC 1918/4193, via net.IP.IsPrivate) rather than trusted by - // which vManage field they came from GET - // /dataservice/device/control/waninterface's "private-ip"/ - // "public-ip" names mean "before NAT" vs "after NAT", not - // "RFC 1918 private" vs "public": a Direct Internet Access - // circuit with no NAT reports the same real, public - // ISP-assigned address in both fields, which would otherwise - // get mislabeled as private_ip. - var candidates []string - if base := stripCIDRHost(iface.IPAddress); base != "" { - candidates = append(candidates, base) - } - if isWAN { - if wp := sdk.NormalizeIP(wan.PrivateIP); wp != "" { - candidates = append(candidates, wp) - } - if wq := sdk.NormalizeIP(wan.PublicIP); wq != "" { - candidates = append(candidates, wq) - } - } - - ipAddrs := map[string]any{} - var privateIPs []string - var publicIP string - seen := make(map[string]bool, len(candidates)) - for _, ip := range candidates { - if seen[ip] { - continue - } - seen[ip] = true - if parsed := net.ParseIP(ip); parsed != nil && parsed.IsPrivate() { - privateIPs = append(privateIPs, ip) - } else { - publicIP = ip - } - } - if len(privateIPs) > 0 { - ipAddrs["private_ip"] = privateIPs - } - if publicIP != "" { - ipAddrs["public_ip"] = publicIP - } - - // interface_name/admin_status/oper_status/speed_mbps/duplex/mtu - // match OSIRIS-JSON-v1.0 section 7.5.2 network.router.port - // "Common properties" table (description is set separately, on - // r.Description, per the OSIRIS-JSON-v1.0 section 4.1.3. - // See the field's own doc comment on Interface in client.go). - // vlan_id is still not included: no vManage endpoint reports a - // VLAN tag for a service-side sub-interface emitting a - // placeholder would misrepresent absent data as a real value. - props := map[string]any{"interface_name": iface.IfName} - if len(ipAddrs) > 0 { - props["ip_addresses"] = ipAddrs - } - if mac := sdk.NormalizeMAC(iface.HWAddr); mac != "" { - props["mac_address"] = mac - } - if iface.IfAdminStatus != "" { - props["admin_status"] = strings.ToLower(iface.IfAdminStatus) - } - if iface.IfOperStatus != "" { - props["oper_status"] = strings.ToLower(iface.IfOperStatus) - } - if speed, ok := parseIntField(string(iface.SpeedMbps)); ok { - props["speed_mbps"] = speed - } - if iface.Duplex != "" { - props["duplex"] = iface.Duplex - } - if mtu, ok := parseIntField(string(iface.Mtu)); ok { - props["mtu"] = mtu - } - if iface.EncapType != "" && iface.EncapType != "null" { - props["encapsulation"] = iface.EncapType - } - if it := interfaceType(iface.PortType); it != "" { - props["interface_type"] = it - } - if iface.VPNID != "" { - // vManage's raw response only ever reports "vpn-id" never - // any form of "vrf" so this is surfaced under vManage's own - // native field name: OSIRIS-JSON-v1.0 network.router.port - // Common Properties table does not document a vrf_id - // property either. - props["vpn_id"] = iface.VPNID - } - r.Properties = props - - if isWAN && wan.Color != "" { - ext := map[string]any{"color": wan.Color} - if wan.NatType != "" { - ext["nat_type"] = wan.NatType - } - r.Extensions = map[string]any{extensionKey: ext} - } - - resources = append(resources, r) - - canonicalKey := sdk.ConnectionCanonicalKey(sdk.ConnectionIDInput{ - Type: "contains", - Direction: "forward", - Source: deviceResourceID, - Target: id, - }) - connID := sdk.BuildConnectionID(canonicalKey, 16) - conn, err := sdk.NewConnection(connID, "contains", deviceResourceID, id) - if err == nil { - conn.Name = fmt.Sprintf("%s -> %s", deviceNativeKey, iface.IfName) - _ = conn.SetDirection("forward") - connections = append(connections, conn) - } - - if isWAN && wan.Color != "" && systemIP != "" { - tunnelIndex[systemIP+":"+wan.Color] = id - } - } - - return resources, connections, tunnelIndex -} - -// selectIPv4Interfaces collapses GET /dataservice/device/interface -// one-row-per-address-family response down to a single row per -// interface name, preferring the af-type=ipv4 row (this producer does -// not model IPv6 addressing yet) and otherwise keeping the first row -// seen. Order of first appearance is preserved. -func selectIPv4Interfaces(ifaces []Interface) []Interface { - byName := make(map[string]Interface, len(ifaces)) - order := make([]string, 0, len(ifaces)) - for _, iface := range ifaces { - existing, seen := byName[iface.IfName] - if !seen { - byName[iface.IfName] = iface - order = append(order, iface.IfName) - continue - } - if existing.AFType != "ipv4" && iface.AFType == "ipv4" { - byName[iface.IfName] = iface - } - } - result := make([]Interface, 0, len(order)) - for _, name := range order { - result = append(result, byName[name]) - } - return result -} - -// parseIntField parses a vManage numeric-string field (e.g. mtu, -// speed_mbps, both returned as strings like "1500") into an int, -// matching OSIRIS-JSON-v1.0 section 7.5.2 integer type for these -// properties. Returns false for empty or non-numeric input. -func parseIntField(s string) (int, bool) { - if s == "" { - return 0, false - } - n, err := strconv.Atoi(s) - if err != nil { - return 0, false - } - return n, true -} - -// interfaceType maps vManage's port-type to the interface_type -// convention shown in OSIRIS-JSON-v1.0 7.5.3 ("primary"/"secondary"): -// "transport" (WAN uplink) is a device's primary interface, "service" -// (LAN-side) is secondary. Unrecognized values return "". -func interfaceType(portType string) string { - switch portType { - case "transport": - return "primary" - case "service": - return "secondary" - default: - return "" - } -} - -// mapUpDownStatus converts a vManage interface admin/oper state string -// into an OSIRIS-JSON-v1.0 section 4.5.2 status enum value. -// Two distinct vocabularies exist depending on platform: -// - classic vEdge (Viptela OS): simple "Up"/"Down". -// - cEdge (IOS-XE, e.g. C8000v/C8200L/ISR/ASR): the IOS-XE -// ietf-interfaces oper-status identity values -// ("if-oper-state-ready", "if-oper-state-no-pass", etc.) passed -// through verbatim - not documented anywhere in the vManage -// OpenAPI spec. -func mapUpDownStatus(state string) string { - switch strings.ToLower(state) { - case "up", "if-oper-state-ready": - return "active" - case "down", "if-oper-state-down", "if-oper-state-lower-layer-down", "if-oper-state-not-present": - return "inactive" - case "if-oper-state-no-pass": - // Administratively/physically up but not passing traffic (e.g. - // a sub-interface whose encapsulation/protocol isn't fully - // negotiated) - a real middle state, not plain up or down. - return "degraded" - default: - return "unknown" - } -} diff --git a/osiris/network/cisco/vmanage/vmanage.go b/osiris/network/cisco/vmanage/vmanage.go deleted file mode 100644 index 2153e79..0000000 --- a/osiris/network/cisco/vmanage/vmanage.go +++ /dev/null @@ -1,522 +0,0 @@ -// Package vmanage implements the Cisco Catalyst SD-WAN Manager -// (vManage) OSIRIS JSON Producer. -// -// A single vManage controller login fans out into many documents: one -// per WAN edge site, grouped by device site-id. It is -// dispatched directly by osiris/network/cisco/cisco.go's Run function. -// -// Multi-tenant (Provider) collection is out of scope for 0.1.0: the -// vManage OpenAPI spec has no documented tenant-switch/session-context -// endpoint, so GET /dataservice/tenant is used only for best-effort -// metadata.scope.accounts population, never to iterate or switch into a -// tenant's own device inventory. -// -// OSIRIS JSON Producer for Cisco SD-WAN Manager (vManage) introduction: -// [OSIRIS-JSON-CISCO]: https://docs.osirisjson.org/osiris-producers/network/cisco -// [OSIRIS-JSON-SPEC]: https://osirisjson.org/en/specification -package vmanage - -import ( - "encoding/json" - "fmt" - "log/slog" - "os" - "path/filepath" - "strings" - - "go.osirisjson.org/producers/osiris/network/cisco/run" - "go.osirisjson.org/producers/pkg/sdk" -) - -const ( - generatorName = "osirisjson-producer-cisco-vmanage" - generatorVersion = "0.1.0" - generatorURL = "https://docs.osirisjson.org/osiris-producers/network/cisco" -) - -// Run is the CLI entry point for the vManage producer. -// It receives the arguments after "vmanage". -func Run(args []string) error { - // Only the long form is checked here: -h is the documented short - // flag for --host (see flags.go), so it must reach ParseFlags - // instead of being intercepted as a help request. This mirrors - // osiris/network/cisco/cisco.go's runSubProducer, which has the - // same -h/--host vs. -h/help ambiguity for apic/nxos/iosxe. - if len(args) > 0 { - switch args[0] { - case "--help": - printHelp() - return nil - case "template": - return runTemplate(args[1:]) - } - } - - cfg, err := ParseFlags(args, promptVisible, run.PromptPassword) - if err != nil { - return err - } - - return runExport(cfg) -} - -// runTemplate writes both --secrets-file shapes, flat -// (cisco-vmanage-secrets.json) and multi-host -// (cisco-vmanage-secrets-multihost.json) via the shared -// run.WriteTemplateFile vmanage has no CSV batch mode, so unlike -// apic/iosxe/nxos it does not call run.GenerateTemplates only the two -// --secrets-file variants apply here, not a CSV template. -func runTemplate(args []string) error { - if len(args) == 0 || (args[0] != "--generate" && args[0] != "-g") { - fmt.Println("Usage: osirisjson-producer cisco vmanage template --generate") - return nil - } - if err := run.WriteTemplateFile("cisco-vmanage-secrets.json", run.CredentialFileTemplate("vmanage.example.com")); err != nil { - return err - } - return run.WriteTemplateFile("cisco-vmanage-secrets-multihost.json", run.CredentialRulesFileTemplate("vmanage01.example.com", "vmanage02.example.com")) -} - -// runExport authenticates once against the controller, fetches the -// full device inventory, partitions it by site-id, and writes one -// OSIRIS JSON document per site into cfg.OutputDir. Per-site write -// failures are logged and skipped; only a fully failed run -// (succeeded == 0) is fatal. -func runExport(cfg *Config) error { - logger := defaultLogger() - - client := NewClient(cfg, logger) - if err := client.Login(cfg.Username, cfg.Password); err != nil { - return fmt.Errorf("vManage authentication failed: %w", err) - } - - // wantRawBody gates attaching each collected endpoint's true, - // unmodified API response body to the owning device resource's - // extensions[osiris.cisco.vmanage] (see setExtension in - // transform.go) a lossless fallback for fields not yet modeled by - // this producer, available in audit purpose only (see - // --include-raw-body). - wantRawBody := cfg.Purpose == "audit" && cfg.IncludeRawBody - - devices, devicesRaw, err := client.GetDevicesWithRaw() - if err != nil { - return fmt.Errorf("fetching device inventory failed: %w", err) - } - var deviceRawByID map[string]json.RawMessage - if wantRawBody { - deviceRawByID = deviceRawIndex(devices, devicesRaw) - } - - // Best-effort only: tenant labels feed metadata.scope.accounts when - // available. A failure here does not abort the run since tenant - // listing may require Provider-level privileges the credential - // doesn't have. - var accounts []string - if tenants, err := client.ListTenants(); err != nil { - logger.Warn("tenant listing failed (continuing without it)", "err", err) - } else { - for _, t := range tenants { - if label := tenantLabel(t); label != "" { - accounts = append(accounts, label) - } - } - } - - // Best-effort, fetched once and reused for every site: GET - // /dataservice/device/omp/links is not scoped to a single device,so - // one call covers every site's OMP peering. TransformOMPLinks only - // emits a connection when both ends resolve within the current - // site's own systemIPToID index (OSIRIS-JSON section 2.2.3), so - // passing the full unfiltered list into each site's transform below - // is safe it naturally narrows to intra-site pairs. - var ompLinks []OMPLink - if links, err := client.GetOMPLinks(); err != nil { - logger.Warn("OMP link listing failed (continuing without OMP peering connections)", "err", err) - } else { - ompLinks = links - } - - outputDir := cfg.OutputDir - if abs, err := filepath.Abs(outputDir); err == nil { - outputDir = abs - } - - groups := GroupDevicesBySiteID(devices) - - // siteNames covers whatever resolveSiteSelection already had to - // resolve (--all and the interactive picker both need every - // discovered site's name; --site's short explicit list does not, - // so siteNames is nil there and the per-site fallback below - // resolves just the few selected sites individually). - selectedSiteIDs, siteNames, err := resolveSiteSelection(cfg, groups, client, logger) - if err != nil { - return fmt.Errorf("resolving site selection: %w", err) - } - logger.Info("site selection resolved", "sites", len(selectedSiteIDs)) - - var succeeded, failed int - var failures []string - for _, siteID := range selectedSiteIDs { - siteDevices := groups[siteID] - - // siteName drives metadata.scope.sites, OutputPath's - // directory/file segment, and (below) every console log line - // for this site resolved once, up front, rather than - // separately per use. Resolved against a site_id-only logger - // since siteName isn't known yet. Not set on individual - // resources (provider.site) see TransformDevices comment. - var siteName string - if siteID != "" { - // Reuse the name resolved during selection when available - // (--all / interactive picker) instead of calling - // GetSiteName every time for the same site-id; only the - // --site path (siteNames == nil) resolve individually here. - // Either way this is best-effort: falls back to the numeric - // site-id itself if the name is unavailable, so it's never - // left empty for a real site. - name, ok := siteNames[siteID] - if !ok { - name = siteDisplayName(client, siteID, logger.With("site_id", siteID)) - } - siteName = name - } - - // Every log line for this site carries both site_id (stable, - // unambiguous correlation key) and site (the resolved display - // name). - log := logger.With("site_id", siteID, "site", siteLabel(siteID, siteName)) - - ctx := sdk.NewContext(&sdk.ProducerConfig{ - SafeFailureMode: cfg.SafeFailureMode, - Purpose: cfg.Purpose, - }) - ctx.Logger = log - - resources, systemIPToID := TransformDevices(siteDevices, cfg.Purpose) - var connections []sdk.Connection - - // Captured before interfaces are appended to resources below, - // so this holds exactly the site's device (router/controller) - // resource IDs the physical.room group's membership - // OSIRIS JSON section 7.6.5. - deviceResourceIDs := make([]string, 0, len(resources)) - for _, r := range resources { - deviceResourceIDs = append(deviceResourceIDs, r.ID) - } - - // deviceResIdx maps each device resource's ID to its position - // in resources stable across the later interface appends below - // (positions are only ever appended past, never reordered), so - // it is safe to compute once here and reuse for every raw-body - // attachment (device object now, per-device interfaces/WAN/OMP - // peers further down the per-device loop). - deviceResIdx := make(map[string]int, len(resources)) - for i, r := range resources { - deviceResIdx[r.ID] = i - } - - if wantRawBody { - for _, d := range siteDevices { - resType, ok := personalityToType[d.Personality] - if !ok { - continue // TransformDevices skipped this device too. - } - raw, ok := deviceRawByID[d.DeviceID] - if !ok { - continue - } - if idx, ok := deviceResIdx[resourceID(deviceNativeKey(d, resType))]; ok { - setExtension(&resources[idx], "raw", raw) - } - } - } - - // Per-device interfaces (contains connections to their owning - // router/controller) and OMP peers. Sequential per device: a - // site's own edge count is small, unlike the multi-hundred-site - // count defaultSiteNameRateLimit was built for (see config.go) - // no bounded-concurrency worker pool needed here. Any single - // device/endpoint failure is logged and skipped, never aborts - // the site's document. - // - // Every stage below logs an Info line on success and a Warn - // line on failure, so a healthy run still shows visible - // progress between "site selection resolved" and "Saved to ...". - deviceCount := 0 - for _, d := range siteDevices { - if d.SystemIP != "" { - deviceCount++ - } - } - if deviceCount > 0 { - log.Info("collecting device interfaces and connections", "devices", deviceCount) - } - - ifaceIndex := make(map[string]string) // "{system-ip}:{color}" -> interface resource ID, merged across the site's devices. - var ompPeerConns []sdk.Connection - for _, d := range siteDevices { - if d.SystemIP == "" { - continue - } - deviceResourceID, ok := systemIPToID[d.SystemIP] - if !ok { - // Personality not in personalityToType - // TransformDevices already skipped this device. - continue - } - deviceResourceType := personalityToType[d.Personality] - deviceKey := deviceNativeKey(d, deviceResourceType) - dlog := log.With("device", d.HostName) - - ifaces, ifacesRaw, err := client.GetDeviceInterfacesWithRaw(d.SystemIP) - if err != nil { - dlog.Warn("interface listing failed (continuing without this device's interfaces)", "err", err) - continue - } - wanIfaces, wanIfacesRaw, err := client.GetWANInterfacesWithRaw(d.SystemIP) - if err != nil { - dlog.Warn("WAN interface listing failed (continuing with base interface data only)", "err", err) - } - - ifaceResources, containsConns, deviceTunnelIndex := TransformInterfaces(deviceResourceID, deviceResourceType, deviceKey, d.SystemIP, ifaces, wanIfaces) - resources = append(resources, ifaceResources...) - connections = append(connections, containsConns...) - for k, v := range deviceTunnelIndex { - ifaceIndex[k] = v - } - dlog.Info("device interfaces collected", "interfaces", len(ifaceResources)) - - // Raw endpoinmt bodies used for development attach to the - // owning device resource, not a separate per-interface - // resource. - if wantRawBody { - if idx, ok := deviceResIdx[deviceResourceID]; ok { - if len(ifacesRaw) > 0 { - setExtension(&resources[idx], "interfaces_raw", ifacesRaw) - } - if len(wanIfacesRaw) > 0 { - setExtension(&resources[idx], "wan_interfaces_raw", wanIfacesRaw) - } - } - } - - peers, peersRaw, err := client.GetOMPPeersWithRaw(d.SystemIP) - if err != nil { - dlog.Warn("OMP peer listing failed (continuing without this device's OMP peering)", "err", err) - continue - } - ompPeerConns = append(ompPeerConns, TransformOMPPeers(deviceResourceID, peers, systemIPToID)...) - if wantRawBody && len(peersRaw) > 0 { - if idx, ok := deviceResIdx[deviceResourceID]; ok { - setExtension(&resources[idx], "omp_peers_raw", peersRaw) - } - } - } - - ompConns := dedupeConnections(append(TransformOMPLinks(ompLinks, systemIPToID), ompPeerConns...)) - if len(ompConns) > 0 { - log.Info("OMP peering connections resolved", "count", len(ompConns)) - } - connections = append(connections, ompConns...) - - // GET /dataservice/topology/monitor/site/{siteId} has no siteId - // to call with for the unclaimed fallback group. - if siteID != "" { - if siteTopology, siteTopologyRaw, err := client.GetSiteTopologyMonitorWithRaw(siteID); err != nil { - log.Warn("site topology monitor failed (continuing without SD-WAN tunnel connections)", "err", err) - } else { - tunnelConns := TransformTunnels(siteTopology, ifaceIndex) - if len(tunnelConns) > 0 { - log.Info("SD-WAN tunnel connections resolved", "count", len(tunnelConns)) - } - connections = append(connections, tunnelConns...) - - // Each entry is matched back to its owning device - // resource by vManage's own device-id, shared between - // this endpoint's "device-id" field and GET - // /dataservice/device's "deviceId" - // field (see Device.DeviceID). - if wantRawBody && len(siteTopology) == len(siteTopologyRaw) { - deviceIDToResID := make(map[string]string, len(siteDevices)) - for _, d := range siteDevices { - resType, ok := personalityToType[d.Personality] - if !ok || d.DeviceID == "" { - continue - } - deviceIDToResID[d.DeviceID] = resourceID(deviceNativeKey(d, resType)) - } - for i, st := range siteTopology { - resID, ok := deviceIDToResID[st.DeviceID] - if !ok { - continue - } - if idx, ok := deviceResIdx[resID]; ok { - setExtension(&resources[idx], "site_topology_raw", siteTopologyRaw[i]) - } - } - } - } - } - - scope := sdk.Scope{ - Providers: []string{providerName}, - Purpose: cfg.Purpose, - Accounts: accounts, - Clusters: []string{cfg.Host}, - } - if siteName != "" { - scope.Sites = []string{siteName} - } - - builder := sdk.NewDocumentBuilder(ctx). - WithGenerator(generatorName, generatorVersion, generatorURL). - WithScope(scope) - for _, r := range resources { - builder.AddResource(r) - } - for _, c := range connections { - builder.AddConnection(c) - } - if group, ok := TransformSiteGroup(siteID, siteName, siteDevices, deviceResourceIDs); ok { - builder.AddGroup(group) - } - - doc, err := builder.Build() - if err != nil { - log.Error("document build failed (continuing with remaining sites)", "err", err) - failures = append(failures, fmt.Sprintf("%s: %v", siteLabel(siteID, siteName), err)) - failed++ - continue - } - - data, err := sdk.MarshalDocument(doc) - if err != nil { - log.Error("marshal failed (continuing with remaining sites)", "err", err) - failures = append(failures, fmt.Sprintf("%s: %v", siteLabel(siteID, siteName), err)) - failed++ - continue - } - - // outPath is keyed by site name, not site-id (see OutputPath's - // comment): a directory that already exists under this name - // from a previous vmanage run, or another producer entirely - // writing to the same --output is reused as-is; MkdirAll below - // is a no-op against it and the new timestamped file is simply - // added alongside whatever is already there. - outPath := OutputPath(outputDir, run.FormatTimestamp(ctx.Clock()), siteName) - if err := os.MkdirAll(filepath.Dir(outPath), 0755); err != nil { - log.Error("creating output directory failed (continuing with remaining sites)", "err", err, "path", filepath.Dir(outPath)) - failures = append(failures, fmt.Sprintf("%s: %v", siteLabel(siteID, siteName), err)) - failed++ - continue - } - if err := os.WriteFile(outPath, data, 0644); err != nil { - log.Error("write failed (continuing with remaining sites)", "err", err, "path", outPath) - failures = append(failures, fmt.Sprintf("%s: %v", siteLabel(siteID, siteName), err)) - failed++ - continue - } - - fmt.Fprintf(os.Stderr, "Saved to %s\n", outPath) - succeeded++ - } - - if succeeded == 0 { - return fmt.Errorf("all %d site(s) failed: %s", failed, strings.Join(failures, "; ")) - } - if failed > 0 { - logger.Warn("export completed with failures", "succeeded", succeeded, "failed", failed) - } else { - logger.Info("export complete", "succeeded", succeeded, "output_dir", outputDir) - } - return nil -} - -// deviceRawIndex builds a Device.DeviceID -> raw JSON object lookup -// from GetDevicesWithRaw's parallel devices/raws slices, so each -// site's per-device raw body (see wantRawBody) can still be found -// after GroupDevicesBySiteID has split the flat device list into -// per-site slices. -func deviceRawIndex(devices []Device, raws []json.RawMessage) map[string]json.RawMessage { - if len(devices) != len(raws) { - return nil - } - idx := make(map[string]json.RawMessage, len(devices)) - for i, d := range devices { - if d.DeviceID != "" { - idx[d.DeviceID] = raws[i] - } - } - return idx -} - -// siteLabel returns a human-readable label for a site, matching the -// resolved name OutputPath used for this site's directory segment -// (siteName) when available, falling back to the raw site-id and then -// to the unclaimed segment name. -func siteLabel(siteID, siteName string) string { - if siteName != "" { - return siteName - } - if siteID == "" { - return unsitedSegment - } - return siteID -} - -func defaultLogger() *slog.Logger { - return slog.New(slog.NewTextHandler(os.Stderr, nil)) -} - -func printHelp() { - fmt.Print(`osirisjson-producer cisco vmanage - Cisco Catalyst SD-WAN Manager (vManage) OSIRIS JSON producer - -Usage: - osirisjson-producer cisco vmanage [flags] - -Site selection: when neither --site nor --all is given, the sites -discovered on the controller are listed interactively (pick by number, -e.g. "1,3,5" or "1-4" or "all"). Use --all (or --site all, an alias) -for non-interactive runs (cron/CI). Every site's document starts being -written immediately, without waiting on any site-name resolution. ---site also accepts either the raw numeric site-id (matches instantly -without waiting for name resolution) or the resolved site name -(e.g. --site MXP); a name that doesn't match any raw site-id -triggers a full site-name resolution pass to find it, since vManage -up to 20.18 still has no endpoint to look up a site-id by name directly. - -Bulk site-name resolution (only triggered by the interactive picker or -a --site value that falls back to name matching) is capped at ---site-name-rate (default 10/s) since vManage's own rate limit is -typically shared across many tools frequently polling same controller -(monitoring systems, other automation, not just this producer). Raise -or lower it based on how much headroom your environment actually has, -from 1 (very conservative) up to your controller's full observed limit. - -Authentication: there is deliberately no -p/--password flag, CLI flag -values are visible to any local user (e.g. via ps) and get written to -shell history. host/username/password are each resolved in this order: -their own -h/-u flag, then --secrets-file, then (for whichever is still -missing) an interactive prompt on the controlling terminal so a bare -"osirisjson-producer cisco vmanage" with no flags at all asks for -host, username and password one at a time, and nothing entered there -is written to disk unless --secrets-file was also given. - -Flags: -`) - fmt.Print(FlagsUsage()) - fmt.Print(` -Other commands: - template --generate Write --secrets-file skeletons: cisco-vmanage-secrets.json - (single host) and cisco-vmanage-secrets-multihost.json - (per-host/CIDR rules) - -Examples: - osirisjson-producer cisco vmanage - osirisjson-producer cisco vmanage -h vmanage.example.com -u admin - osirisjson-producer cisco vmanage --secrets-file ./cisco-vmanage-secrets.json - osirisjson-producer cisco vmanage --secrets-file ./cisco-vmanage-secrets.json --purpose audit --site "MXP,Branch-1" - osirisjson-producer cisco vmanage --secrets-file ./cisco-vmanage-secrets.json --all -o ./output - osirisjson-producer cisco vmanage template --generate -`) -} diff --git a/testdata-policy-allowlist.json b/testdata-policy-allowlist.json index 95736a7..eab1b8a 100644 --- a/testdata-policy-allowlist.json +++ b/testdata-policy-allowlist.json @@ -9,6 +9,24 @@ "issue": "feature/ci-test-data-policy", "review_by": "2027-11-18" }, + { + "path": "README.md", + "rule": "OSIRIS-PR-TDP-004", + "fingerprint": "sha256:0047c2a15c876d1e30ba8ef79aee532a", + "reason": "Try-it example targets the public Cisco DevNet ACI Simulator Always On sandbox host, which readers must use verbatim to reproduce the demo", + "owner": "Tia Zanella @skhell ", + "issue": "feature/ci-test-data-policy", + "review_by": "2027-11-19" + }, + { + "path": "README.md", + "rule": "OSIRIS-PR-TDP-004", + "fingerprint": "sha256:1908274e2a1ca9273cd7c10066112ec0", + "reason": "Audit-purpose try-it example targets the same public Cisco DevNet ACI Simulator Always On sandbox host", + "owner": "Tia Zanella @skhell ", + "issue": "feature/ci-test-data-policy", + "review_by": "2027-11-19" + }, { "path": "osiris/network/cisco/apic/security_test.go", "rule": "OSIRIS-PR-TDP-010", diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/README.md b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/README.md new file mode 100644 index 0000000..c93709f --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/README.md @@ -0,0 +1,231 @@ +# OSIRIS JSON Cisco Catalyst SD-WAN Manager producer fixtures + +Synthetic SD-WAN Manager `/dataservice` REST response bodies and the +OSIRIS JSON documents the Cisco Catalyst SD-WAN Manager producer +(`osiris/network/cisco/catalyst-sd-wan-manager`) is expected to emit +from them. +`TestGolden` in `golden_test.go` logs in to an in-memory HTTPS SD-WAN +Manager that serves these bodies, runs the full export and compares the +emitted per-site document byte for byte with `purpose/golden_.json`. + +## API names from before the Catalyst SD-WAN Manager rebranding + +The SD-WAN Manager REST API still uses the component names from before +the Catalyst SD-WAN Manager rebranding, in the releases this producer +targets API release (20.18, 26.1 and 26.2). The fixtures reproduce them +exactly because the tests must decode what the API actually sends: + +| API name | Kind | Meaning | +|---|---|---| +| `vmanage` | `personality`, `device-type`, `device-model` value | Catalyst SD-WAN Manager | +| `vsmart` | `personality`, `device-type`, `device-model` value | Catalyst SD-WAN Controller | +| `vbond` | `personality`, `device-type` value | Catalyst SD-WAN Validator | +| `vedge`, `cedge` | `personality` value | WAN edge | +| `connectedVManages` | `GET /dataservice/device` field | Managers the device is connected to | +| `num-vmanages`, `vmanage-connection-preference` | `GET /dataservice/device/control/waninterface` field | Manager connection count and preference (not modeled) | + +Names the OSIRIS JSON Producer chooses itself use the current naming: +provider `cisco.catalystsdwanmanager`, extension namespace +`osiris.cisco.catalystsdwanmanager` and extension keys such as +`connected_manager` (from `connectedVManages`). The personality and +device-model values pass through unchanged into `provider.type` and +`properties.model`, so the expected documents carry them too. + +## Layout + +```text + + api/.json # response body of GET /dataservice/ + purpose/ + _golden_documentation.json # expected default OSIRIS JSON document + _golden_audit.json # expected OSIRIS JSON document using --purpose audit flag +``` + +`` is the endpoint path after `/dataservice/`. A `deviceId` or +`state` query parameter becomes the last path segment: + +| Request | Fixture | +|---|---| +| `GET /dataservice/device` | `api/device.json` | +| `GET /dataservice/topology/device/site/{siteId}` | `api/topology/device/site/{siteId}.json` | +| `GET /dataservice/topology/monitor/site/{siteId}` | `api/topology/monitor/site/{siteId}.json` | +| `GET /dataservice/device/interface?deviceId={system-ip}` | `api/device/interface/{system-ip}.json` | +| `GET /dataservice/device/control/waninterface?deviceId={system-ip}` | `api/device/control/waninterface/{system-ip}.json` | +| `GET /dataservice/device/omp/peers?deviceId={system-ip}` | `api/device/omp/peers/{system-ip}.json` | +| `GET /dataservice/device/omp/links?state={state}` | `api/device/omp/links/{state}.json` | + +An endpoint without a fixture file is answered with a valid empty list +(`{"data":[]}`). List bodies use the `{"data": [...]}` envelope. + +The export stamps the wall clock into `metadata.timestamp` and the +controller address it dialed into `metadata.scope.clusters`. The test +checks that the dialed address is the only cluster and then pins both +fields (`2026-11-13T12:00:00Z`, `lab-manager01.example.com`), every +other byte is the OSIRIS JSON producer own output. + +Besides the byte-for-byte comparison: + +- `TestGolden_PurposeContract` requires that every documentation + document carries only the fields of the producer's documentation + allowlist, that no audit-only field (`serial_number`, + `certificate_validity`, `ip_addresses`, `mac_address`, `system_ip`, + `geo_location`, `device_groups`, `up_since`) appears in one, that + each of them appears in at least one audit document, and that both + purposes hold the same graph. +- `TestGolden_GraphIntegrity` requires that every connection endpoint + and every group member is an emitted resource. + +Unit cases for single response shapes (bare arrays, numeric `speed-mbps` +failed endpoints, raw bodies) are inline in the `_test.go` file that +uses them. + +Validate the expected documents with the canonical CLI before +committing a change to them: + +```bash +./scripts/validate_golden.sh testdata/osiris/network/cisco/catalyst-sd-wan-manager +``` + +## Scenarios + +Each scenario was tested against the matching platform in the +[Cisco DevNet Sandbox](https://developer.cisco.com/sandbox). +Only the structure was taken from the sandbox. Every value is synthetic, +as described below. +`lab_sdwan` follows the structure observed on the sandbox, +`lab_cross_site` is built from the documented response shapes of the +same endpoints. + +Addresses are RFC 5737 (`192.0.2.0/24`, `198.51.100.0/24`, +`203.0.113.0/24`) and RFC 3849 (`2001:db8::/32`), MAC addresses are +RFC 9542 documentation unicast (`00:00:5E:00:53:xx`) or locally +administered (`02:00:5E:00:53:xx`), device names use the `LAB-` prefix, +serial numbers use the `TST` prefix, device UUIDs are sequential +synthetic values (`00000000-0000-4000-8000-000000000NNN`) or +`-` strings, site names are `MXP`, `BRANCH-00` and +`OFFICE-00` and the coordinates are the approved example location. + +### Cisco Catalyst SD-WAN Manager lab_sdwan + +**Shape:** a Catalyst SD-WAN control-plane site, API release 20.18 (see +`version` in `api/device.json`), observed on the DevNet Sandbox SD-WAN +Manager Always On environment. + +**Contains:** site-id `100` (`MXP`) with three controllers, every one +`reachable` and `normal`: + +| Device | Personality | Model | System IP | Interfaces | +|---|---|---|---|---| +| `LAB-MANAGER01` | `vmanage` | `vmanage` | `192.0.2.1` | `docker0`, `eth0` (VPN 512), `eth1` (transport), `eth2`, `eth3`, `system` | +| `LAB-CONTROLLER01` | `vsmart` | `vsmart` | `192.0.2.101` | `eth0` (service), `eth1` (transport), `eth2`, `eth3`, `system` | +| `LAB-VALIDATOR01` | `vbond` | `vedge-cloud` | `192.0.2.201` | `eth0` (service), `ge0/0` (transport), `system` | + +The emitted document holds 3 `osiris.cisco.controller` resources, 14 +`network.interface` resources, 14 `contains` connections and one +`logical.site` group listing those 17 resources, with the site's +coordinates at `--purpose audit`. + +Response details that exercise specific transform paths: + +- `latitude` is a string and `longitude` a number, as in the SD-WAN + Manager OpenAPI example for `GET /dataservice/device`. +- Interfaces without an address report `ip-address` as `-`. +- `LAB-MANAGER01` `eth0` is listed twice, IPv6 first; both rows are + reconciled into one interface, with the IPv4 row's fields. +- The Manager and Controller transport interfaces have a WAN interface + entry with color `default` the Validator has none, so its `ge0/0` + carries no color. +- Some interfaces are administratively `Down` but operationally `Up`, + as the sandbox reports for the controllers service and bridge + interfaces. + +**Deliberately omits:** + +- WAN edges (`vedge`, `cedge`), and with them `network.router` and + `network.router.port` resources, OMP links and peers and SD-WAN + tunnel connections. The sandbox control-plane site has none, the + OMP and site topology monitor endpoints are answered empty. +- Tenants: the producer does not query them, so + `metadata.scope.accounts` is never populated. +- `private_ip` addresses: the producer classifies an interface address + as public only when it is globally routable, and every example + address here is RFC 5737 (which is globally routable in form), so + all interface addresses are emitted as `public_ip`. +- `--include-raw-body` output. + +### Cisco Catalyst SD-WAN Manager lab_cross_site + +**Shape:** two WAN edge sites and a controller site, modeled on the +field shapes of a cEdge (Catalyst 8000V, IOS-XE 17.15) fabric managed +by SD-WAN Manager 20.18. Each site is exported as its own document +(`purpose/_golden_.json`). + +**Contains:** + +| Site | Device | Personality | System IP | Interfaces | +|---|---|---|---|---| +| `1000` `MXP` | `LAB-CONTROLLER01` | `vsmart` | `192.0.2.1` | `eth0` (transport, color `default`), `system` | +| `100` `BRANCH-00` | `LAB-RTR01` | `vedge` (cEdge) | `192.0.2.11` | `GigabitEthernet1` (transport, `biz-internet`), `GigabitEthernet2` (VPN 10), `Loopback1` (VPN 0 and VPN 10) | +| `200` `OFFICE-00` | `LAB-RTR02` | `vedge` (cEdge) | `192.0.2.12` | `GigabitEthernet1` (transport, `biz-internet`), `GigabitEthernet3` (VPN 10) | + +Both edges hold an OMP session with the controller and a +`biz-internet` tunnel with each other. Every document keeps the +relationships it takes part in by carrying the remote endpoints as +neighbor resources (`site_role: "neighbor"`, never site group +members): the BRANCH-00 and OFFICE-00 documents both hold the +cross-site tunnel with the same connection ID and endpoints, and each +holds its edge's OMP session with the controller. An OSIRIS JSON +Consumer merging the three documents by ID obtains one end-to-end graph. + +Response details that exercise specific transform paths: + +- `LAB-RTR01` `GigabitEthernet1` has its `description` only on its + IPv6 row, it is kept on the reconciled interface. +- `LAB-RTR01` `Loopback1` exists in VPN 0 and VPN 10: two interfaces, + the VPN 10 one with an `@vpn10` ID suffix. +- `LAB-RTR02` reports its controller session `down` while the global + OMP link list and the controller report it `up`: the connection has + no single state and lists `observed_states` `["down", "up"]` + identically in every document. +- `LAB-RTR02` lists an OMP peer `192.0.2.99` that is not in the + inventory: it is not invented and `graph.unresolved_omp` counts it. +- The controller's `lastupdated` is a numeric string (the published + schema's type) the edges an integer (the published example's). +- The two ends report different tunnel quality scores (`9` and `0`); + each document keeps the score its own site reported and a `0` + score is kept. + +**Deliberately omits:** tenants, `--include-raw-body` output, and +devices without a native identity. + +### Cisco Catalyst SD-WAN Manager contract_20_18 contract_26_1 contract_26_2 + +**Shape:** one scenario per documented API SD-WAN Manager release. Every +response body carries exactly the keys of that release's documented +example response for the endpoint (the official OpenAPI specification +of the release) with synthetic values. The documented response +contracts of the endpoints this producer calls are the same in the +three releases except for `GET /dataservice/device/interface`, whose +26.2 example adds `fec-mode`; the three scenarios differ only there. + +**Contains:** the same fabric as `lab_cross_site` (a controller site +`1000` `MXP` and edge sites `100` `BRANCH-00` and `200` `OFFICE-00` +joined by a `biz-internet` tunnel, both edges peering with the +controller), plus the documented fields this producer does not model +(counters, preferences, `if-speed`, `ipv6-address`, and so on). The +inventory mixes the example's typing (the controller, integer +timestamps and numeric longitude) with the published schema's (the +edges, string timestamps and string longitude). + +`TestContract_EveryReleaseYieldsTheSameCompleteGraph` exports every +site of every release at both purposes and requires complete +coverage, no unresolved endpoint, the cross-site tunnel and the OMP +sessions in both edge documents, and the same graph for all three +releases. Only the `BRANCH-00` document of each release is kept as a +golden (`purpose/branch_00_golden_.json`) the three are +identical. + +**Does not establish:** behavior of a deployed Manager of these +releases. The scenarios prove the documented contracts decode into the +expected graph, documents still carry `api_profile: "unverified"` +because the producer does not discover the Manager release. diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device.json new file mode 100644 index 0000000..4660edd --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device.json @@ -0,0 +1,125 @@ +[ + { + "board-serial": "TST0000301", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vsmart", + "device-os": "next", + "device-type": "vsmart", + "deviceId": "192.0.2.1", + "domain-id": "1", + "host-name": "LAB-CONTROLLER01", + "isDeviceGeoData": true, + "lastupdated": 1794571200000, + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.1", + "longitude": 10.2241237, + "max-controllers": "0", + "model_sku": "None", + "personality": "vsmart", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "1000", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.1", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": 1793520000000, + "uuid": "00000000-0000-4000-8000-000000000301", + "validity": "valid", + "version": "20.18.2.1" + }, + { + "board-serial": "TST0000011", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vedge-C8000V", + "device-os": "next", + "device-type": "vedge", + "deviceId": "192.0.2.11", + "domain-id": "1", + "host-name": "LAB-RTR01", + "isDeviceGeoData": true, + "lastupdated": "1794571200000", + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.11", + "longitude": "10.2241237", + "max-controllers": "0", + "model_sku": "None", + "personality": "vedge", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "100", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.11", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": "1793520000000", + "uuid": "C8000V-TST0000011", + "validity": "valid", + "version": "17.15.01a" + }, + { + "board-serial": "TST0000012", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vedge-C8000V", + "device-os": "next", + "device-type": "vedge", + "deviceId": "192.0.2.12", + "domain-id": "1", + "host-name": "LAB-RTR02", + "isDeviceGeoData": true, + "lastupdated": "1794571200000", + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.12", + "longitude": "10.2241237", + "max-controllers": "0", + "model_sku": "None", + "personality": "vedge", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "200", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.12", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": "1793520000000", + "uuid": "C8000V-TST0000012", + "validity": "valid", + "version": "17.15.01a" + } +] diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.1.json new file mode 100644 index 0000000..7b407eb --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.1.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "default", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "eth0", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "203.0.113.1", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.1", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.1-default", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.11.json new file mode 100644 index 0000000..06d8a46 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.11.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "biz-internet", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "GigabitEthernet1", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "198.51.100.11", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.11", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.11-biz-internet", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.12.json new file mode 100644 index 0000000..1c12eb4 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/control/waninterface/192.0.2.12.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "biz-internet", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "GigabitEthernet1", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "198.51.100.12", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.12", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.12-biz-internet", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.1.json new file mode 100644 index 0000000..8dd0217 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.1.json @@ -0,0 +1,46 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:31", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "eth0", + "ip-address": "203.0.113.1/24", + "ipv6-address": "2001:db8:1::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-0-eth0", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1", + "vpn-id": "0" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.11.json new file mode 100644 index 0000000..dec65e6 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.11.json @@ -0,0 +1,88 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:11", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet1", + "ip-address": "198.51.100.11/24", + "ipv6-address": "2001:db8:11::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-0-GigabitEthernet1", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vpn-id": "0" + }, + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:12", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet2", + "ip-address": "203.0.113.75/27", + "ipv6-address": "::", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "service", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-10-GigabitEthernet2", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vpn-id": "10" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.12.json new file mode 100644 index 0000000..13e3f92 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/interface/192.0.2.12.json @@ -0,0 +1,88 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:21", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet1", + "ip-address": "198.51.100.12/24", + "ipv6-address": "2001:db8:21::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-0-GigabitEthernet1", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vpn-id": "0" + }, + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:22", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet2", + "ip-address": "203.0.113.85/27", + "ipv6-address": "::", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "service", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-10-GigabitEthernet2", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vpn-id": "10" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/links/up.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/links/up.json new file mode 100644 index 0000000..bbcdb09 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/links/up.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "adeviceId": "192.0.2.11", + "ahost-name": "LAB-RTR01", + "apersonality": "vedge", + "asite-id": "100", + "asystem-ip": "192.0.2.11", + "bdeviceId": "192.0.2.1", + "bhost-name": "LAB-CONTROLLER01", + "bpersonality": "vsmart", + "bsite-id": "1000", + "bsystem-ip": "192.0.2.1", + "lastupdated": "1794571200000", + "linkKey": "192.0.2.11-192.0.2.1", + "state": "up" + }, + { + "adeviceId": "192.0.2.12", + "ahost-name": "LAB-RTR02", + "apersonality": "vedge", + "asite-id": "200", + "asystem-ip": "192.0.2.12", + "bdeviceId": "192.0.2.1", + "bhost-name": "LAB-CONTROLLER01", + "bpersonality": "vsmart", + "bsite-id": "1000", + "bsystem-ip": "192.0.2.1", + "lastupdated": "1794571200000", + "linkKey": "192.0.2.12-192.0.2.1", + "state": "up" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.1.json new file mode 100644 index 0000000..2e5b685 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.1.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.11", + "refresh": "supported", + "site-id": 100, + "state": "up", + "type": "vedge", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-192.0.2.11", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1" + }, + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.12", + "refresh": "supported", + "site-id": 200, + "state": "up", + "type": "vedge", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-192.0.2.12", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.11.json new file mode 100644 index 0000000..cc8a029 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.11.json @@ -0,0 +1,19 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.1", + "refresh": "supported", + "site-id": 1000, + "state": "up", + "type": "vsmart", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-192.0.2.1", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.12.json new file mode 100644 index 0000000..495355c --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/device/omp/peers/192.0.2.12.json @@ -0,0 +1,19 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.1", + "refresh": "supported", + "site-id": 1000, + "state": "up", + "type": "vsmart", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-192.0.2.1", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/100.json new file mode 100644 index 0000000..fb1b279 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/100.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "BRANCH-00" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/1000.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/1000.json new file mode 100644 index 0000000..0b77a9d --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/1000.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "MXP" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/200.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/200.json new file mode 100644 index 0000000..63251b5 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/device/site/200.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "OFFICE-00" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/monitor/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/monitor/site/100.json new file mode 100644 index 0000000..3c55f51 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/monitor/site/100.json @@ -0,0 +1,31 @@ +{ + "data": [ + { + "circuits": [ + { + "circuit-health": "good", + "color": "biz-internet", + "system_ip": "192.0.2.11", + "tunnels": [ + { + "health": "good", + "name": "192.0.2.11:biz-internet-192.0.2.12:biz-internet", + "state": "up", + "vqoe_score": 9 + } + ] + } + ], + "device-health": "good", + "device-id": "192.0.2.11", + "if-speed": [ + { + "count": 1, + "interface": "GigabitEthernet1", + "rx_kbps": 1, + "tx_kbps": 1 + } + ] + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/monitor/site/200.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/monitor/site/200.json new file mode 100644 index 0000000..fac7fa6 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/api/topology/monitor/site/200.json @@ -0,0 +1,31 @@ +{ + "data": [ + { + "circuits": [ + { + "circuit-health": "good", + "color": "biz-internet", + "system_ip": "192.0.2.12", + "tunnels": [ + { + "health": "good", + "name": "192.0.2.12:biz-internet-192.0.2.11:biz-internet", + "state": "up", + "vqoe_score": 9 + } + ] + } + ], + "device-health": "good", + "device-id": "192.0.2.12", + "if-speed": [ + { + "count": 1, + "interface": "GigabitEthernet1", + "rx_kbps": 1, + "tx_kbps": 1 + } + ] + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/purpose/branch_00_golden_audit.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/purpose/branch_00_golden_audit.json new file mode 100644 index 0000000..355f33e --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/purpose/branch_00_golden_audit.json @@ -0,0 +1,325 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "audit", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "BRANCH-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "serial_number": "TST0000011", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "certificate_validity": "Valid", + "chassis_number": "C8000V-TST0000011", + "connected_manager": [ + "192.0.2.2" + ], + "device_groups": [ + "TEST-GROUP-A" + ], + "health": "green", + "last_update": "2026-11-13T12:00:00Z", + "site_id": "100", + "state_description": "All daemons up", + "system_ip": "192.0.2.11", + "up_since": "2026-11-01T08:00:00Z" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "duplex": "full", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "ip_addresses": { + "public_ip": "203.0.113.11" + }, + "mac_address": "02:00:5e:00:53:11", + "mtu": 1500, + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "nat_type": "-" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "type": "network.router.port", + "name": "GigabitEthernet2", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet2", + "type": "GigabitEthernet2", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "duplex": "full", + "interface_name": "GigabitEthernet2", + "interface_type": "secondary", + "ip_addresses": { + "public_ip": "203.0.113.75" + }, + "mac_address": "02:00:5e:00:53:12", + "mtu": 1500, + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-1963c56ca41cf931", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet2" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp", + "sources": [ + "omp_links", + "omp_peers" + ] + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "vqoe_score": 9 + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", + "name": "BRANCH-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000011", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2" + ], + "properties": { + "geo_location": { + "latitude": 45.5433411, + "longitude": 10.2241237 + } + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/purpose/branch_00_golden_documentation.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/purpose/branch_00_golden_documentation.json new file mode 100644 index 0000000..cb49f65 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_20_18/purpose/branch_00_golden_documentation.json @@ -0,0 +1,288 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "documentation", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "BRANCH-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "health": "green", + "site_id": "100" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "type": "network.router.port", + "name": "GigabitEthernet2", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet2", + "type": "GigabitEthernet2", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet2", + "interface_type": "secondary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-1963c56ca41cf931", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet2" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp" + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", + "name": "BRANCH-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000011", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2" + ], + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device.json new file mode 100644 index 0000000..4660edd --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device.json @@ -0,0 +1,125 @@ +[ + { + "board-serial": "TST0000301", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vsmart", + "device-os": "next", + "device-type": "vsmart", + "deviceId": "192.0.2.1", + "domain-id": "1", + "host-name": "LAB-CONTROLLER01", + "isDeviceGeoData": true, + "lastupdated": 1794571200000, + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.1", + "longitude": 10.2241237, + "max-controllers": "0", + "model_sku": "None", + "personality": "vsmart", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "1000", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.1", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": 1793520000000, + "uuid": "00000000-0000-4000-8000-000000000301", + "validity": "valid", + "version": "20.18.2.1" + }, + { + "board-serial": "TST0000011", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vedge-C8000V", + "device-os": "next", + "device-type": "vedge", + "deviceId": "192.0.2.11", + "domain-id": "1", + "host-name": "LAB-RTR01", + "isDeviceGeoData": true, + "lastupdated": "1794571200000", + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.11", + "longitude": "10.2241237", + "max-controllers": "0", + "model_sku": "None", + "personality": "vedge", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "100", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.11", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": "1793520000000", + "uuid": "C8000V-TST0000011", + "validity": "valid", + "version": "17.15.01a" + }, + { + "board-serial": "TST0000012", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vedge-C8000V", + "device-os": "next", + "device-type": "vedge", + "deviceId": "192.0.2.12", + "domain-id": "1", + "host-name": "LAB-RTR02", + "isDeviceGeoData": true, + "lastupdated": "1794571200000", + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.12", + "longitude": "10.2241237", + "max-controllers": "0", + "model_sku": "None", + "personality": "vedge", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "200", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.12", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": "1793520000000", + "uuid": "C8000V-TST0000012", + "validity": "valid", + "version": "17.15.01a" + } +] diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.1.json new file mode 100644 index 0000000..7b407eb --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.1.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "default", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "eth0", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "203.0.113.1", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.1", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.1-default", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.11.json new file mode 100644 index 0000000..06d8a46 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.11.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "biz-internet", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "GigabitEthernet1", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "198.51.100.11", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.11", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.11-biz-internet", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.12.json new file mode 100644 index 0000000..1c12eb4 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/control/waninterface/192.0.2.12.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "biz-internet", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "GigabitEthernet1", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "198.51.100.12", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.12", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.12-biz-internet", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.1.json new file mode 100644 index 0000000..8dd0217 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.1.json @@ -0,0 +1,46 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:31", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "eth0", + "ip-address": "203.0.113.1/24", + "ipv6-address": "2001:db8:1::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-0-eth0", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1", + "vpn-id": "0" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.11.json new file mode 100644 index 0000000..dec65e6 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.11.json @@ -0,0 +1,88 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:11", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet1", + "ip-address": "198.51.100.11/24", + "ipv6-address": "2001:db8:11::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-0-GigabitEthernet1", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vpn-id": "0" + }, + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:12", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet2", + "ip-address": "203.0.113.75/27", + "ipv6-address": "::", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "service", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-10-GigabitEthernet2", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vpn-id": "10" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.12.json new file mode 100644 index 0000000..13e3f92 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/interface/192.0.2.12.json @@ -0,0 +1,88 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:21", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet1", + "ip-address": "198.51.100.12/24", + "ipv6-address": "2001:db8:21::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-0-GigabitEthernet1", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vpn-id": "0" + }, + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "hwaddr": "02:00:5e:00:53:22", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet2", + "ip-address": "203.0.113.85/27", + "ipv6-address": "::", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "service", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-10-GigabitEthernet2", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vpn-id": "10" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/links/up.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/links/up.json new file mode 100644 index 0000000..bbcdb09 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/links/up.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "adeviceId": "192.0.2.11", + "ahost-name": "LAB-RTR01", + "apersonality": "vedge", + "asite-id": "100", + "asystem-ip": "192.0.2.11", + "bdeviceId": "192.0.2.1", + "bhost-name": "LAB-CONTROLLER01", + "bpersonality": "vsmart", + "bsite-id": "1000", + "bsystem-ip": "192.0.2.1", + "lastupdated": "1794571200000", + "linkKey": "192.0.2.11-192.0.2.1", + "state": "up" + }, + { + "adeviceId": "192.0.2.12", + "ahost-name": "LAB-RTR02", + "apersonality": "vedge", + "asite-id": "200", + "asystem-ip": "192.0.2.12", + "bdeviceId": "192.0.2.1", + "bhost-name": "LAB-CONTROLLER01", + "bpersonality": "vsmart", + "bsite-id": "1000", + "bsystem-ip": "192.0.2.1", + "lastupdated": "1794571200000", + "linkKey": "192.0.2.12-192.0.2.1", + "state": "up" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.1.json new file mode 100644 index 0000000..2e5b685 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.1.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.11", + "refresh": "supported", + "site-id": 100, + "state": "up", + "type": "vedge", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-192.0.2.11", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1" + }, + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.12", + "refresh": "supported", + "site-id": 200, + "state": "up", + "type": "vedge", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-192.0.2.12", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.11.json new file mode 100644 index 0000000..cc8a029 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.11.json @@ -0,0 +1,19 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.1", + "refresh": "supported", + "site-id": 1000, + "state": "up", + "type": "vsmart", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-192.0.2.1", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.12.json new file mode 100644 index 0000000..495355c --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/device/omp/peers/192.0.2.12.json @@ -0,0 +1,19 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.1", + "refresh": "supported", + "site-id": 1000, + "state": "up", + "type": "vsmart", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-192.0.2.1", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/100.json new file mode 100644 index 0000000..fb1b279 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/100.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "BRANCH-00" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/1000.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/1000.json new file mode 100644 index 0000000..0b77a9d --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/1000.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "MXP" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/200.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/200.json new file mode 100644 index 0000000..63251b5 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/device/site/200.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "OFFICE-00" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/monitor/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/monitor/site/100.json new file mode 100644 index 0000000..3c55f51 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/monitor/site/100.json @@ -0,0 +1,31 @@ +{ + "data": [ + { + "circuits": [ + { + "circuit-health": "good", + "color": "biz-internet", + "system_ip": "192.0.2.11", + "tunnels": [ + { + "health": "good", + "name": "192.0.2.11:biz-internet-192.0.2.12:biz-internet", + "state": "up", + "vqoe_score": 9 + } + ] + } + ], + "device-health": "good", + "device-id": "192.0.2.11", + "if-speed": [ + { + "count": 1, + "interface": "GigabitEthernet1", + "rx_kbps": 1, + "tx_kbps": 1 + } + ] + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/monitor/site/200.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/monitor/site/200.json new file mode 100644 index 0000000..fac7fa6 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/api/topology/monitor/site/200.json @@ -0,0 +1,31 @@ +{ + "data": [ + { + "circuits": [ + { + "circuit-health": "good", + "color": "biz-internet", + "system_ip": "192.0.2.12", + "tunnels": [ + { + "health": "good", + "name": "192.0.2.12:biz-internet-192.0.2.11:biz-internet", + "state": "up", + "vqoe_score": 9 + } + ] + } + ], + "device-health": "good", + "device-id": "192.0.2.12", + "if-speed": [ + { + "count": 1, + "interface": "GigabitEthernet1", + "rx_kbps": 1, + "tx_kbps": 1 + } + ] + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/purpose/branch_00_golden_audit.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/purpose/branch_00_golden_audit.json new file mode 100644 index 0000000..355f33e --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/purpose/branch_00_golden_audit.json @@ -0,0 +1,325 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "audit", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "BRANCH-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "serial_number": "TST0000011", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "certificate_validity": "Valid", + "chassis_number": "C8000V-TST0000011", + "connected_manager": [ + "192.0.2.2" + ], + "device_groups": [ + "TEST-GROUP-A" + ], + "health": "green", + "last_update": "2026-11-13T12:00:00Z", + "site_id": "100", + "state_description": "All daemons up", + "system_ip": "192.0.2.11", + "up_since": "2026-11-01T08:00:00Z" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "duplex": "full", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "ip_addresses": { + "public_ip": "203.0.113.11" + }, + "mac_address": "02:00:5e:00:53:11", + "mtu": 1500, + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "nat_type": "-" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "type": "network.router.port", + "name": "GigabitEthernet2", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet2", + "type": "GigabitEthernet2", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "duplex": "full", + "interface_name": "GigabitEthernet2", + "interface_type": "secondary", + "ip_addresses": { + "public_ip": "203.0.113.75" + }, + "mac_address": "02:00:5e:00:53:12", + "mtu": 1500, + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-1963c56ca41cf931", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet2" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp", + "sources": [ + "omp_links", + "omp_peers" + ] + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "vqoe_score": 9 + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", + "name": "BRANCH-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000011", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2" + ], + "properties": { + "geo_location": { + "latitude": 45.5433411, + "longitude": 10.2241237 + } + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/purpose/branch_00_golden_documentation.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/purpose/branch_00_golden_documentation.json new file mode 100644 index 0000000..cb49f65 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_1/purpose/branch_00_golden_documentation.json @@ -0,0 +1,288 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "documentation", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "BRANCH-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "health": "green", + "site_id": "100" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "type": "network.router.port", + "name": "GigabitEthernet2", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet2", + "type": "GigabitEthernet2", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet2", + "interface_type": "secondary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-1963c56ca41cf931", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet2" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp" + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", + "name": "BRANCH-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000011", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2" + ], + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device.json new file mode 100644 index 0000000..4660edd --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device.json @@ -0,0 +1,125 @@ +[ + { + "board-serial": "TST0000301", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vsmart", + "device-os": "next", + "device-type": "vsmart", + "deviceId": "192.0.2.1", + "domain-id": "1", + "host-name": "LAB-CONTROLLER01", + "isDeviceGeoData": true, + "lastupdated": 1794571200000, + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.1", + "longitude": 10.2241237, + "max-controllers": "0", + "model_sku": "None", + "personality": "vsmart", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "1000", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.1", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": 1793520000000, + "uuid": "00000000-0000-4000-8000-000000000301", + "validity": "valid", + "version": "20.18.2.1" + }, + { + "board-serial": "TST0000011", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vedge-C8000V", + "device-os": "next", + "device-type": "vedge", + "deviceId": "192.0.2.11", + "domain-id": "1", + "host-name": "LAB-RTR01", + "isDeviceGeoData": true, + "lastupdated": "1794571200000", + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.11", + "longitude": "10.2241237", + "max-controllers": "0", + "model_sku": "None", + "personality": "vedge", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "100", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.11", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": "1793520000000", + "uuid": "C8000V-TST0000011", + "validity": "valid", + "version": "17.15.01a" + }, + { + "board-serial": "TST0000012", + "certificate-validity": "Valid", + "connectedVManages": [ + "192.0.2.2" + ], + "controlConnections": "2", + "device-groups": [ + "TEST-GROUP-A" + ], + "device-model": "vedge-C8000V", + "device-os": "next", + "device-type": "vedge", + "deviceId": "192.0.2.12", + "domain-id": "1", + "host-name": "LAB-RTR02", + "isDeviceGeoData": true, + "lastupdated": "1794571200000", + "latitude": "45.5433411", + "layoutLevel": 3, + "local-system-ip": "192.0.2.12", + "longitude": "10.2241237", + "max-controllers": "0", + "model_sku": "None", + "personality": "vedge", + "platform": "x86_64", + "reachability": "reachable", + "site-id": "200", + "state": "green", + "state_description": "All daemons up", + "status": "normal", + "statusOrder": 4, + "system-ip": "192.0.2.12", + "testbed_mode": false, + "timezone": "UTC", + "total_cpu_count": "4", + "uptime-date": "1793520000000", + "uuid": "C8000V-TST0000012", + "validity": "valid", + "version": "17.15.01a" + } +] diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.1.json new file mode 100644 index 0000000..7b407eb --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.1.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "default", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "eth0", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "203.0.113.1", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.1", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.1-default", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.11.json new file mode 100644 index 0000000..06d8a46 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.11.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "biz-internet", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "GigabitEthernet1", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "198.51.100.11", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.11", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.11-biz-internet", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.12.json new file mode 100644 index 0000000..1c12eb4 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/control/waninterface/192.0.2.12.json @@ -0,0 +1,39 @@ +{ + "data": [ + { + "admin-state": "up", + "carrier": "default", + "color": "biz-internet", + "control-str": "Yes", + "index": 1, + "instance": 1, + "interface": "GigabitEthernet1", + "last-conn-time": "-", + "last-conn-time-date": 1794571200000, + "last-resort": "No", + "lastupdated": 1794571200000, + "low-bandwidth-link": "No", + "nat-type": "-", + "num-vmanages": 1, + "num-vsmarts": 1, + "operation-state": "up", + "per-wan-max-controllers": 1, + "preference": "0", + "private-ip": "198.51.100.12", + "private-ipv6": "::", + "private-port": 1, + "public-ip": "203.0.113.12", + "public-port": 1, + "restrict-str": "no-restrict", + "spi-change": "-", + "vbond-as-stun-server": "No", + "vdevice-dataKey": "192.0.2.12-biz-internet", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vmanage-connection-preference": "5", + "wan-port-hopped": "No", + "wan-time-since-port-hop": "-", + "weight": 1 + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.1.json new file mode 100644 index 0000000..09c983a --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.1.json @@ -0,0 +1,47 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "fec-mode": "auto", + "hwaddr": "02:00:5e:00:53:31", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "eth0", + "ip-address": "203.0.113.1/24", + "ipv6-address": "2001:db8:1::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-0-eth0", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1", + "vpn-id": "0" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.11.json new file mode 100644 index 0000000..cd509dd --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.11.json @@ -0,0 +1,90 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "fec-mode": "auto", + "hwaddr": "02:00:5e:00:53:11", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet1", + "ip-address": "198.51.100.11/24", + "ipv6-address": "2001:db8:11::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-0-GigabitEthernet1", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vpn-id": "0" + }, + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "fec-mode": "auto", + "hwaddr": "02:00:5e:00:53:12", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet2", + "ip-address": "203.0.113.75/27", + "ipv6-address": "::", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "service", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-10-GigabitEthernet2", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11", + "vpn-id": "10" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.12.json new file mode 100644 index 0000000..8324457 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/interface/192.0.2.12.json @@ -0,0 +1,90 @@ +{ + "data": [ + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "fec-mode": "auto", + "hwaddr": "02:00:5e:00:53:21", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet1", + "ip-address": "198.51.100.12/24", + "ipv6-address": "2001:db8:21::1/64", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "transport", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-0-GigabitEthernet1", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vpn-id": "0" + }, + { + "af-type": "ipv4", + "allow-service": "-", + "auto-neg": "true", + "duplex": "full", + "encap-type": "null", + "fec-mode": "auto", + "hwaddr": "02:00:5e:00:53:22", + "if-admin-status": "if-state-up", + "if-oper-status": "if-oper-state-ready", + "if-tracker-status": "NA", + "ifindex": 1, + "ifname": "GigabitEthernet2", + "ip-address": "203.0.113.85/27", + "ipv6-address": "::", + "lastupdated": 1794571200000, + "mtu": "1500", + "num-flaps": "0", + "port-type": "service", + "rx-drops": 1, + "rx-errors": 1, + "rx-kbps": 1, + "rx-octets": 1, + "rx-packets": 1, + "rx-pps": 1, + "secondary": "-", + "secondary-address": "-", + "shaping-rate": 1, + "speed-mbps": "1000", + "tcp-mss-adjust": "-", + "tx-drops": 1, + "tx-errors": 1, + "tx-kbps": 1, + "tx-octets": 1, + "tx-packets": 1, + "tx-pps": 1, + "uptime": "1:00:00:00", + "uptime-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-10-GigabitEthernet2", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12", + "vpn-id": "10" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/links/up.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/links/up.json new file mode 100644 index 0000000..bbcdb09 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/links/up.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "adeviceId": "192.0.2.11", + "ahost-name": "LAB-RTR01", + "apersonality": "vedge", + "asite-id": "100", + "asystem-ip": "192.0.2.11", + "bdeviceId": "192.0.2.1", + "bhost-name": "LAB-CONTROLLER01", + "bpersonality": "vsmart", + "bsite-id": "1000", + "bsystem-ip": "192.0.2.1", + "lastupdated": "1794571200000", + "linkKey": "192.0.2.11-192.0.2.1", + "state": "up" + }, + { + "adeviceId": "192.0.2.12", + "ahost-name": "LAB-RTR02", + "apersonality": "vedge", + "asite-id": "200", + "asystem-ip": "192.0.2.12", + "bdeviceId": "192.0.2.1", + "bhost-name": "LAB-CONTROLLER01", + "bpersonality": "vsmart", + "bsite-id": "1000", + "bsystem-ip": "192.0.2.1", + "lastupdated": "1794571200000", + "linkKey": "192.0.2.12-192.0.2.1", + "state": "up" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.1.json new file mode 100644 index 0000000..2e5b685 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.1.json @@ -0,0 +1,34 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.11", + "refresh": "supported", + "site-id": 100, + "state": "up", + "type": "vedge", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-192.0.2.11", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1" + }, + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.12", + "refresh": "supported", + "site-id": 200, + "state": "up", + "type": "vedge", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.1-192.0.2.12", + "vdevice-host-name": "LAB-CONTROLLER01", + "vdevice-name": "192.0.2.1" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.11.json new file mode 100644 index 0000000..cc8a029 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.11.json @@ -0,0 +1,19 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.1", + "refresh": "supported", + "site-id": 1000, + "state": "up", + "type": "vsmart", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.11-192.0.2.1", + "vdevice-host-name": "LAB-RTR01", + "vdevice-name": "192.0.2.11" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.12.json new file mode 100644 index 0000000..495355c --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/device/omp/peers/192.0.2.12.json @@ -0,0 +1,19 @@ +{ + "data": [ + { + "domain-id": 1, + "lastupdated": 1794571200000, + "legit": "yes", + "peer": "192.0.2.1", + "refresh": "supported", + "site-id": 1000, + "state": "up", + "type": "vsmart", + "up-time": "1:00:00:00", + "up-time-date": 1793520000000, + "vdevice-dataKey": "192.0.2.12-192.0.2.1", + "vdevice-host-name": "LAB-RTR02", + "vdevice-name": "192.0.2.12" + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/100.json new file mode 100644 index 0000000..fb1b279 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/100.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "BRANCH-00" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/1000.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/1000.json new file mode 100644 index 0000000..0b77a9d --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/1000.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "MXP" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/200.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/200.json new file mode 100644 index 0000000..63251b5 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/device/site/200.json @@ -0,0 +1,4 @@ +{ + "data": [], + "site_name": "OFFICE-00" +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/monitor/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/monitor/site/100.json new file mode 100644 index 0000000..3c55f51 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/monitor/site/100.json @@ -0,0 +1,31 @@ +{ + "data": [ + { + "circuits": [ + { + "circuit-health": "good", + "color": "biz-internet", + "system_ip": "192.0.2.11", + "tunnels": [ + { + "health": "good", + "name": "192.0.2.11:biz-internet-192.0.2.12:biz-internet", + "state": "up", + "vqoe_score": 9 + } + ] + } + ], + "device-health": "good", + "device-id": "192.0.2.11", + "if-speed": [ + { + "count": 1, + "interface": "GigabitEthernet1", + "rx_kbps": 1, + "tx_kbps": 1 + } + ] + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/monitor/site/200.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/monitor/site/200.json new file mode 100644 index 0000000..fac7fa6 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/api/topology/monitor/site/200.json @@ -0,0 +1,31 @@ +{ + "data": [ + { + "circuits": [ + { + "circuit-health": "good", + "color": "biz-internet", + "system_ip": "192.0.2.12", + "tunnels": [ + { + "health": "good", + "name": "192.0.2.12:biz-internet-192.0.2.11:biz-internet", + "state": "up", + "vqoe_score": 9 + } + ] + } + ], + "device-health": "good", + "device-id": "192.0.2.12", + "if-speed": [ + { + "count": 1, + "interface": "GigabitEthernet1", + "rx_kbps": 1, + "tx_kbps": 1 + } + ] + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/purpose/branch_00_golden_audit.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/purpose/branch_00_golden_audit.json new file mode 100644 index 0000000..355f33e --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/purpose/branch_00_golden_audit.json @@ -0,0 +1,325 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "audit", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "BRANCH-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "serial_number": "TST0000011", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "certificate_validity": "Valid", + "chassis_number": "C8000V-TST0000011", + "connected_manager": [ + "192.0.2.2" + ], + "device_groups": [ + "TEST-GROUP-A" + ], + "health": "green", + "last_update": "2026-11-13T12:00:00Z", + "site_id": "100", + "state_description": "All daemons up", + "system_ip": "192.0.2.11", + "up_since": "2026-11-01T08:00:00Z" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "duplex": "full", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "ip_addresses": { + "public_ip": "203.0.113.11" + }, + "mac_address": "02:00:5e:00:53:11", + "mtu": 1500, + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "nat_type": "-" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "type": "network.router.port", + "name": "GigabitEthernet2", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet2", + "type": "GigabitEthernet2", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "duplex": "full", + "interface_name": "GigabitEthernet2", + "interface_type": "secondary", + "ip_addresses": { + "public_ip": "203.0.113.75" + }, + "mac_address": "02:00:5e:00:53:12", + "mtu": 1500, + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-1963c56ca41cf931", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet2" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp", + "sources": [ + "omp_links", + "omp_peers" + ] + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "vqoe_score": 9 + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", + "name": "BRANCH-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000011", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2" + ], + "properties": { + "geo_location": { + "latitude": 45.5433411, + "longitude": 10.2241237 + } + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/purpose/branch_00_golden_documentation.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/purpose/branch_00_golden_documentation.json new file mode 100644 index 0000000..cb49f65 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/contract_26_2/purpose/branch_00_golden_documentation.json @@ -0,0 +1,288 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "documentation", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "BRANCH-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "health": "green", + "site_id": "100" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "type": "network.router.port", + "name": "GigabitEthernet2", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet2", + "type": "GigabitEthernet2", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet2", + "interface_type": "secondary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-1963c56ca41cf931", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet2" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp" + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", + "name": "BRANCH-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000011", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2" + ], + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device.json new file mode 100644 index 0000000..3f721ac --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device.json @@ -0,0 +1,71 @@ +{ + "data": [ + { + "deviceId": "192.0.2.1", + "system-ip": "192.0.2.1", + "host-name": "LAB-CONTROLLER01", + "uuid": "00000000-0000-4000-8000-000000000301", + "site-id": "1000", + "personality": "vsmart", + "device-type": "vsmart", + "device-model": "vsmart", + "reachability": "reachable", + "status": "normal", + "version": "20.18.2.1", + "board-serial": "TST0000301", + "certificate-validity": "Valid", + "device-groups": ["No groups"], + "latitude": "45.5433411", + "longitude": 10.2241237, + "lastupdated": "1794571200000", + "state": "green", + "state_description": "All daemons up", + "uptime-date": 1793520000000 + }, + { + "deviceId": "192.0.2.11", + "system-ip": "192.0.2.11", + "host-name": "LAB-RTR01", + "uuid": "C8000V-TST0000011", + "site-id": "100", + "personality": "vedge", + "device-type": "vedge", + "device-model": "vedge-C8000V", + "reachability": "reachable", + "status": "normal", + "version": "17.15.01a", + "board-serial": "TST0000011", + "certificate-validity": "Valid", + "device-groups": ["TEST-GROUP-B", "TEST-GROUP-A"], + "latitude": "45.5433411", + "longitude": "10.2241237", + "lastupdated": 1794571200000, + "state": "green", + "state_description": "All daemons up", + "uptime-date": 1793520000000, + "connectedVManages": ["192.0.2.2"] + }, + { + "deviceId": "192.0.2.12", + "system-ip": "192.0.2.12", + "host-name": "LAB-RTR02", + "uuid": "C8000V-TST0000012", + "site-id": "200", + "personality": "vedge", + "device-type": "vedge", + "device-model": "vedge-C8000V", + "reachability": "reachable", + "status": "warning", + "version": "17.15.01a", + "board-serial": "TST0000012", + "certificate-validity": "Valid", + "latitude": "45.5433411", + "longitude": "10.2241237", + "lastupdated": 1794571200000, + "state": "yellow", + "state_description": "Control connection down", + "uptime-date": 1793520000000, + "connectedVManages": ["192.0.2.2"] + } + ] +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.1.json new file mode 100644 index 0000000..441dc0a --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.1.json @@ -0,0 +1 @@ +{"data":[{"vdevice-host-name":"LAB-CONTROLLER01","interface":"eth0","color":"default","private-ip":"203.0.113.1","public-ip":"203.0.113.1","operation-state":"up"}]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.11.json new file mode 100644 index 0000000..845a16b --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.11.json @@ -0,0 +1 @@ +{"data":[{"vdevice-host-name":"LAB-RTR01","interface":"GigabitEthernet1","color":"biz-internet","private-ip":"198.51.100.11","public-ip":"203.0.113.11","nat-type":"A","operation-state":"up"}]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.12.json new file mode 100644 index 0000000..8534483 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/control/waninterface/192.0.2.12.json @@ -0,0 +1 @@ +{"data":[{"vdevice-host-name":"LAB-RTR02","interface":"GigabitEthernet1","color":"biz-internet","private-ip":"198.51.100.12","public-ip":"203.0.113.12","nat-type":"A","operation-state":"up"}]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.1.json new file mode 100644 index 0000000..0840581 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.1.json @@ -0,0 +1,4 @@ +{"data":[ + {"vdevice-host-name":"LAB-CONTROLLER01","ifname":"eth0","af-type":"ipv4","ip-address":"203.0.113.1/24","hwaddr":"02:00:5e:00:53:31","if-admin-status":"Up","if-oper-status":"Up","vpn-id":"0","port-type":"transport","duplex":"full","speed-mbps":"1000"}, + {"vdevice-host-name":"LAB-CONTROLLER01","ifname":"system","af-type":"ipv4","ip-address":"192.0.2.1/32","if-admin-status":"Up","if-oper-status":"Up","vpn-id":"0"} +]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.11.json new file mode 100644 index 0000000..3b7ca28 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.11.json @@ -0,0 +1,7 @@ +{"data":[ + {"vdevice-host-name":"LAB-RTR01","ifname":"GigabitEthernet1","af-type":"ipv6","ip-address":"2001:db8:11::1/64","hwaddr":"02:00:5e:00:53:11","if-admin-status":"if-state-up","if-oper-status":"if-oper-state-ready","vpn-id":"0","port-type":"transport","description":"TRANSPORT biz-internet"}, + {"vdevice-host-name":"LAB-RTR01","ifname":"GigabitEthernet1","af-type":"ipv4","ip-address":"198.51.100.11/24","hwaddr":"02:00:5e:00:53:11","if-admin-status":"if-state-up","if-oper-status":"if-oper-state-ready","vpn-id":"0","port-type":"transport","duplex":"full","mtu":"1500","speed-mbps":1000}, + {"vdevice-host-name":"LAB-RTR01","ifname":"GigabitEthernet2","af-type":"ipv4","ip-address":"203.0.113.65/27","hwaddr":"02:00:5e:00:53:12","if-admin-status":"if-state-up","if-oper-status":"if-oper-state-ready","vpn-id":"10","port-type":"service","description":"LAN BRANCH-00","speed-mbps":"1000"}, + {"vdevice-host-name":"LAB-RTR01","ifname":"Loopback1","af-type":"ipv4","ip-address":"203.0.113.97/32","if-admin-status":"if-state-up","if-oper-status":"if-oper-state-ready","vpn-id":"0","port-type":"service"}, + {"vdevice-host-name":"LAB-RTR01","ifname":"Loopback1","af-type":"ipv4","ip-address":"203.0.113.98/32","if-admin-status":"if-state-up","if-oper-status":"if-oper-state-ready","vpn-id":"10","port-type":"service","description":"VPN 10 router ID"} +]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.12.json new file mode 100644 index 0000000..9094a8f --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/interface/192.0.2.12.json @@ -0,0 +1,4 @@ +{"data":[ + {"vdevice-host-name":"LAB-RTR02","ifname":"GigabitEthernet1","af-type":"ipv4","ip-address":"198.51.100.12/24","hwaddr":"02:00:5e:00:53:21","if-admin-status":"if-state-up","if-oper-status":"if-oper-state-ready","vpn-id":"0","port-type":"transport","description":"TRANSPORT biz-internet","speed-mbps":"1000"}, + {"vdevice-host-name":"LAB-RTR02","ifname":"GigabitEthernet3","af-type":"ipv4","ip-address":"203.0.113.129/27","hwaddr":"02:00:5e:00:53:23","if-admin-status":"if-state-up","if-oper-status":"if-oper-state-lower-layer-down","vpn-id":"10","port-type":"service","description":"LAN OFFICE-00"} +]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/links/up.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/links/up.json new file mode 100644 index 0000000..7f12e44 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/links/up.json @@ -0,0 +1,4 @@ +{"data":[ + {"state":"up","adeviceId":"192.0.2.11","bdeviceId":"192.0.2.1","asystem-ip":"192.0.2.11","bsystem-ip":"192.0.2.1","asite-id":"100","bsite-id":"1000","ahost-name":"LAB-RTR01","bhost-name":"LAB-CONTROLLER01","apersonality":"vedge","bpersonality":"vsmart"}, + {"state":"up","adeviceId":"192.0.2.12","bdeviceId":"192.0.2.1","asystem-ip":"192.0.2.12","bsystem-ip":"192.0.2.1","asite-id":"200","bsite-id":"1000","ahost-name":"LAB-RTR02","bhost-name":"LAB-CONTROLLER01","apersonality":"vedge","bpersonality":"vsmart"} +]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.1.json new file mode 100644 index 0000000..4365735 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.1.json @@ -0,0 +1,4 @@ +{"data":[ + {"vdevice-host-name":"LAB-CONTROLLER01","peer":"192.0.2.11","type":"vedge","state":"up"}, + {"vdevice-host-name":"LAB-CONTROLLER01","peer":"192.0.2.12","type":"vedge","state":"up"} +]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.11.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.11.json new file mode 100644 index 0000000..1647e50 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.11.json @@ -0,0 +1 @@ +{"data":[{"vdevice-host-name":"LAB-RTR01","peer":"192.0.2.1","type":"vsmart","state":"up"}]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.12.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.12.json new file mode 100644 index 0000000..0d5fc91 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/device/omp/peers/192.0.2.12.json @@ -0,0 +1,4 @@ +{"data":[ + {"vdevice-host-name":"LAB-RTR02","peer":"192.0.2.1","type":"vsmart","state":"down"}, + {"vdevice-host-name":"LAB-RTR02","peer":"192.0.2.99","type":"vsmart","state":"up"} +]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/100.json new file mode 100644 index 0000000..d60ebe3 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/100.json @@ -0,0 +1 @@ +{"site_name":"BRANCH-00","data":[]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/1000.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/1000.json new file mode 100644 index 0000000..4eef9d5 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/1000.json @@ -0,0 +1 @@ +{"site_name":"MXP","data":[]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/200.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/200.json new file mode 100644 index 0000000..b2acf57 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/device/site/200.json @@ -0,0 +1 @@ +{"site_name":"OFFICE-00","data":[]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/monitor/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/monitor/site/100.json new file mode 100644 index 0000000..cb79af3 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/monitor/site/100.json @@ -0,0 +1 @@ +{"data":[{"device-id":"192.0.2.11","device-health":"good","circuits":[{"color":"biz-internet","system_ip":"192.0.2.11","circuit-health":"good","tunnels":[{"name":"192.0.2.11:biz-internet-192.0.2.12:biz-internet","health":"good","state":"up","vqoe_score":9}]}]}]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/monitor/site/200.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/monitor/site/200.json new file mode 100644 index 0000000..bfd81c6 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/api/topology/monitor/site/200.json @@ -0,0 +1 @@ +{"data":[{"device-id":"192.0.2.12","device-health":"fair","circuits":[{"color":"biz-internet","system_ip":"192.0.2.12","circuit-health":"fair","tunnels":[{"name":"192.0.2.12:biz-internet-192.0.2.11:biz-internet","health":"fair","state":"up","vqoe_score":0}]}]}]} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/branch_00_golden_audit.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/branch_00_golden_audit.json new file mode 100644 index 0000000..32c1531 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/branch_00_golden_audit.json @@ -0,0 +1,393 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "audit", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "BRANCH-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 5, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "serial_number": "TST0000011", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "certificate_validity": "Valid", + "chassis_number": "C8000V-TST0000011", + "connected_manager": [ + "192.0.2.2" + ], + "device_groups": [ + "TEST-GROUP-A", + "TEST-GROUP-B" + ], + "health": "green", + "last_update": "2026-11-13T12:00:00Z", + "site_id": "100", + "state_description": "All daemons up", + "system_ip": "192.0.2.11", + "up_since": "2026-11-01T08:00:00Z" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "description": "TRANSPORT biz-internet", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "duplex": "full", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "ip_addresses": { + "public_ip": "203.0.113.11" + }, + "mac_address": "02:00:5e:00:53:11", + "mtu": 1500, + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "nat_type": "A" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "type": "network.router.port", + "name": "GigabitEthernet2", + "description": "LAN BRANCH-00", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet2", + "type": "GigabitEthernet2", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet2", + "interface_type": "secondary", + "ip_addresses": { + "public_ip": "203.0.113.65" + }, + "mac_address": "02:00:5e:00:53:12", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-Loopback1", + "type": "network.router.port", + "name": "Loopback1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-Loopback1", + "type": "Loopback1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "Loopback1", + "interface_type": "secondary", + "ip_addresses": { + "public_ip": "203.0.113.97" + }, + "oper_status": "if-oper-state-ready", + "vpn_id": "0" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-Loopback1@vpn10", + "type": "network.router.port", + "name": "Loopback1", + "description": "VPN 10 router ID", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-Loopback1@vpn10", + "type": "Loopback1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "Loopback1", + "interface_type": "secondary", + "ip_addresses": { + "public_ip": "203.0.113.98" + }, + "oper_status": "if-oper-state-ready", + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-1963c56ca41cf931", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet2" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-loopback1-097a0c68d39446ae", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-Loopback1", + "direction": "forward", + "name": "TST0000011 -> Loopback1" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-loopback1-vpn-8edbd37952c943d1", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-Loopback1@vpn10", + "direction": "forward", + "name": "TST0000011 -> Loopback1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp", + "sources": [ + "omp_links", + "omp_peers" + ] + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "vqoe_score": 9 + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", + "name": "BRANCH-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000011", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "cisco.catalystsdwanmanager::TST0000011-Loopback1", + "cisco.catalystsdwanmanager::TST0000011-Loopback1@vpn10" + ], + "properties": { + "geo_location": { + "latitude": 45.5433411, + "longitude": 10.2241237 + } + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/branch_00_golden_documentation.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/branch_00_golden_documentation.json new file mode 100644 index 0000000..85b2d7a --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/branch_00_golden_documentation.json @@ -0,0 +1,351 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "documentation", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "BRANCH-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 5, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "health": "green", + "site_id": "100" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "description": "TRANSPORT biz-internet", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "type": "network.router.port", + "name": "GigabitEthernet2", + "description": "LAN BRANCH-00", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet2", + "type": "GigabitEthernet2", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet2", + "interface_type": "secondary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-Loopback1", + "type": "network.router.port", + "name": "Loopback1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-Loopback1", + "type": "Loopback1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "Loopback1", + "interface_type": "secondary", + "oper_status": "if-oper-state-ready", + "vpn_id": "0" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-Loopback1@vpn10", + "type": "network.router.port", + "name": "Loopback1", + "description": "VPN 10 router ID", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-Loopback1@vpn10", + "type": "Loopback1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "Loopback1", + "interface_type": "secondary", + "oper_status": "if-oper-state-ready", + "vpn_id": "10" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-1963c56ca41cf931", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet2" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-loopback1-097a0c68d39446ae", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-Loopback1", + "direction": "forward", + "name": "TST0000011 -> Loopback1" + }, + { + "id": "conn-contains-tst0000011-to-tst0000011-loopback1-vpn-8edbd37952c943d1", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-Loopback1@vpn10", + "direction": "forward", + "name": "TST0000011 -> Loopback1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp" + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", + "name": "BRANCH-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000011", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet2", + "cisco.catalystsdwanmanager::TST0000011-Loopback1", + "cisco.catalystsdwanmanager::TST0000011-Loopback1@vpn10" + ], + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/mxp_golden_audit.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/mxp_golden_audit.json new file mode 100644 index 0000000..7ac33a8 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/mxp_golden_audit.json @@ -0,0 +1,291 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "audit", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "MXP" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 0, + "operation": "site_topology", + "status": "empty" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 0, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vsmart", + "serial_number": "TST0000301", + "version": "20.18.2.1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "certificate_validity": "Valid", + "device_groups": [ + "No groups" + ], + "health": "green", + "last_update": "2026-11-13T12:00:00Z", + "site_id": "1000", + "state_description": "All daemons up", + "system_ip": "192.0.2.1", + "up_since": "2026-11-01T08:00:00Z" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-eth0", + "type": "network.interface", + "name": "eth0", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301-eth0", + "type": "eth0", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "up", + "properties": { + "admin_status": "up", + "duplex": "full", + "interface_name": "eth0", + "interface_type": "primary", + "ip_addresses": { + "public_ip": "203.0.113.1" + }, + "mac_address": "02:00:5e:00:53:31", + "oper_status": "up", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "default" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-system", + "type": "network.interface", + "name": "system", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301-system", + "type": "system", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "up", + "properties": { + "admin_status": "up", + "interface_name": "system", + "ip_addresses": { + "public_ip": "192.0.2.1" + }, + "oper_status": "up", + "vpn_id": "0" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--11b42c5d91b27833", + "type": "contains", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-system", + "direction": "forward", + "name": "00000000-0000-4000-8000-000000000301 -> system" + }, + { + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--344fec5c3af78bb5", + "type": "contains", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-eth0", + "direction": "forward", + "name": "00000000-0000-4000-8000-000000000301 -> eth0" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp", + "sources": [ + "omp_links", + "omp_peers" + ] + } + } + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000012-020a700b279eb138", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000012", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "unknown", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "observed_states": [ + "down", + "up" + ], + "protocol": "omp", + "sources": [ + "omp_links", + "omp_peers" + ] + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-1000-c6614661399c83ee", + "type": "logical.site", + "name": "MXP", + "members": [ + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-eth0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-system" + ], + "properties": { + "geo_location": { + "latitude": 45.5433411, + "longitude": 10.2241237 + } + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/mxp_golden_documentation.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/mxp_golden_documentation.json new file mode 100644 index 0000000..7c54ad0 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/mxp_golden_documentation.json @@ -0,0 +1,256 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "documentation", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "MXP" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 0, + "operation": "site_topology", + "status": "empty" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 0, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vsmart", + "version": "20.18.2.1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "health": "green", + "site_id": "1000" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-eth0", + "type": "network.interface", + "name": "eth0", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301-eth0", + "type": "eth0", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "up", + "properties": { + "admin_status": "up", + "interface_name": "eth0", + "interface_type": "primary", + "oper_status": "up", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "default" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-system", + "type": "network.interface", + "name": "system", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301-system", + "type": "system", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "up", + "properties": { + "admin_status": "up", + "interface_name": "system", + "oper_status": "up", + "vpn_id": "0" + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200", + "site_role": "neighbor" + } + } + } + ], + "connections": [ + { + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--11b42c5d91b27833", + "type": "contains", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-system", + "direction": "forward", + "name": "00000000-0000-4000-8000-000000000301 -> system" + }, + { + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--344fec5c3af78bb5", + "type": "contains", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-eth0", + "direction": "forward", + "name": "00000000-0000-4000-8000-000000000301 -> eth0" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000011-090e835025039c7a", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000011", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp" + } + } + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000012-020a700b279eb138", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000012", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "unknown", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp" + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-1000-c6614661399c83ee", + "type": "logical.site", + "name": "MXP", + "members": [ + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-eth0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301-system" + ], + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/office_00_golden_audit.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/office_00_golden_audit.json new file mode 100644 index 0000000..18d8c31 --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/office_00_golden_audit.json @@ -0,0 +1,322 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "audit", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "OFFICE-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 1, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "status": "degraded", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "serial_number": "TST0000012", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "certificate_validity": "Valid", + "chassis_number": "C8000V-TST0000012", + "connected_manager": [ + "192.0.2.2" + ], + "health": "yellow", + "last_update": "2026-11-13T12:00:00Z", + "site_id": "200", + "state_description": "Control connection down", + "system_ip": "192.0.2.12", + "up_since": "2026-11-01T08:00:00Z" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "description": "TRANSPORT biz-internet", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "ip_addresses": { + "public_ip": "203.0.113.12" + }, + "mac_address": "02:00:5e:00:53:21", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "nat_type": "A" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet3", + "type": "network.router.port", + "name": "GigabitEthernet3", + "description": "LAN OFFICE-00", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet3", + "type": "GigabitEthernet3", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "status": "inactive", + "state": "if-oper-state-lower-layer-down", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet3", + "interface_type": "secondary", + "ip_addresses": { + "public_ip": "203.0.113.129" + }, + "mac_address": "02:00:5e:00:53:23", + "oper_status": "if-oper-state-lower-layer-down", + "vpn_id": "10" + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-ea5cfa349886fcb8", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet3", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet3" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000012-020a700b279eb138", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000012", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "unknown", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "observed_states": [ + "down", + "up" + ], + "protocol": "omp", + "sources": [ + "omp_links", + "omp_peers" + ] + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "vqoe_score": 0 + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-200-89e627b7e22cfcab", + "type": "logical.site", + "name": "OFFICE-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000012", + "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet3" + ], + "properties": { + "geo_location": { + "latitude": 45.5433411, + "longitude": 10.2241237 + } + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/office_00_golden_documentation.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/office_00_golden_documentation.json new file mode 100644 index 0000000..4be24aa --- /dev/null +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_cross_site/purpose/office_00_golden_documentation.json @@ -0,0 +1,288 @@ +{ + "$schema": "https://osirisjson.org/schema/v1.0/osiris.schema.json", + "version": "1.0.0", + "metadata": { + "timestamp": "2026-11-13T12:00:00Z", + "generator": { + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", + "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" + }, + "scope": { + "purpose": "documentation", + "providers": [ + "cisco.catalystsdwanmanager" + ], + "sites": [ + "OFFICE-00" + ], + "clusters": [ + "lab-manager01.example.com" + ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_links", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 2, + "operation": "omp_peers", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_topology", + "status": "succeeded" + } + ], + "graph": { + "neighbor_devices": 2, + "neighbor_interfaces": 1, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 1, + "unresolved_tunnels": 0 + } + } + }, + "topology": { + "resources": [ + { + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "type": "osiris.cisco.controller", + "name": "LAB-CONTROLLER01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000301", + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "1000", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011", + "type": "network.router", + "name": "LAB-RTR01", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011", + "type": "vedge-C8000V", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000011-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "BRANCH-00", + "system": "lab-manager01.example.com" + }, + "properties": { + "interface_name": "GigabitEthernet1" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet", + "site_role": "neighbor" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012", + "type": "network.router", + "name": "LAB-RTR02", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012", + "type": "vedge-C8000V", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "status": "degraded", + "state": "reachable", + "properties": { + "manufacturer": "Cisco", + "model": "vedge-C8000V", + "version": "17.15.01a" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "health": "yellow", + "site_id": "200" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "type": "network.router.port", + "name": "GigabitEthernet1", + "description": "TRANSPORT biz-internet", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet1", + "type": "GigabitEthernet1", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "status": "active", + "state": "if-oper-state-ready", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet1", + "interface_type": "primary", + "oper_status": "if-oper-state-ready", + "speed_mbps": 1000, + "vpn_id": "0" + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + }, + { + "id": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet3", + "type": "network.router.port", + "name": "GigabitEthernet3", + "description": "LAN OFFICE-00", + "provider": { + "name": "cisco.catalystsdwanmanager", + "native_id": "TST0000012-GigabitEthernet3", + "type": "GigabitEthernet3", + "site": "OFFICE-00", + "system": "lab-manager01.example.com" + }, + "status": "inactive", + "state": "if-oper-state-lower-layer-down", + "properties": { + "admin_status": "if-state-up", + "interface_name": "GigabitEthernet3", + "interface_type": "secondary", + "oper_status": "if-oper-state-lower-layer-down", + "vpn_id": "10" + } + } + ], + "connections": [ + { + "id": "conn-contains-tst0000011-to-tst0000011-gigabitethern-8e1d451d83c44c60", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000011", + "target": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "direction": "forward", + "name": "TST0000011 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-c73e0c244492f606", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet1" + }, + { + "id": "conn-contains-tst0000012-to-tst0000012-gigabitethern-ea5cfa349886fcb8", + "type": "contains", + "source": "cisco.catalystsdwanmanager::TST0000012", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet3", + "direction": "forward", + "name": "TST0000012 -> GigabitEthernet3" + }, + { + "id": "conn-network-00000000-0000-4000-8000--to-tst0000012-020a700b279eb138", + "type": "network", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000301", + "target": "cisco.catalystsdwanmanager::TST0000012", + "direction": "bidirectional", + "name": "OMP Peering", + "status": "unknown", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "protocol": "omp" + } + } + }, + { + "id": "conn-network.vpn-tst0000011-gigabitethern-to-tst0000012-gigabitethern-cb0cc5e0afa00a73", + "type": "network.vpn", + "source": "cisco.catalystsdwanmanager::TST0000011-GigabitEthernet1", + "target": "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "direction": "bidirectional", + "name": "SD-WAN Site-to-Site Tunnel", + "status": "active", + "state": "up", + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "color": "biz-internet" + } + } + } + ], + "groups": [ + { + "id": "group-logical.site-200-89e627b7e22cfcab", + "type": "logical.site", + "name": "OFFICE-00", + "members": [ + "cisco.catalystsdwanmanager::TST0000012", + "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet1", + "cisco.catalystsdwanmanager::TST0000012-GigabitEthernet3" + ], + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "200" + } + } + } + ] + } +} diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device.json similarity index 100% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device.json diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/control/waninterface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/control/waninterface/192.0.2.1.json similarity index 100% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/control/waninterface/192.0.2.1.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/control/waninterface/192.0.2.1.json diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/control/waninterface/192.0.2.101.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/control/waninterface/192.0.2.101.json similarity index 100% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/control/waninterface/192.0.2.101.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/control/waninterface/192.0.2.101.json diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/interface/192.0.2.1.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/interface/192.0.2.1.json similarity index 85% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/interface/192.0.2.1.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/interface/192.0.2.1.json index d5b0b5c..d3d262f 100644 --- a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/interface/192.0.2.1.json +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/interface/192.0.2.1.json @@ -1,6 +1,6 @@ { "data": [ - {"vdevice-host-name": "LAB-MANAGER01", "ifname": "cbr-vmanage", "af-type": "ipv4", "ip-address": "203.0.113.1/24", "hwaddr": "02:00:5e:00:53:01", "if-admin-status": "Down", "if-oper-status": "Up", "vpn-id": "0", "duplex": "full", "speed-mbps": "1000"}, + {"vdevice-host-name": "LAB-MANAGER01", "ifname": "docker0", "af-type": "ipv4", "ip-address": "203.0.113.1/24", "hwaddr": "02:00:5e:00:53:01", "if-admin-status": "Down", "if-oper-status": "Up", "vpn-id": "0", "duplex": "full", "speed-mbps": "1000"}, {"vdevice-host-name": "LAB-MANAGER01", "ifname": "eth0", "af-type": "ipv6", "ip-address": "2001:db8:512::90/64", "hwaddr": "00:00:5e:00:53:10", "if-admin-status": "Up", "if-oper-status": "Up", "vpn-id": "512", "duplex": "full", "speed-mbps": "1000"}, {"vdevice-host-name": "LAB-MANAGER01", "ifname": "eth0", "af-type": "ipv4", "ip-address": "203.0.113.90/24", "hwaddr": "00:00:5e:00:53:10", "if-admin-status": "Up", "if-oper-status": "Up", "vpn-id": "512", "duplex": "full", "speed-mbps": "1000"}, {"vdevice-host-name": "LAB-MANAGER01", "ifname": "eth1", "af-type": "ipv4", "ip-address": "198.51.100.1/24", "hwaddr": "00:00:5e:00:53:11", "if-admin-status": "Up", "if-oper-status": "Up", "vpn-id": "0", "port-type": "transport", "duplex": "full", "speed-mbps": "1000"}, diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/interface/192.0.2.101.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/interface/192.0.2.101.json similarity index 100% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/interface/192.0.2.101.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/interface/192.0.2.101.json diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/interface/192.0.2.201.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/interface/192.0.2.201.json similarity index 100% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/api/device/interface/192.0.2.201.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/device/interface/192.0.2.201.json diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/topology/device/site/100.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/topology/device/site/100.json similarity index 100% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/api/topology/device/site/100.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/api/topology/device/site/100.json diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/purpose/golden_audit.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/purpose/golden_audit.json similarity index 56% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/purpose/golden_audit.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/purpose/golden_audit.json index fdadf96..5e156ba 100644 --- a/testdata/osiris/network/cisco/vmanage/lab_sdwan/purpose/golden_audit.json +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/purpose/golden_audit.json @@ -4,14 +4,14 @@ "metadata": { "timestamp": "2026-11-13T12:00:00Z", "generator": { - "name": "osirisjson-producer-cisco-vmanage", - "version": "0.1.0", + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" }, "scope": { "purpose": "audit", "providers": [ - "cisco.vmanage" + "cisco.catalystsdwanmanager" ], "sites": [ "MXP" @@ -19,30 +19,87 @@ "clusters": [ "lab-manager01.example.com" ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 0, + "operation": "omp_links", + "status": "empty" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 3, + "count": 15, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 3, + "count": 2, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 3, + "count": 0, + "operation": "omp_peers", + "status": "empty" + }, + { + "attempts": 1, + "count": 0, + "operation": "site_topology", + "status": "empty" + } + ], + "graph": { + "neighbor_devices": 0, + "neighbor_interfaces": 0, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } } }, "topology": { "resources": [ { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", "type": "osiris.cisco.controller", "name": "LAB-MANAGER01", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001", - "type": "vmanage" + "type": "vmanage", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "reachable", "properties": { - "management_ip": "192.0.2.1", "manufacturer": "Cisco", "model": "vmanage", "serial_number": "TST0000001", "version": "20.18.2.1" }, "extensions": { - "osiris.cisco.vmanage": { + "osiris.cisco.catalystsdwanmanager": { "certificate_validity": "Valid", "connected_manager": [ "192.0.2.1" @@ -54,25 +111,28 @@ "last_update": "2026-11-13T12:00:00Z", "site_id": "100", "state_description": "All daemons up", + "system_ip": "192.0.2.1", "up_since": "2026-11-01T08:00:00Z" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-cbr-vmanage", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-docker0", "type": "network.interface", - "name": "cbr-vmanage", + "name": "docker0", "provider": { - "name": "cisco.vmanage", - "native_id": "00000000-0000-4000-8000-000000000001-cbr-vmanage", - "type": "cbr-vmanage" + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000001-docker0", + "type": "docker0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "down", "duplex": "full", - "interface_name": "cbr-vmanage", + "interface_name": "docker0", "ip_addresses": { "public_ip": "203.0.113.1" }, @@ -83,13 +143,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth0", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth0", "type": "network.interface", "name": "eth0", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-eth0", - "type": "eth0" + "type": "eth0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -107,13 +169,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth1", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth1", "type": "network.interface", "name": "eth1", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-eth1", - "type": "eth1" + "type": "eth1", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -131,19 +195,21 @@ "vpn_id": "0" }, "extensions": { - "osiris.cisco.vmanage": { + "osiris.cisco.catalystsdwanmanager": { "color": "default" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth2", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth2", "type": "network.interface", "name": "eth2", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-eth2", - "type": "eth2" + "type": "eth2", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "inactive", "state": "down", @@ -158,13 +224,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth3", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth3", "type": "network.interface", "name": "eth3", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-eth3", - "type": "eth3" + "type": "eth3", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "inactive", "state": "down", @@ -179,13 +247,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-system", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-system", "type": "network.interface", "name": "system", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-system", - "type": "system" + "type": "system", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -202,25 +272,26 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", "type": "osiris.cisco.controller", "name": "LAB-CONTROLLER01", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101", - "type": "vsmart" + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "reachable", "properties": { - "management_ip": "192.0.2.101", "manufacturer": "Cisco", "model": "vsmart", "serial_number": "TST0000101", "version": "20.18.2.1" }, "extensions": { - "osiris.cisco.vmanage": { + "osiris.cisco.catalystsdwanmanager": { "certificate_validity": "Valid", "connected_manager": [ "192.0.2.1" @@ -232,18 +303,21 @@ "last_update": "2026-11-13T12:05:00Z", "site_id": "100", "state_description": "All daemons up", + "system_ip": "192.0.2.101", "up_since": "2026-11-01T08:01:00Z" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth0", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth0", "type": "network.interface", "name": "eth0", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-eth0", - "type": "eth0" + "type": "eth0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -259,13 +333,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth1", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth1", "type": "network.interface", "name": "eth1", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-eth1", - "type": "eth1" + "type": "eth1", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -283,19 +359,21 @@ "vpn_id": "0" }, "extensions": { - "osiris.cisco.vmanage": { + "osiris.cisco.catalystsdwanmanager": { "color": "default" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth2", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth2", "type": "network.interface", "name": "eth2", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-eth2", - "type": "eth2" + "type": "eth2", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "inactive", "state": "down", @@ -310,13 +388,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth3", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth3", "type": "network.interface", "name": "eth3", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-eth3", - "type": "eth3" + "type": "eth3", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "inactive", "state": "down", @@ -331,13 +411,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-system", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-system", "type": "network.interface", "name": "system", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-system", - "type": "system" + "type": "system", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -354,25 +436,26 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000201", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", "type": "osiris.cisco.controller", "name": "LAB-VALIDATOR01", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000201", - "type": "vedge-cloud" + "type": "vedge-cloud", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "reachable", "properties": { - "management_ip": "192.0.2.201", "manufacturer": "Cisco", "model": "vedge-cloud", "serial_number": "TST0000201", "version": "20.18.2.1" }, "extensions": { - "osiris.cisco.vmanage": { + "osiris.cisco.catalystsdwanmanager": { "certificate_validity": "Valid", "connected_manager": [ "192.0.2.1" @@ -384,18 +467,21 @@ "last_update": "2026-11-13T12:10:00Z", "site_id": "100", "state_description": "All daemons up", + "system_ip": "192.0.2.201", "up_since": "2026-11-01T08:02:00Z" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000201-eth0", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-eth0", "type": "network.interface", "name": "eth0", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000201-eth0", - "type": "eth0" + "type": "eth0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -411,13 +497,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000201-ge0/0", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-ge0/0", "type": "network.interface", "name": "ge0/0", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000201-ge0/0", - "type": "ge0/0" + "type": "ge0/0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -436,13 +524,15 @@ } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000201-system", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-system", "type": "network.interface", "name": "system", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000201-system", - "type": "system" + "type": "system", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", @@ -461,133 +551,152 @@ ], "connections": [ { - "id": "conn-contains-00000000-0000-4000-8000--to-0-94598e78b44b3e24", + "id": "conn-contains-00000000-0000-4000-8000--to-0-f2a2379887cd15b3", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000201", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000201-ge0/0", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-ge0/0", "direction": "forward", "name": "00000000-0000-4000-8000-000000000201 -> ge0/0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--2d96faaabfbe360f", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--02321f6fc10cf0b7", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000201", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000201-system", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-system", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000201 -> system" + "name": "00000000-0000-4000-8000-000000000101 -> system" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--343c07dafe4e4daf", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--12da9644dbec14df", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth0", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth3", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> eth0" + "name": "00000000-0000-4000-8000-000000000001 -> eth3" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--39295a7b1b160de0", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--440a708c139b2c1c", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-system", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth1", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> system" + "name": "00000000-0000-4000-8000-000000000001 -> eth1" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--3a7557ebaafe5072", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--5308991077237721", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth3", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-system", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> eth3" + "name": "00000000-0000-4000-8000-000000000201 -> system" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--515b02d401977de8", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--5ce9433590f07fc7", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth1", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth1", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> eth1" + "name": "00000000-0000-4000-8000-000000000101 -> eth1" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--5a938e6218c774b0", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--73bf7e9a17d07ea3", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-system", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth2", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000101 -> system" + "name": "00000000-0000-4000-8000-000000000001 -> eth2" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--6108f51217163967", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--7750fada83ba0636", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth2", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth0", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> eth2" + "name": "00000000-0000-4000-8000-000000000001 -> eth0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--7fda7eea2c5d0930", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--ab099ac803bbe0c1", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth3", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth3", "direction": "forward", "name": "00000000-0000-4000-8000-000000000101 -> eth3" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--aff31be5e7e17836", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--b38e2e7e27bcca49", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth1", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-docker0", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000101 -> eth1" + "name": "00000000-0000-4000-8000-000000000001 -> docker0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--b9ae42fe824a6e7c", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--cbf7d1b2c16eaf3d", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000201", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000201-eth0", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth0", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000201 -> eth0" + "name": "00000000-0000-4000-8000-000000000101 -> eth0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--c1d7fda95e397e5c", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--ce610d34f56fe7c7", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth0", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-eth0", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000101 -> eth0" + "name": "00000000-0000-4000-8000-000000000201 -> eth0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--e1c2d707cd59d060", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--d3acd5c29a1803e8", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-cbr-vmanage", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-system", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> cbr-vmanage" + "name": "00000000-0000-4000-8000-000000000001 -> system" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--ecf449099b04700c", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--eda8885545babf93", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth2", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth2", "direction": "forward", "name": "00000000-0000-4000-8000-000000000101 -> eth2" } ], "groups": [ { - "id": "group-physical.room-100-4550929cd72b5c29", - "type": "physical.room", + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", "name": "MXP", "members": [ - "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "cisco.vmanage::00000000-0000-4000-8000-000000000201" + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-docker0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth1", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth2", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth3", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-system", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth1", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth2", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth3", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-system", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-eth0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-ge0/0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-system" ], "properties": { "geo_location": { "latitude": 45.5433411, "longitude": 10.2241237 } + }, + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" + } } } ] diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/purpose/golden_documentation.json b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/purpose/golden_documentation.json similarity index 50% rename from testdata/osiris/network/cisco/vmanage/lab_sdwan/purpose/golden_documentation.json rename to testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/purpose/golden_documentation.json index 0260c63..688fb07 100644 --- a/testdata/osiris/network/cisco/vmanage/lab_sdwan/purpose/golden_documentation.json +++ b/testdata/osiris/network/cisco/catalyst-sd-wan-manager/lab_sdwan/purpose/golden_documentation.json @@ -4,14 +4,14 @@ "metadata": { "timestamp": "2026-11-13T12:00:00Z", "generator": { - "name": "osirisjson-producer-cisco-vmanage", - "version": "0.1.0", + "name": "osirisjson-producer-cisco-catalyst-sdwan-manager", + "version": "0.2.0", "url": "https://docs.osirisjson.org/osiris-producers/network/cisco" }, "scope": { "purpose": "documentation", "providers": [ - "cisco.vmanage" + "cisco.catalystsdwanmanager" ], "sites": [ "MXP" @@ -19,434 +19,445 @@ "clusters": [ "lab-manager01.example.com" ] + }, + "osiris.cisco.catalystsdwanmanager": { + "api_profile": "unverified", + "complete": true, + "coverage": [ + { + "attempts": 1, + "count": 3, + "operation": "device", + "status": "succeeded" + }, + { + "attempts": 1, + "count": 0, + "operation": "omp_links", + "status": "empty" + }, + { + "attempts": 1, + "count": 1, + "operation": "site_name", + "status": "succeeded" + }, + { + "attempts": 3, + "count": 15, + "operation": "device_interface", + "status": "succeeded" + }, + { + "attempts": 3, + "count": 2, + "operation": "wan_interface", + "status": "succeeded" + }, + { + "attempts": 3, + "count": 0, + "operation": "omp_peers", + "status": "empty" + }, + { + "attempts": 1, + "count": 0, + "operation": "site_topology", + "status": "empty" + } + ], + "graph": { + "neighbor_devices": 0, + "neighbor_interfaces": 0, + "unidentified_devices": 0, + "unparsed_tunnels": 0, + "unresolved_omp": 0, + "unresolved_tunnels": 0 + } } }, "topology": { "resources": [ { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", "type": "osiris.cisco.controller", "name": "LAB-MANAGER01", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001", - "type": "vmanage" + "type": "vmanage", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "reachable", "properties": { - "management_ip": "192.0.2.1", "manufacturer": "Cisco", "model": "vmanage", "version": "20.18.2.1" }, "extensions": { - "osiris.cisco.vmanage": { - "connected_manager": [ - "192.0.2.1" - ], - "device_groups": [ - "No groups" - ], + "osiris.cisco.catalystsdwanmanager": { "health": "green", - "last_update": "2026-11-13T12:00:00Z", - "site_id": "100", - "state_description": "All daemons up", - "up_since": "2026-11-01T08:00:00Z" + "site_id": "100" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-cbr-vmanage", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-docker0", "type": "network.interface", - "name": "cbr-vmanage", + "name": "docker0", "provider": { - "name": "cisco.vmanage", - "native_id": "00000000-0000-4000-8000-000000000001-cbr-vmanage", - "type": "cbr-vmanage" + "name": "cisco.catalystsdwanmanager", + "native_id": "00000000-0000-4000-8000-000000000001-docker0", + "type": "docker0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "down", - "duplex": "full", - "interface_name": "cbr-vmanage", - "ip_addresses": { - "public_ip": "203.0.113.1" - }, - "mac_address": "02:00:5e:00:53:01", + "interface_name": "docker0", "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth0", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth0", "type": "network.interface", "name": "eth0", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-eth0", - "type": "eth0" + "type": "eth0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "up", - "duplex": "full", "interface_name": "eth0", - "ip_addresses": { - "public_ip": "203.0.113.90" - }, - "mac_address": "00:00:5e:00:53:10", "oper_status": "up", "speed_mbps": 1000, "vpn_id": "512" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth1", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth1", "type": "network.interface", "name": "eth1", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-eth1", - "type": "eth1" + "type": "eth1", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "up", - "duplex": "full", "interface_name": "eth1", "interface_type": "primary", - "ip_addresses": { - "public_ip": "198.51.100.1" - }, - "mac_address": "00:00:5e:00:53:11", "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" }, "extensions": { - "osiris.cisco.vmanage": { + "osiris.cisco.catalystsdwanmanager": { "color": "default" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth2", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth2", "type": "network.interface", "name": "eth2", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-eth2", - "type": "eth2" + "type": "eth2", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "inactive", "state": "down", "properties": { "admin_status": "down", - "duplex": "full", "interface_name": "eth2", - "mac_address": "00:00:5e:00:53:12", "oper_status": "down", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth3", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth3", "type": "network.interface", "name": "eth3", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-eth3", - "type": "eth3" + "type": "eth3", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "inactive", "state": "down", "properties": { "admin_status": "down", - "duplex": "full", "interface_name": "eth3", - "mac_address": "00:00:5e:00:53:13", "oper_status": "down", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000001-system", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-system", "type": "network.interface", "name": "system", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000001-system", - "type": "system" + "type": "system", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "up", - "duplex": "full", "interface_name": "system", - "ip_addresses": { - "public_ip": "192.0.2.1" - }, "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", "type": "osiris.cisco.controller", "name": "LAB-CONTROLLER01", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101", - "type": "vsmart" + "type": "vsmart", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "reachable", "properties": { - "management_ip": "192.0.2.101", "manufacturer": "Cisco", "model": "vsmart", "version": "20.18.2.1" }, "extensions": { - "osiris.cisco.vmanage": { - "connected_manager": [ - "192.0.2.1" - ], - "device_groups": [ - "No groups" - ], + "osiris.cisco.catalystsdwanmanager": { "health": "green", - "last_update": "2026-11-13T12:05:00Z", - "site_id": "100", - "state_description": "All daemons up", - "up_since": "2026-11-01T08:01:00Z" + "site_id": "100" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth0", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth0", "type": "network.interface", "name": "eth0", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-eth0", - "type": "eth0" + "type": "eth0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "down", - "duplex": "full", "interface_name": "eth0", "interface_type": "secondary", - "mac_address": "00:00:5e:00:53:20", "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth1", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth1", "type": "network.interface", "name": "eth1", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-eth1", - "type": "eth1" + "type": "eth1", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "up", - "duplex": "full", "interface_name": "eth1", "interface_type": "primary", - "ip_addresses": { - "public_ip": "198.51.100.101" - }, - "mac_address": "00:00:5e:00:53:21", "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" }, "extensions": { - "osiris.cisco.vmanage": { + "osiris.cisco.catalystsdwanmanager": { "color": "default" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth2", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth2", "type": "network.interface", "name": "eth2", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-eth2", - "type": "eth2" + "type": "eth2", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "inactive", "state": "down", "properties": { "admin_status": "down", - "duplex": "full", "interface_name": "eth2", - "mac_address": "00:00:5e:00:53:22", "oper_status": "down", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth3", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth3", "type": "network.interface", "name": "eth3", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-eth3", - "type": "eth3" + "type": "eth3", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "inactive", "state": "down", "properties": { "admin_status": "down", - "duplex": "full", "interface_name": "eth3", - "mac_address": "00:00:5e:00:53:23", "oper_status": "down", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000101-system", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-system", "type": "network.interface", "name": "system", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000101-system", - "type": "system" + "type": "system", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "up", - "duplex": "full", "interface_name": "system", - "ip_addresses": { - "public_ip": "192.0.2.101" - }, "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000201", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", "type": "osiris.cisco.controller", "name": "LAB-VALIDATOR01", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000201", - "type": "vedge-cloud" + "type": "vedge-cloud", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "reachable", "properties": { - "management_ip": "192.0.2.201", "manufacturer": "Cisco", "model": "vedge-cloud", "version": "20.18.2.1" }, "extensions": { - "osiris.cisco.vmanage": { - "connected_manager": [ - "192.0.2.1" - ], - "device_groups": [ - "No groups" - ], + "osiris.cisco.catalystsdwanmanager": { "health": "green", - "last_update": "2026-11-13T12:10:00Z", - "site_id": "100", - "state_description": "All daemons up", - "up_since": "2026-11-01T08:02:00Z" + "site_id": "100" } } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000201-eth0", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-eth0", "type": "network.interface", "name": "eth0", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000201-eth0", - "type": "eth0" + "type": "eth0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "down", - "duplex": "full", "interface_name": "eth0", "interface_type": "secondary", - "mac_address": "00:00:5e:00:53:30", "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000201-ge0/0", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-ge0/0", "type": "network.interface", "name": "ge0/0", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000201-ge0/0", - "type": "ge0/0" + "type": "ge0/0", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "up", - "duplex": "full", "interface_name": "ge0/0", "interface_type": "primary", - "ip_addresses": { - "public_ip": "198.51.100.201" - }, - "mac_address": "00:00:5e:00:53:31", "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" } }, { - "id": "cisco.vmanage::00000000-0000-4000-8000-000000000201-system", + "id": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-system", "type": "network.interface", "name": "system", "provider": { - "name": "cisco.vmanage", + "name": "cisco.catalystsdwanmanager", "native_id": "00000000-0000-4000-8000-000000000201-system", - "type": "system" + "type": "system", + "site": "MXP", + "system": "lab-manager01.example.com" }, "status": "active", "state": "up", "properties": { "admin_status": "up", - "duplex": "full", "interface_name": "system", - "ip_addresses": { - "public_ip": "192.0.2.201" - }, "oper_status": "up", "speed_mbps": 1000, "vpn_id": "0" @@ -455,132 +466,145 @@ ], "connections": [ { - "id": "conn-contains-00000000-0000-4000-8000--to-0-94598e78b44b3e24", + "id": "conn-contains-00000000-0000-4000-8000--to-0-f2a2379887cd15b3", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000201", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000201-ge0/0", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-ge0/0", "direction": "forward", "name": "00000000-0000-4000-8000-000000000201 -> ge0/0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--2d96faaabfbe360f", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--02321f6fc10cf0b7", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000201", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000201-system", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-system", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000201 -> system" + "name": "00000000-0000-4000-8000-000000000101 -> system" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--343c07dafe4e4daf", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--12da9644dbec14df", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth0", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth3", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> eth0" + "name": "00000000-0000-4000-8000-000000000001 -> eth3" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--39295a7b1b160de0", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--440a708c139b2c1c", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-system", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth1", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> system" + "name": "00000000-0000-4000-8000-000000000001 -> eth1" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--3a7557ebaafe5072", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--5308991077237721", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth3", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-system", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> eth3" + "name": "00000000-0000-4000-8000-000000000201 -> system" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--515b02d401977de8", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--5ce9433590f07fc7", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth1", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth1", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> eth1" + "name": "00000000-0000-4000-8000-000000000101 -> eth1" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--5a938e6218c774b0", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--73bf7e9a17d07ea3", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-system", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth2", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000101 -> system" + "name": "00000000-0000-4000-8000-000000000001 -> eth2" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--6108f51217163967", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--7750fada83ba0636", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-eth2", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth0", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> eth2" + "name": "00000000-0000-4000-8000-000000000001 -> eth0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--7fda7eea2c5d0930", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--ab099ac803bbe0c1", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth3", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth3", "direction": "forward", "name": "00000000-0000-4000-8000-000000000101 -> eth3" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--aff31be5e7e17836", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--b38e2e7e27bcca49", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth1", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-docker0", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000101 -> eth1" + "name": "00000000-0000-4000-8000-000000000001 -> docker0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--b9ae42fe824a6e7c", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--cbf7d1b2c16eaf3d", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000201", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000201-eth0", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth0", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000201 -> eth0" + "name": "00000000-0000-4000-8000-000000000101 -> eth0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--c1d7fda95e397e5c", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--ce610d34f56fe7c7", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth0", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-eth0", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000101 -> eth0" + "name": "00000000-0000-4000-8000-000000000201 -> eth0" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--e1c2d707cd59d060", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--d3acd5c29a1803e8", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000001-cbr-vmanage", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-system", "direction": "forward", - "name": "00000000-0000-4000-8000-000000000001 -> cbr-vmanage" + "name": "00000000-0000-4000-8000-000000000001 -> system" }, { - "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--ecf449099b04700c", + "id": "conn-contains-00000000-0000-4000-8000--to-00000000-0000-4000-8000--eda8885545babf93", "type": "contains", - "source": "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "target": "cisco.vmanage::00000000-0000-4000-8000-000000000101-eth2", + "source": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "target": "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth2", "direction": "forward", "name": "00000000-0000-4000-8000-000000000101 -> eth2" } ], "groups": [ { - "id": "group-physical.room-100-4550929cd72b5c29", - "type": "physical.room", + "id": "group-logical.site-100-d1fcb94a35f7d7b4", + "type": "logical.site", "name": "MXP", "members": [ - "cisco.vmanage::00000000-0000-4000-8000-000000000001", - "cisco.vmanage::00000000-0000-4000-8000-000000000101", - "cisco.vmanage::00000000-0000-4000-8000-000000000201" + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-docker0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth1", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth2", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-eth3", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000001-system", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth1", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth2", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-eth3", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000101-system", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-eth0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-ge0/0", + "cisco.catalystsdwanmanager::00000000-0000-4000-8000-000000000201-system" ], - "properties": { - "geo_location": { - "latitude": 45.5433411, - "longitude": 10.2241237 + "extensions": { + "osiris.cisco.catalystsdwanmanager": { + "site_id": "100" } } } diff --git a/testdata/osiris/network/cisco/vmanage/README.md b/testdata/osiris/network/cisco/vmanage/README.md deleted file mode 100644 index d2f6431..0000000 --- a/testdata/osiris/network/cisco/vmanage/README.md +++ /dev/null @@ -1,120 +0,0 @@ -# OSIRIS JSON Cisco Catalyst SD-WAN Manager (vManage) producer fixtures - -Synthetic vManage `/dataservice` REST response bodies and the OSIRIS -JSON documents the Cisco Catalyst SD-WAN Manager producer -(`osiris/network/cisco/vmanage`) is expected to emit from them. -`TestGolden` in `golden_test.go` logs in to an in-memory HTTPS vManage -that serves these bodies, runs the full export and compares the emitted -per-site document byte for byte with `purpose/golden_.json`. - -## Layout - -```text - - api/.json # response body of GET /dataservice/ - purpose/ - golden_documentation.json # expected default OSIRIS JSON document - golden_audit.json # expected OSIRIS JSON document using --purpose audit flag -``` - -`` is the endpoint path after `/dataservice/`. A `deviceId` or -`state` query parameter becomes the last path segment: - -| Request | Fixture | -|---|---| -| `GET /dataservice/device` | `api/device.json` | -| `GET /dataservice/tenant` | `api/tenant.json` | -| `GET /dataservice/topology/device/site/{siteId}` | `api/topology/device/site/{siteId}.json` | -| `GET /dataservice/topology/monitor/site/{siteId}` | `api/topology/monitor/site/{siteId}.json` | -| `GET /dataservice/device/interface?deviceId={system-ip}` | `api/device/interface/{system-ip}.json` | -| `GET /dataservice/device/control/waninterface?deviceId={system-ip}` | `api/device/control/waninterface/{system-ip}.json` | -| `GET /dataservice/device/omp/peers?deviceId={system-ip}` | `api/device/omp/peers/{system-ip}.json` | -| `GET /dataservice/device/omp/links?state={state}` | `api/device/omp/links/{state}.json` | - -An endpoint without a fixture file is answered with a valid empty list -(`{"data":[]}`). List bodies use the `{"data": [...]}` envelope. - -The export stamps the wall clock into `metadata.timestamp` and the -controller address it dialed into `metadata.scope.clusters`. The test -checks that the dialed address is the only cluster and then pins both -fields (`2026-11-13T12:00:00Z`, `lab-manager01.example.com`), every -other byte is the producer's own output. - -Besides the byte-for-byte comparison: - -- `TestGolden_PurposeContract` requires that the documentation - document carries no audit-only field (`serial_number`, - `certificate_validity`) and that the audit document carries them. -- `TestGolden_GraphIntegrity` requires that every connection endpoint - and every group member is an emitted resource. - -Unit cases for single response shapes (bare arrays, numeric `speed-mbps` -failed endpoints, raw bodies) are inline in the `_test.go` file that -uses them. - -Validate the expected documents with the canonical CLI before -committing a change to them: - -```bash -./scripts/validate_golden.sh testdata/osiris/network/cisco/vmanage -``` - -## Scenarios - -Each scenario was tested against the matching platform in the -[Cisco DevNet Sandbox](https://developer.cisco.com/sandbox). -Only the structure was taken from the sandbox. Every value is -synthetic, as described below. - -Addresses are RFC 5737 (`192.0.2.0/24`, `198.51.100.0/24`, -`203.0.113.0/24`) and RFC 3849 (`2001:db8::/32`), MAC addresses are -RFC 9542 documentation unicast (`00:00:5E:00:53:xx`) or locally -administered (`02:00:5E:00:53:xx`), device names use the `LAB-` prefix, -serial numbers use the `TST` prefix, device UUIDs are sequential -synthetic values (`00000000-0000-4000-8000-000000000NNN`), the site name -is `MXP` and the coordinates are the approved example location. - -### lab_sdwan - -**Shape:** a Catalyst SD-WAN control-plane site, release 20.18 (see -`version` in `api/device.json`), observed on the DevNet Sandbox SD-WAN -Manager Always On environment. - -**Contains:** site-id `100` (`MXP`) with three controllers, every one -`reachable` and `normal`: - -| Device | Personality | Model | System IP | Interfaces | -|---|---|---|---|---| -| `LAB-MANAGER01` | `vmanage` | `vmanage` | `192.0.2.1` | `cbr-vmanage`, `eth0` (VPN 512), `eth1` (transport), `eth2`, `eth3`, `system` | -| `LAB-CONTROLLER01` | `vsmart` | `vsmart` | `192.0.2.101` | `eth0` (service), `eth1` (transport), `eth2`, `eth3`, `system` | -| `LAB-VALIDATOR01` | `vbond` | `vedge-cloud` | `192.0.2.201` | `eth0` (service), `ge0/0` (transport), `system` | - -The emitted document holds 3 `osiris.cisco.controller` resources, 14 -`network.interface` resources, 14 `contains` connections and one -`physical.room` group for the site with its coordinates. - -Response details that exercise specific transform paths: - -- `latitude` is a string and `longitude` a number, as in the vManage - OpenAPI example for `GET /dataservice/device`. -- Interfaces without an address report `ip-address` as `-`. -- `LAB-MANAGER01` `eth0` is listed twice, IPv6 first, and the IPv4 - entry is the one emitted. -- The Manager and Controller transport interfaces have a WAN interface - entry with color `default` the Validator has none, so its `ge0/0` - carries no color. -- Some interfaces are administratively `Down` but operationally `Up`, - as the sandbox reports for the controllers' service and bridge - interfaces. - -**Deliberately omits:** - -- WAN edges (`vedge`, `cedge`), and with them `network.router` and - `network.router.port` resources, OMP links and peers and SD-WAN - tunnel connections. The sandbox control-plane site has none; the - OMP, site topology monitor and tenant endpoints are answered empty. -- Tenants: `metadata.scope.accounts` is not populated. -- `private_ip` addresses: the producer classifies an interface address - as private only when it is RFC 1918, and every example address here - is RFC 5737, so all interface addresses are emitted as `public_ip`. -- `--include-raw-body` output. diff --git a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/tenant.json b/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/tenant.json deleted file mode 100644 index fe51488..0000000 --- a/testdata/osiris/network/cisco/vmanage/lab_sdwan/api/tenant.json +++ /dev/null @@ -1 +0,0 @@ -[]