topogen 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a
2
+ # variety of Python versions
3
+ #
4
+ # In addition, code coverage is reported to Coveralls
5
+ #
6
+ # For more information see:
7
+ # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
8
+ #
9
+ # For using output and referencing it in other steps
10
+ # https://stackoverflow.com/questions/58033366/how-to-get-the-current-branch-within-github-actions#58035262
11
+
12
+ name: Python package
13
+
14
+ on: [push]
15
+
16
+ jobs:
17
+ build:
18
+ name: "Build package"
19
+ if: startsWith(github.ref, 'refs/heads/')
20
+ runs-on: ubuntu-latest
21
+ strategy:
22
+ fail-fast: false
23
+ matrix:
24
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
25
+
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ with:
29
+ fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags
30
+
31
+ - name: Install uv
32
+ uses: astral-sh/setup-uv@v2
33
+ with:
34
+ # Install a specific version of uv.
35
+ version: "0.7.9"
36
+
37
+ - name: Set up Python ${{ matrix.python-version }}
38
+ uses: actions/setup-python@v5
39
+ with:
40
+ python-version: ${{ matrix.python-version }}
41
+
42
+ # - name: Create the version file
43
+ # run: |
44
+ # ./version.sh
45
+ # cat src/eve2cml/_version.py
46
+
47
+ - name: Install the project
48
+ run: uv sync --all-extras --dev
49
+
50
+ - name: Check code
51
+ run: |
52
+ uv run mypy --check-untyped-def src
53
+ uv run ruff check
54
+
55
+ # - name: Run tests and check coverage
56
+ # run: |
57
+ # uv run coverage run -m pytest
58
+ # uv run coverage lcov
59
+ #
60
+ # - name: Code Coverage
61
+ # uses: coverallsapp/github-action@v2
62
+ # with:
63
+ # github-token: ${{ secrets.GITHUB_TOKEN }}
64
+ # path-to-lcov: coverage.lcov
@@ -0,0 +1,117 @@
1
+ # publish to pypi
2
+ # push:
3
+ # branches:
4
+ # - main
5
+ # tags:
6
+ # - "0.1.?"
7
+
8
+ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
9
+
10
+ on: [push]
11
+
12
+ jobs:
13
+ build:
14
+ name: Build distribution 📦
15
+ runs-on: ubuntu-latest
16
+ if: startsWith(github.ref, 'refs/tags/')
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags
22
+
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v2
25
+ with:
26
+ # Install a specific version of uv.
27
+ version: "0.7.9"
28
+
29
+ - name: Set up Python
30
+ uses: actions/setup-python@v5
31
+ with:
32
+ python-version-file: ".python-version"
33
+
34
+ - name: Build a binary wheel and a source tarball
35
+ run: |
36
+ # ./version.sh
37
+ uv build
38
+
39
+ - name: Store the distribution packages
40
+ uses: actions/upload-artifact@v4
41
+ with:
42
+ name: python-package-distributions
43
+ path: dist/
44
+
45
+ publish-to-pypi:
46
+ name: >-
47
+ Publish Python 🐍 distribution 📦 to PyPI
48
+ if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
49
+ needs:
50
+ - build
51
+ runs-on: ubuntu-latest
52
+ environment:
53
+ name: pypi
54
+ url: https://pypi.org/p/topogen
55
+ permissions:
56
+ id-token: write # IMPORTANT: mandatory for trusted publishing publish-to-pypi:
57
+ steps:
58
+ - name: Download all the dists
59
+ uses: actions/download-artifact@v4
60
+ with:
61
+ name: python-package-distributions
62
+ path: dist/
63
+ - name: Publish distribution 📦 to PyPI
64
+ uses: pypa/gh-action-pypi-publish@release/v1
65
+
66
+ # - name: Publish Python 🐍 distribution 📦 to PyPI
67
+ # env:
68
+ # TWINE_USERNAME: __token__
69
+ # TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
70
+ # TWINE_REPOSITORY: pypi
71
+ # #
72
+ # run: uvx twine upload dist/*
73
+
74
+ github-release:
75
+ name: >-
76
+ Sign the Python 🐍 distribution 📦 with Sigstore
77
+ and upload them to GitHub Release
78
+ needs:
79
+ - publish-to-pypi
80
+ runs-on: ubuntu-latest
81
+ if: startsWith(github.ref, 'refs/tags/')
82
+
83
+ permissions:
84
+ contents: write # IMPORTANT: mandatory for making GitHub Releases
85
+ id-token: write # IMPORTANT: mandatory for sigstore
86
+
87
+ steps:
88
+ - name: Download all the dists
89
+ uses: actions/download-artifact@v4
90
+ with:
91
+ name: python-package-distributions
92
+ path: dist/
93
+ - name: Sign the dists with Sigstore
94
+ uses: sigstore/gh-action-sigstore-python@v2.1.1
95
+ with:
96
+ inputs: >-
97
+ ./dist/*.tar.gz
98
+ ./dist/*.whl
99
+ - name: Create GitHub Release
100
+ env:
101
+ GITHUB_TOKEN: ${{ github.token }}
102
+ run: >-
103
+ gh release create
104
+ '${{ github.ref_name }}'
105
+ --repo '${{ github.repository }}'
106
+ --draft
107
+ --generate-notes
108
+ - name: Upload artifact signatures to GitHub Release
109
+ env:
110
+ GITHUB_TOKEN: ${{ github.token }}
111
+ # Upload to GitHub Release using the `gh` CLI.
112
+ # `dist/` contains the built packages, and the
113
+ # sigstore-produced signatures and certificates.
114
+ run: >-
115
+ gh release upload
116
+ '${{ github.ref_name }}' dist/**
117
+ --repo '${{ github.repository }}'
@@ -0,0 +1,17 @@
1
+ *.pyc
2
+ dist
3
+ venv
4
+ .venv
5
+ .vscode
6
+ .ipynb_checkpoints
7
+ .ropeproject
8
+ .mise.toml
9
+ __pycache__
10
+
11
+ # VIM
12
+ *.swp
13
+
14
+ # IDE (Pycharm/VS Code)
15
+ .vscode/
16
+ *.code-workspace
17
+
Binary file
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,20 @@
1
+ # Changes
2
+
3
+ This file lists changes.
4
+
5
+ - version 0.2.0
6
+ - properly configure name server / domain name
7
+ - properly inject default route
8
+ - fix indentation for boot.sh script
9
+ - adapted some typing
10
+ - renamed iol.jinja2 to iol-xe.jnja.2
11
+ - added special LXC FRR variant
12
+ - constrain number of node CLI arg
13
+ - fix weird bug when DNS host is selected as the central node
14
+ - updated dependencies
15
+ - version 0.1.4
16
+ - added an IOL template
17
+ - removed requests and associated libraries
18
+ - add support to generate IOL nodes
19
+ - fixed "ignore" SSL errors cmd line flag
20
+ - version 0.1.3 and earlier were the initial release
topogen-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Cisco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
topogen-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,258 @@
1
+ Metadata-Version: 2.4
2
+ Name: topogen
3
+ Version: 0.2.0
4
+ Summary: Generate test topology files and configurations for CML2
5
+ Project-URL: Homepage, https://developer.cisco.com/modeling-labs
6
+ Project-URL: Repository, https://github.com/rschmied/topogen
7
+ Project-URL: Issues, https://github.com/rschmied/topogen/issues
8
+ Project-URL: Changelog, https://github.com/crschmied/topogen/blob/master/CHANGELOG.md
9
+ Author-email: Ralph Schmieder <rschmied@cisco.com>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: automation,network-programming,simulation,tools,virtualization
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Environment :: Console
15
+ Classifier: Intended Audience :: Telecommunications Industry
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Internet
24
+ Requires-Python: >=3.12
25
+ Requires-Dist: enlighten==1.13.0
26
+ Requires-Dist: jinja2==3.1.4
27
+ Requires-Dist: networkx==3.4.2
28
+ Requires-Dist: pyserde[toml]>=0.22.2
29
+ Requires-Dist: virl2-client>=2.7.0
30
+ Provides-Extra: all
31
+ Requires-Dist: numpy>=2.2.0; extra == 'all'
32
+ Requires-Dist: scipy>=1.14.1; extra == 'all'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # TopoGen for CML2
36
+
37
+ This package provides a `topogen` command which can create CML2 topologies.
38
+ It does this by using the PCL (VIRL Python Client Library) to talk to a live
39
+ controller, creating the lab, nodes and links on the fly.
40
+
41
+ ![Demo](.images/demo.gif)
42
+
43
+ ## Features
44
+
45
+ - create topologies of arbitrary size (up to 400 tested, this is N^2)
46
+ - can use templates to provide node configurations (currently a built-in
47
+ DNS host template and an IOSv template exist)
48
+ - provide network numbering for all links (/30) and router loopbacks
49
+ - provide a DNS configuration so that all loopbacks and interface addresses can
50
+ be resolved both from the DNS host as well as from all routers (provided the
51
+ template configures DNS)
52
+ - provide a default route via DNS host, distributed via OSPF
53
+ - provide outbound NAT on the DNS host for the entire network
54
+
55
+ ## Installation
56
+
57
+ > **Important** Ensure that the PCL you install is compatible with your controller.
58
+ If it doesn't work, then try installing the wheel with Pip manually. The wheel can
59
+ be downloaded from your controller at the `/client` location.
60
+
61
+ Steps:
62
+
63
+ 1. clone this directory
64
+ 2. create virtual environment in it `python3 -mvenv .venv`
65
+ 3. activate the venv `source .venv/bin/activate` (or with
66
+ .fish or .bat, ...)
67
+ 4. install using `python3 -mpip install -e .`
68
+
69
+ Alternatively, use Astral/uv:
70
+
71
+ 1. clone this directory
72
+ 2. create the venv: `uv venv`
73
+ 3. activate the venv `source .venv/bin/activate` (optional, can also
74
+ run with `uv run`)
75
+ 4. install using `uv sync --frozen`
76
+
77
+ If the Networkx mode (`--mode nx`) should be used, then the following
78
+ command is required instead to install SciPy and NumPy dependencies: `uv sync
79
+ --all-extras --dev --frozen`
80
+
81
+ At this point, the `topogen` command should be available. Alternatively,
82
+ if you did not activate the venv, use `uv run topogen`.
83
+
84
+ ## Configuration
85
+
86
+ ### CML2
87
+
88
+ CML2 access is provided via the environment. Like shown with this shell snippet:
89
+
90
+ ```shell
91
+ VIRL2_URL="https://cml-controller.cml.lab"
92
+ VIRL2_USER="someuser"
93
+ VIRL2_PASS="somepass"
94
+ export VIRL2_URL VIRL2_USER VIRL2_PASS
95
+ ```
96
+
97
+ In addition, a CA file in PEM format can be provided which can be used to verify
98
+ the cert presented by the controller... The default CA file of the controller is
99
+ included in the repo.
100
+
101
+ For this to work, it's also required to have proper name resolution for the CML2
102
+ controller (e.g. add `192.168.254.123 cml-controller.cml.lab` with **the correct
103
+ IP** into your hosts file).
104
+
105
+ ### Tool
106
+
107
+ The tool accepts a variety of command line switches... they are all listed by
108
+ providing `-h` or `--help`:
109
+
110
+ ```plain
111
+ $ topogen --help
112
+ usage: topogen [-h] [-c CONFIGFILE] [-w] [-v] [-l LOGLEVEL] [-p] [--ca CAFILE] [-i] [-d DISTANCE] [-L LABNAME] [-T TEMPLATE]
113
+ [--list-templates] [-m {nx,simple}]
114
+ [nodes]
115
+
116
+ generate test topology files and configurations for CML2
117
+
118
+ positional arguments:
119
+ nodes Number of nodes to generate
120
+
121
+ optional arguments:
122
+ -h, --help show this help message and exit
123
+ --ca CAFILE Use the CA certificate from this file (PEM format), defaults to ca.pem
124
+ -i, --insecure If no CA provided, do not verify TLS (insecure!)
125
+ -d DISTANCE, --distance DISTANCE
126
+ Node distance, default 200
127
+ -L LABNAME, --labname LABNAME
128
+ Lab name to create, default "topogen lab"
129
+ -T TEMPLATE, --template TEMPLATE
130
+ Template name to use, defaults to "iosv"
131
+ --list-templates List all available templates
132
+ -m {nx,simple}, --mode {nx,simple}
133
+ mode of operation, default is "simple"
134
+
135
+ configuration:
136
+ -c CONFIGFILE, --config CONFIGFILE
137
+ Use the configuration from this file, defaults to config.toml
138
+ -w, --write Write the default configuration to a file and exit
139
+ -v, --version show program's version number and exit
140
+ -l LOGLEVEL, --loglevel LOGLEVEL
141
+ DEBUG, INFO, WARN, ERROR, CRITICAL, defaults to WARN
142
+ -p, --progress show a progress bar
143
+ $
144
+ ```
145
+
146
+ At a minimum, the amount of nodes to be created must be provided.
147
+
148
+ #### Modes
149
+
150
+ There are two modes available right now:
151
+
152
+ - `nx`: this creates a partially meshed topology. It also places nodes in clusters
153
+ which is more pronounced with many nodes (>40).
154
+ - `simple` (which is the default): this creates a single string of nodes, laid out
155
+ in a square / spiral pattern.
156
+
157
+ #### Templates
158
+
159
+ To list the available templates, use the `--list-templates` switch. Currently,
160
+ only an IOSv template is provided.
161
+
162
+ To choose a specific template, provide the `--template=iosv` switch.
163
+
164
+ Currently, all router nodes are using the same template.
165
+
166
+ #### Other Configuration
167
+
168
+ IP address ranges are configured via a configuration file, if present. The
169
+ defaults are like shown here:
170
+
171
+ ```toml
172
+ loopbacks = "10.0.0.0/8"
173
+ p2pnets = "172.16.0.0/12"
174
+ nameserver = "8.8.8.8"
175
+ domainname = "virl.lab"
176
+ username = "cisco"
177
+ password = "cisco"
178
+ ```
179
+
180
+ The username and password are used for the device configurations (e.g. the
181
+ Alpine DNS node and the generated routers). The nameserver value is not used
182
+ at the moment (it is actually replaced with the IP address of the DNS host's
183
+ second interface / NIC facing the router network).
184
+
185
+ ## Operation
186
+
187
+ The topology has an external connector and a DNS-host (based on Alpine). On
188
+ that host, a dnsmasq DNS server is running which can resolve all IP addresses
189
+ of all topology router loopbacks. All topology routers are also using this
190
+ DNS server (assuming they have connectivity to it).
191
+
192
+ > [!NOTE]
193
+ >
194
+ > Since the Alpine node does not include dnsmasq by default, it
195
+ > will pull in and install this package from the Internet. Therefore it
196
+ > is required to have Internet connectivity for this to work! Once the
197
+ > network has been created and full connectivity is established, it
198
+ > should be possible to SSH/Telnet to all nodes using their node names.
199
+ > The below shows logging into the Jumphost (at 192.168.255.100) via
200
+ > the controller (at 192.168.122.245) and then onward to router `r1`
201
+ > using its name.
202
+
203
+ ```plain
204
+ rschmied@delle:~/Projects/topogen$ ssh -tp1122 sysuser@192.168.122.245 ssh cisco@192.168.255.100
205
+ cisco@192.168.255.100's password:
206
+ Welcome to Alpine!
207
+
208
+ The Alpine Wiki contains a large amount of how-to guides and general
209
+ information about administrating Alpine systems.
210
+ See <http://wiki.alpinelinux.org/>.
211
+
212
+ You can setup the system with the command: setup-alpine
213
+
214
+ You may change this message by editing /etc/motd.
215
+
216
+ dns-host:~$ telnet r1
217
+ Connected to r1
218
+
219
+ Entering character mode
220
+ Escape character is '^]'.
221
+
222
+
223
+ **************************************************************************
224
+ * IOSv is strictly limited to use for evaluation, demonstration and IOS *
225
+ * education. IOSv is provided as-is and is not supported by Cisco's *
226
+ * Technical Advisory Center. Any use or disclosure, in whole or in part, *
227
+ * of the IOSv Software or Documentation to any third party for any *
228
+ * purposes is expressly prohibited except as otherwise authorized by *
229
+ * Cisco in writing. *
230
+ **************************************************************************
231
+
232
+ User Access Verification
233
+
234
+ Username: cisco
235
+ Password:
236
+ **************************************************************************
237
+ * IOSv is strictly limited to use for evaluation, demonstration and IOS *
238
+ * education. IOSv is provided as-is and is not supported by Cisco's *
239
+ * Technical Advisory Center. Any use or disclosure, in whole or in part, *
240
+ * of the IOSv Software or Documentation to any third party for any *
241
+ * purposes is expressly prohibited except as otherwise authorized by *
242
+ * Cisco in writing. *
243
+ **************************************************************************
244
+ R1#traceroute 192.168.122.1
245
+ Type escape sequence to abort.
246
+ Tracing the route to 192.168.122.1
247
+ VRF info: (vrf in name/id, vrf out name/id)
248
+ 1 from-r1-gi0-0-to-r9-gi0-0.virl.lab (172.16.0.2) 3 msec
249
+ from-r1-gi0-1-to-r2-gi0-0.virl.lab (172.16.0.6) 9 msec
250
+ from-r1-gi0-2-to-r4-gi0-0.virl.lab (172.16.0.10) 4 msec
251
+ 2 from-r7-gi0-4-to-r9-gi0-2.virl.lab (172.16.0.57) 10 msec
252
+ from-r2-gi0-3-to-r7-gi0-0.virl.lab (172.16.0.22) 18 msec
253
+ from-r4-gi0-2-to-r7-gi0-2.virl.lab (172.16.0.38) 14 msec
254
+ 3 172.16.0.77 7 msec 10 msec 11 msec
255
+ 4 192.168.255.1 11 msec 14 msec 9 msec
256
+ 5 192.168.122.1 13 msec 12 msec 11 msec
257
+ R1#
258
+ ```