Skip to content

Commit 8bd26fc

Browse files
authored
refactor the code (#148)
* initial rework of setup task * rework deploy task * rework delete task * rework sign task and add task for controller * rework add task for validator * rework cml connection to happen inside task * optimize console connection * combine add task for controller and validator * minor enhancements to handle timeouts * add integration tests * update tests * add tests for add task * rework add task for edge * fix ipv6 controller template * rework add task for sdrouting * bump version to 3.0.0b1 in pyproject.toml * update readme * update for 3.0.0b1 * add support for custom cpus/ram in add task * rework backup task * rework restore task * optimize logging and error handling * update tests * fixes and code optimizations * update docs * formatting and minor enhancements * add logout handling to CML connections in delete, images, and setup tasks * add methods to enable MRF and create network hierarchy entry in ManagerClient * refactor _patch_topology to use lambda for user substitution in configuration * fix: improve backup loading by filtering extracted files for security * refactor: simplify node extraction loop by using enumerate * refactor: replace direct SSH handling with context manager for cleaner code * refactor: replace ManagerClient instantiation with connect_manager for improved connection handling * refactor: centralize node extraction logic with topology_nodes utility function * refactor: extract manager mode validation logic into a separate function * refactor: replace hardcoded node definitions with constants for improved maintainability * refactor: replace custom topology dumping logic with utility function for consistency * refactor: rename temporary directory variable for clarity in backup loading * refactor: extract config group ID retrieval into a separate function for reusability * minor fixes * minor code simplifications and doc updates * fix pipeline issues * drop mypy * minor fixes * fix pipeline errors * fix lint * refactor: improve readability of SSH host key policy setting * refactor: simplify comment on SSH host key policy setting * updates based on PR review * drop passlib dependency
1 parent 45d3b4a commit 8bd26fc

1,297 files changed

Lines changed: 6772 additions & 413291 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to PyPi
1+
name: Publish to PyPI
22

33
on:
44
push:
@@ -9,26 +9,20 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
pypi-publish:
13-
name: upload release to PyPI
12+
publish:
13+
name: Build and publish to PyPI
1414
runs-on: ubuntu-latest
15-
defaults:
16-
run:
17-
shell: bash
1815
environment: release
1916
permissions:
2017
id-token: write
2118
steps:
22-
- uses: actions/checkout@v4
23-
- name: Set up Python
24-
uses: actions/setup-python@v5
25-
with:
26-
python-version: 3.11
27-
- name: Set up Poetry
28-
uses: abatilo/actions-poetry@v2.0.0
29-
with:
30-
poetry-version: 1.7.1
31-
- name: Build the package
32-
run: poetry build
33-
- name: Publish package distributions to PyPI
34-
uses: pypa/gh-action-pypi-publish@release/v1
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
23+
24+
- name: Build
25+
run: uv build
26+
27+
- name: Publish to PyPI
28+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0

.github/workflows/scorecard.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,20 @@ name: scorecard
33
on:
44
push:
55
branches:
6-
# Run on pushes to default branch
76
- main
87
schedule:
9-
# Run weekly on Saturdays
108
- cron: "30 1 * * 6"
11-
# Run when branch protection rules change
129
branch_protection_rule:
13-
# Run the workflow manually
1410
workflow_dispatch:
1511

16-
# Declare default permissions as read-only
1712
permissions: read-all
1813

1914
jobs:
2015
run-scorecard:
21-
# Call reusable workflow file
2216
uses: cisco-ospo/.github/.github/workflows/_scorecard.yml@main
2317
permissions:
2418
id-token: write
2519
security-events: write
2620
secrets: inherit
2721
with:
28-
# Publish results of Scorecard analysis
2922
publish-results: true

.github/workflows/test.yml

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Test
2+
23
on:
34
workflow_dispatch:
45
pull_request:
@@ -15,64 +16,32 @@ jobs:
1516
runs-on: ubuntu-latest
1617
timeout-minutes: 5
1718
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2020

21-
- name: Python Setup
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version: "3.12"
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
2523

26-
- name: Lint Checks
27-
run: |
28-
pip install poetry
29-
poetry install
30-
poetry run flake8 catalyst_sdwan_lab
31-
poetry run isort --check --diff --profile black catalyst_sdwan_lab
32-
poetry run black --check catalyst_sdwan_lab
33-
poetry run mypy --show-error-codes --show-error-context --pretty --install-types --non-interactive catalyst_sdwan_lab --cache-dir=.mypy_cache/
24+
- name: Ruff
25+
run: uv run ruff check src/
3426

3527
test:
36-
name: Tests
28+
name: Tests (Python ${{ matrix.python }})
3729
runs-on: ubuntu-latest
3830
timeout-minutes: 10
3931
strategy:
4032
matrix:
4133
python:
42-
- "3.9"
43-
- "3.10"
4434
- "3.11"
4535
- "3.12"
4636
- "3.13"
37+
- "3.14"
4738
steps:
48-
- name: Checkout
49-
uses: actions/checkout@v4
39+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5040

51-
- name: Python Setup
52-
uses: actions/setup-python@v5
41+
- name: Install uv
42+
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5.4.2
5343
with:
5444
python-version: ${{ matrix.python }}
5545

56-
- name: Test
57-
run: |
58-
pip install poetry
59-
poetry install
60-
poetry run sdwan-lab -h
61-
62-
notification:
63-
name: Notification
64-
if: always() && github.event_name != 'pull_request'
65-
needs: [lint, test]
66-
runs-on: ubuntu-latest
67-
timeout-minutes: 5
68-
steps:
69-
- name: Check Job Success
70-
run: |
71-
if [ ${{ needs.lint.result }} == 'success' ] && [ ${{ needs.test.result }} == 'success' ]; then
72-
echo "All jobs succeeded"
73-
echo "jobSuccess=success" >> $GITHUB_ENV
74-
else
75-
echo "Not all jobs succeeded"
76-
echo "jobSuccess=fail" >> $GITHUB_ENV
77-
fi
78-
id: print_status
46+
- name: Run tests
47+
run: uv run pytest tests/ -v

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,7 @@ cython_debug/
197197
catalyst_sdwan_lab/data/certs/rootCA.key
198198
vsdwan.sh
199199
lab.env
200-
backup/
200+
old/
201+
.claude/
202+
CLAUDE.md
203+
*.qcow2

.mypy.ini

Lines changed: 0 additions & 16 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
# Catalyst SD-WAN Lab 2.2.0 [unreleased]
2-
1+
# Catalyst SD-WAN Lab 3.0.0b1 [2026-06-02]
2+
3+
Complete rewrite. The tool is now dependency-minimal with no catalystwan SDK, no pyATS, and no pyOpenSSL.
4+
5+
- Drop `catalystwan` SDK — replaced with a thin `requests`-based Manager HTTP client
6+
- Drop `pyats` / `unicon` — replaced with `paramiko` for SSH access to CML nodes
7+
- Drop `pyOpenSSL` — replaced with direct use of `cryptography`
8+
- Migrate packaging from Poetry to `uv`
9+
- Raise minimum Python version to 3.11
10+
- Raise minimum SD-WAN Manager version to 20.15
11+
- Raise minimum CML version to 2.7
12+
- Add `images` subcommand with `list`, `upload`, and `delete` — moves image management out of `setup`
13+
- Add SD-Routing Edge onboarding via config-group-based flow
14+
- Add `--manager-port` option to `deploy` and `restore` for PATty mode (replaces `pat:<port>` syntax)
15+
- Add `--serial-file` option to `deploy` and `restore` for custom `.viptela` serial files and org name
16+
- Add `--output / -o` option to `sign` to write the signed certificate to a file
17+
- Add `--debug` global flag for HTTP-level request/response logging
18+
- Add `--directory` flag to `backup` to save as an unpacked directory instead of a zip archive
319
- Add support for Catalyst SD-WAN release 26.1.1
4-
- In deploy and restore tasks, add progress status for SD-WAN Manager boot (>26.1.1)
5-
- In deploy and restore tasks, skip initial setup workflow on first UI login (>26.1.1)
20+
- Add progress status for SD-WAN Manager boot in `deploy` and `restore` (Manager >= 26.1.1)
21+
- Skip initial setup workflow on first UI login in `deploy` and `restore` (Manager >= 26.1.1)
22+
- Accept un-padded software versions (`26.1.1` resolved to `26.01.01` automatically)
23+
- Move `setup --list` to `images list` and `setup --delete` to `images delete`
24+
- Rename `--manager``--manager-ip`, `--muser``--manager-user`, `--mpassword``--manager-pass`, `--mmask``--manager-mask`, `--mgateway``--manager-gateway`, `--ip_type``--ip-type`, `--deleteexisting``--delete-existing`, `--contr_version``--contr-version`, `--edge_version``--edge-version`
625

726
# Catalyst SD-WAN Lab 2.1.8 [Mar 5, 2026]
827

CONTRIBUTING.md

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,78 @@
33
Thank you for your interest in contributing to Catalyst SD-WAN Lab! Please take a moment to review this document **before submitting a pull request**:
44

55
- Want to add something yourself? [Make a PR](https://github.com/cisco-open/sdwan-lab-deployment-tool/pulls).
6-
- To make a PR, fork the repository, make your changes, and submit the pull request. Then, wait for review and feedback from our developers.
7-
- Write a clear PR description and include docstrings in your code to make it easily understandable.
8-
- Always write clear log messages for your commits.
9-
- Before submitting a PR, verify that the existing SD-WAN Lab tasks work without any issues (see [Testing Before Pull Requests](#testing-before-pull-requests)).
6+
- Fork the repository, make your changes, and submit the pull request. Then wait for review and feedback.
7+
- Write a clear PR description explaining what changed and why.
8+
- Always write clear commit messages.
9+
- Before submitting a PR, make sure unit tests pass and, where possible, verify that the affected tasks work end-to-end (see [Testing](#testing)).
1010
- For CML interactions, use the official [CML SDK](https://github.com/CiscoDevNet/virl2-client).
11-
- For SD-WAN interactions, use the official [Catalyst WAN SDK](https://github.com/CiscoDevNet/catalystwan).
12-
- Found a bug or have a feature request? [Report it here](https://github.com/cisco-open/sdwan-lab-deployment-tool/issues) and provide as much information as possible.
11+
- For SD-WAN Manager interactions, use the thin `manager_client.py` HTTP client in this repo (direct `requests` calls — no external SDK).
12+
- Found a bug or have a feature request? [Report it here](https://github.com/cisco-open/sdwan-lab-deployment-tool/issues) and provide as much detail as possible.
1313

14-
## Testing Before Pull Requests
14+
## Development Setup
1515

16-
Before opening a pull request, please ensure all tests pass:
16+
This project uses [uv](https://docs.astral.sh/uv/) for packaging and dependency management.
1717

18-
1. Create a virtual environment:
18+
1. Install `uv` if you don't have it:
1919

20-
```
21-
python3 -m venv venv
20+
```sh
21+
curl -LsSf https://astral.sh/uv/install.sh | sh
2222
```
2323

24-
2. Activate the virtual environment:
24+
2. Clone the repository and install dependencies (including dev extras):
2525

26+
```sh
27+
git clone https://github.com/cisco-open/sdwan-lab-deployment-tool.git
28+
cd sdwan-lab-deployment-tool
29+
uv sync
2630
```
27-
source venv/bin/activate
31+
32+
3. Verify the installation:
33+
34+
```sh
35+
uv run csdwan --version
2836
```
2937

30-
The prompt will update with the virtual environment name (`venv`), indicating that it is active.
38+
## Testing
3139

32-
3. Upgrade initial virtual environment packages:
40+
### Unit tests
3341

34-
```
35-
pip install --upgrade pip setuptools pytest
36-
```
42+
Run the unit test suite:
3743

38-
4. Install the tool from your local repository:
44+
```sh
45+
uv run pytest
46+
```
3947

40-
```
41-
pip install --upgrade .
42-
```
48+
### Integration tests
4349

44-
Alternatively, you can install the tool from your branch, for example:
50+
Integration tests run the full CLI against a live CML environment. They are excluded from the default `pytest` run and must be invoked explicitly.
4551

46-
```
47-
pip install git+https://github.com/cisco-open/sdwan-lab-deployment-tool.git@restore_version_change
48-
```
52+
Set the required environment variables (the same ones used in `lab.env`, plus `SDWAN_VERSION`):
4953

50-
5. Load the environment variables used to deploy a test lab:
54+
```sh
55+
export CML_IP='cml.example.com'
56+
export CML_USER='admin'
57+
export CML_PASSWORD='your-password'
58+
export LAB_NAME='sdwan-lab'
59+
export MANAGER_PORT=2000 # PATty mode, or use MANAGER_IP/MANAGER_MASK/MANAGER_GATEWAY
60+
export MANAGER_USER='sdwan'
61+
export MANAGER_PASSWORD='your-manager-password'
62+
export SDWAN_VERSION='20.15.1'
63+
```
5164

52-
```
53-
source lab.env
54-
```
65+
Or simply source your existing `lab.env` and export `SDWAN_VERSION`:
5566

56-
6. Run tests:
67+
```sh
68+
source lab.env
69+
export SDWAN_VERSION=20.15.1
70+
```
5771

58-
```
59-
pytest -s test_csdwan.py
60-
```
72+
Then run all integration tests:
73+
74+
```sh
75+
uv run pytest tests/integration/ -v -s
76+
```
77+
78+
The `-s` flag disables output capture so you can watch the progress of each `csdwan` step in real time. The full workflow test (deploy → add → backup → restore → delete) takes 30–60 minutes depending on your environment.
6179

62-
This will run all tasks and display real-time output. Make sure to resolve any test failures before submitting your PR. If needed, you can modify the control components and edge versions in the test_csdwan.py file.
80+
If any required environment variable is missing, the tests are automatically skipped rather than failing.

0 commit comments

Comments
 (0)