|
1 | | -# nac-nd |
| 1 | +# nac-analytics |
2 | 2 |
|
3 | 3 | > **In development** — install from source today; PyPI release planned. |
| 4 | +> Formerly **nac-nd**. Today it covers Cisco ACI via Nexus Dashboard 4.2.1+; the intent is to grow beyond Nexus Dashboard and add support for additional Cisco products, so one tool can drive change analytics across platforms. |
4 | 5 |
|
5 | | -CLI for change analysis on Cisco ACI fabrics via Nexus Dashboard 4.2.1+. Upload a candidate configuration, compare snapshots, or check compliance. |
| 6 | +CLI for change analysis on Cisco ACI fabrics via Nexus Dashboard 4.2.1+. |
6 | 7 |
|
7 | | -**Requirements:** Nexus Dashboard 4.2.1+, Python 3.10+, an ACI fabric registered in Nexus Dashboard. |
| 8 | +Commands are grouped per Cisco product: `nac-analytics <product> <command>`. |
| 9 | +Today the product is `nexus-dashboard` (alias `nd`); more products are planned. |
| 10 | + |
| 11 | +## Installation |
8 | 12 |
|
9 | | -## Install (from source) |
| 13 | +**Requirements:** Nexus Dashboard 4.2.1+, Python 3.10+, an ACI fabric registered in Nexus Dashboard. |
10 | 14 |
|
11 | 15 | ```bash |
12 | | -git clone https://github.com/netascode/nac-nd.git |
13 | | -cd nac-nd |
| 16 | +git clone https://github.com/netascode/nac-analytics.git |
| 17 | +cd nac-analytics |
14 | 18 | uv sync --group dev |
15 | | -uv run nac-nd --help |
| 19 | +uv run nac-analytics --help |
16 | 20 | ``` |
17 | 21 |
|
18 | | -PyPI install (`pip install nac-nd` / `uv tool install nac-nd`) will be added when the first release is published. |
19 | | - |
20 | 22 | ## Quick start |
21 | 23 |
|
22 | 24 | ```bash |
23 | | -cp config.example.yaml nac-nd.yaml # edit host, fabric, domain |
24 | | -cp .env.example .env # set ND_USER and ND_PASSWORD (gitignored) |
25 | | -uv run nac-nd doctor |
| 25 | +cp config.example.yaml nac-analytics.yaml # edit host, fabric, domain |
| 26 | +cp .env.example .env # set ND_USER and ND_PASSWORD |
| 27 | +uv run nac-analytics nd doctor |
26 | 28 | ``` |
27 | 29 |
|
28 | | -Run `nac-nd <command> --help` for all options. |
29 | | - |
30 | | -## Configuration |
31 | | - |
32 | | -Settings resolve in order: **CLI flags → environment variables → YAML → `.env` in cwd**. |
33 | | - |
34 | | -| YAML key | Environment variable | Notes | |
35 | | -| --- | --- | --- | |
36 | | -| `host` | `ND_HOST` | Nexus Dashboard hostname (optional `http://` prefix) | |
37 | | -| `username` / `user` | `ND_USER` | | |
38 | | -| `password` | `ND_PASSWORD` | Keep in env/CI secrets, not YAML | |
39 | | -| `domain` | `ND_DOMAIN` | Default `DefaultAuth` | |
40 | | -| `fabric` | `ND_FABRIC` | Default fabric for commands | |
41 | | -| `fabrics` | — | List for `compliance --all` | |
42 | | -| `verify_ssl` / `verify_tls` | `ND_VERIFY_SSL` | `ND_VERIFY_TLS` accepted as alias | |
43 | | -| `ca_bundle` | `ND_CA_BUNDLE` | | |
44 | | -| `job_timeout_minutes` | `ND_JOB_TIMEOUT_MINUTES` | | |
45 | | -| `poll_interval` | `ND_POLL_INTERVAL` | | |
46 | | -| `delta_detail` | `ND_DELTA_DETAIL` | Overrides `--detail` default | |
47 | | - |
48 | | -Config file locations: `--config path`, `ND_CONFIG`, `./nac-nd.yaml`, or `~/.config/nac-nd/config.yaml`. |
49 | | - |
50 | | -## Commands |
51 | | - |
52 | | -All primary inputs use **positional arguments** (not flags): |
| 30 | +## Exit codes |
53 | 31 |
|
54 | | -| Command | Syntax | |
| 32 | +| Code | Meaning | |
55 | 33 | | --- | --- | |
56 | | -| `prechange` | `nac-nd prechange <plan.json> [<baseline>]` or `nac-nd prechange --job-id <id>` | |
57 | | -| `snapshots` | `nac-nd snapshots <selector>` | |
58 | | -| `delta` | `nac-nd delta [<pre>] [<post>]` | |
59 | | - |
60 | | -`prechange` and `delta` are **gate commands**: they fail on new `critical`/`major` anomalies by default, write JUnit to `prechange-report.xml` / `delta-report.xml`, and print a one-line verdict on stderr. Use `--output text` for a full human-readable report. |
61 | | - |
62 | | -### doctor — check connectivity |
63 | | - |
64 | | -```bash |
65 | | -nac-nd doctor |
66 | | -``` |
67 | | - |
68 | | -### prechange — Terraform plan (Network as Code) |
69 | | - |
70 | | -Use with [Network as Code](https://netascode.cisco.com) projects: run `terraform plan`, export JSON, analyse before apply. |
71 | | - |
72 | | -```bash |
73 | | -terraform plan -out=plan.tfplan |
74 | | -terraform show -json plan.tfplan > plan.json |
75 | | -nac-nd prechange plan.json |
76 | | -``` |
77 | | - |
78 | | -- **Exit 0** — DECISION: PASS |
79 | | -- **Exit 3** — DECISION: FAIL |
80 | | -- Writes `prechange-report.xml` automatically |
81 | | -- Use `--fail-on none` to report only (always exit 0) |
82 | | -- Use `--output text` for the full change-approval report on stdout |
83 | | - |
84 | | -Optional baseline positional (defaults to `latest`): |
85 | | - |
86 | | -```bash |
87 | | -nac-nd prechange plan.json latest-1 |
88 | | -``` |
89 | | - |
90 | | -Resume or fetch an existing analysis (no re-upload) — useful after a timeout while ND was still queued: |
91 | | - |
92 | | -```bash |
93 | | -nac-nd prechange --job-id <job-id> --fail-on none |
94 | | -``` |
95 | | - |
96 | | -`--job-id` waits if the job is still running, then writes the report from the completed result. |
97 | | - |
98 | | -### prechange — APIC MO JSON |
99 | | - |
100 | | -```bash |
101 | | -nac-nd prechange examples/minimal-change.json --output text |
102 | | -``` |
103 | | - |
104 | | -### snapshots — pin a snapshot ID |
105 | | - |
106 | | -```bash |
107 | | -SNAPSHOT_ID=$(nac-nd snapshots latest) |
108 | | -``` |
109 | | - |
110 | | -Text output is the snapshot ID only (for `$()` capture). Use `--output json` for the full record. |
111 | | - |
112 | | -### delta — compare snapshots |
113 | | - |
114 | | -```bash |
115 | | -nac-nd delta # latest-1 vs latest (ad-hoc only) |
116 | | -nac-nd delta abc-123 # pinned pre, post defaults to latest |
117 | | -nac-nd delta abc-123 def-456 # both pinned |
118 | | -``` |
119 | | - |
120 | | -Writes `delta-report.xml` by default. Selectors: `latest`, `latest-N`, or a snapshot ID. |
121 | | - |
122 | | -### compliance — rule status |
123 | | - |
124 | | -```bash |
125 | | -nac-nd compliance |
126 | | -nac-nd --config nac-nd.yaml compliance --all --fail-on-violations |
127 | | -``` |
128 | | - |
129 | | -## CI/CD |
130 | | - |
131 | | -Gate commands need **no extra flags** in CI — fail on exit code, not by parsing output: |
132 | | - |
133 | | -```yaml |
134 | | -- name: Pre-change analysis |
135 | | - run: nac-nd prechange plan.json |
136 | | - |
137 | | -- name: Pin baseline snapshot |
138 | | - id: baseline |
139 | | - run: echo "snapshot_id=$(nac-nd snapshots latest)" >> "$GITHUB_OUTPUT" |
| 34 | +| 0 | Success; threshold not breached | |
| 35 | +| 1 | Unexpected error | |
| 36 | +| 2 | Analysis job failed, stopped, vanished, or timed out | |
| 37 | +| 3 | New anomalies at `--fail-on` (or compliance violations with `--fail-on-violations`) | |
| 38 | +| 4 | Bad input, config, or configuration rejected by Nexus Dashboard | |
| 39 | +| 5 | Authentication or authorisation failure | |
140 | 40 |
|
141 | | -- run: terraform apply -auto-approve plan.tfplan |
| 41 | +## Nexus Dashboard commands |
142 | 42 |
|
143 | | -- name: Post-apply delta |
144 | | - run: nac-nd delta "${{ steps.baseline.outputs.snapshot_id }}" |
145 | 43 | ``` |
146 | | -
|
147 | | -Pin the baseline snapshot ID saved **before** apply. Do not rely on `nac-nd delta` with no arguments in CI — another snapshot may arrive between stages. |
148 | | - |
149 | | -Optional: upload auto-generated reports: |
150 | | - |
151 | | -```yaml |
152 | | -- uses: actions/upload-artifact@v4 |
153 | | - if: always() |
154 | | - with: |
155 | | - name: nd-reports |
156 | | - path: | |
157 | | - prechange-report.xml |
158 | | - delta-report.xml |
| 44 | +$ nac-analytics nexus-dashboard --help |
| 45 | +
|
| 46 | +Usage: nac-analytics nexus-dashboard [OPTIONS] COMMAND [ARGS]... |
| 47 | +
|
| 48 | +Change analysis for Cisco Nexus Dashboard 4.2.1+ (GA REST APIs, ACI). |
| 49 | +
|
| 50 | +Configuration: |
| 51 | + ND_HOST Nexus Dashboard hostname or IP |
| 52 | + ND_USER Login username |
| 53 | + ND_PASSWORD Login password |
| 54 | + ND_DOMAIN Login domain |
| 55 | + ND_FABRIC Default ACI fabric name |
| 56 | + ND_VERIFY_SSL Verify TLS certificate (ND_VERIFY_TLS accepted) |
| 57 | + ND_CA_BUNDLE Path to CA bundle |
| 58 | + ND_JOB_TIMEOUT_MINUTES Minutes to wait for analysis jobs |
| 59 | + ND_POLL_INTERVAL Seconds between job status polls |
| 60 | + ND_DELTA_DETAIL Default --detail for prechange and delta |
| 61 | + ND_CONFIG Path to YAML config file |
| 62 | +
|
| 63 | +In YAML, nest these under a `nexus_dashboard:` section. Settings load from |
| 64 | +CLI flags, then environment variables, nac-analytics.yaml, or .env. |
| 65 | +
|
| 66 | +Options: |
| 67 | + --help Show this message and exit. |
| 68 | +
|
| 69 | +Commands: |
| 70 | + prechange Analyse a candidate configuration against a fabric's current state. |
| 71 | + delta Compare two snapshots of a fabric and report what changed. |
| 72 | + snapshots Resolve a fabric snapshot and print its ID (for CI baseline pinning). |
| 73 | + compliance Report compliance rule status for a fabric (or every fabric with --all). |
| 74 | + doctor Check connectivity, credentials, and fabric visibility. |
159 | 75 | ``` |
160 | 76 |
|
161 | | -### Local full pipeline |
| 77 | +Verb-level usage and examples: [command reference](docs/commands/README.md). |
162 | 78 |
|
163 | | -After exporting a Terraform plan from `examples/terraform`: |
| 79 | +## Configuration |
164 | 80 |
|
165 | | -```bash |
166 | | -PLAN_FILE=examples/terraform/plan.json ./examples/ci-pipeline.sh |
167 | | -``` |
| 81 | +Precedence: CLI flags → environment variables → YAML → `.env` in cwd. |
168 | 82 |
|
169 | | -See [examples/README.md](examples/README.md) for APIC credentials and apply steps. |
| 83 | +Settings are scoped per product. See [config.example.yaml](config.example.yaml) and [Configuration](docs/configuration.md) for the full variable list and YAML layout. |
170 | 84 |
|
171 | | -## Exit codes |
| 85 | +## Documentation |
172 | 86 |
|
173 | | -| Code | Meaning | |
| 87 | +| Topic | Link | |
174 | 88 | | --- | --- | |
175 | | -| 0 | Success; threshold not breached | |
176 | | -| 1 | Unexpected error | |
177 | | -| 2 | Analysis job failed, stopped, vanished, or timed out | |
178 | | -| 3 | New anomalies at `--fail-on` (or compliance violations with `--fail-on-violations`) | |
179 | | -| 4 | Bad input, config, or configuration rejected by Nexus Dashboard | |
180 | | -| 5 | Authentication or authorisation failure | |
| 89 | +| Documentation hub | [docs/README.md](docs/README.md) | |
| 90 | +| Command reference (global + verbs) | [docs/commands/README.md](docs/commands/README.md) | |
| 91 | +| Configuration | [docs/configuration.md](docs/configuration.md) | |
| 92 | +| Development | [docs/development.md](docs/development.md) | |
| 93 | +| Examples & CI pipeline | [examples/README.md](examples/README.md) | |
181 | 94 |
|
182 | 95 | ## Development |
183 | 96 |
|
184 | | -```bash |
185 | | -uv sync --group dev |
186 | | -uv run pytest |
187 | | -uv run ruff check . |
188 | | -uv run ruff format --check . |
189 | | -uv run python -m mypy nac_nd |
190 | | -``` |
| 97 | +Contributors: see [Development](docs/development.md). |
0 commit comments