topogen 0.2.2__tar.gz → 0.2.3__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.
- {topogen-0.2.2 → topogen-0.2.3}/.github/workflows/python-package.yml +10 -7
- topogen-0.2.3/.github/workflows/release.yml +110 -0
- {topogen-0.2.2 → topogen-0.2.3}/.gitignore +1 -0
- {topogen-0.2.2 → topogen-0.2.3}/CHANGES.md +9 -0
- {topogen-0.2.2 → topogen-0.2.3}/PKG-INFO +11 -6
- {topogen-0.2.2 → topogen-0.2.3}/README.md +9 -4
- {topogen-0.2.2 → topogen-0.2.3}/pyproject.toml +1 -1
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/colorlog.py +2 -1
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/config.py +4 -4
- topogen-0.2.3/src/topogen/frr.py +25 -0
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/main.py +2 -2
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/models.py +2 -1
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/render.py +25 -25
- topogen-0.2.2/src/topogen/templates/lxc.jinja2 → topogen-0.2.3/src/topogen/templates/frr.jinja2 +0 -1
- topogen-0.2.3/uv.lock +898 -0
- topogen-0.2.2/.github/workflows/release.yml +0 -117
- topogen-0.2.2/src/topogen/lxcfrr.py +0 -33
- topogen-0.2.2/uv.lock +0 -577
- {topogen-0.2.2 → topogen-0.2.3}/.images/demo.gif +0 -0
- {topogen-0.2.2 → topogen-0.2.3}/.python-version +0 -0
- {topogen-0.2.2 → topogen-0.2.3}/LICENSE +0 -0
- {topogen-0.2.2 → topogen-0.2.3}/ca.pem +0 -0
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/__init__.py +1 -1
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/dnshost.py +0 -0
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/templates/__init__.py +0 -0
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/templates/iol-xe.jinja2 +0 -0
- {topogen-0.2.2 → topogen-0.2.3}/src/topogen/templates/iosv.jinja2 +0 -0
|
@@ -13,6 +13,9 @@ name: Python package
|
|
|
13
13
|
|
|
14
14
|
on: [push]
|
|
15
15
|
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
16
19
|
jobs:
|
|
17
20
|
build:
|
|
18
21
|
name: "Build package"
|
|
@@ -21,21 +24,21 @@ jobs:
|
|
|
21
24
|
strategy:
|
|
22
25
|
fail-fast: false
|
|
23
26
|
matrix:
|
|
24
|
-
python-version: ["3.
|
|
27
|
+
python-version: ["3.12", "3.13", "3.14"]
|
|
25
28
|
|
|
26
29
|
steps:
|
|
27
|
-
- uses: actions/checkout@
|
|
30
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
28
31
|
with:
|
|
29
|
-
fetch-depth: 0
|
|
32
|
+
fetch-depth: 0
|
|
33
|
+
persist-credentials: false
|
|
30
34
|
|
|
31
35
|
- name: Install uv
|
|
32
|
-
uses: astral-sh/setup-uv@
|
|
36
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
33
37
|
with:
|
|
34
|
-
|
|
35
|
-
version: "0.7.9"
|
|
38
|
+
version: "0.13.9"
|
|
36
39
|
|
|
37
40
|
- name: Set up Python ${{ matrix.python-version }}
|
|
38
|
-
uses: actions/setup-python@
|
|
41
|
+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
39
42
|
with:
|
|
40
43
|
python-version: ${{ matrix.python-version }}
|
|
41
44
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
name: Publish Python distribution
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
name: Build distribution
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0
|
|
20
|
+
persist-credentials: false
|
|
21
|
+
|
|
22
|
+
- name: Install uv
|
|
23
|
+
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
24
|
+
with:
|
|
25
|
+
version: "0.13.9"
|
|
26
|
+
|
|
27
|
+
- name: Set up Python
|
|
28
|
+
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
|
|
29
|
+
with:
|
|
30
|
+
python-version-file: ".python-version"
|
|
31
|
+
|
|
32
|
+
- name: Verify tag matches package version
|
|
33
|
+
env:
|
|
34
|
+
RELEASE_TAG: ${{ github.ref_name }}
|
|
35
|
+
run: |
|
|
36
|
+
package_version="$(uv version --short)"
|
|
37
|
+
if [[ "$RELEASE_TAG" != "v$package_version" ]]; then
|
|
38
|
+
echo "Tag $RELEASE_TAG does not match package version v$package_version" >&2
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
- name: Build distribution
|
|
43
|
+
run: uv build
|
|
44
|
+
|
|
45
|
+
- name: Store distribution packages
|
|
46
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
47
|
+
with:
|
|
48
|
+
name: python-package-distributions
|
|
49
|
+
path: dist/
|
|
50
|
+
|
|
51
|
+
publish-to-pypi:
|
|
52
|
+
name: Publish distribution to PyPI
|
|
53
|
+
needs: build
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
environment:
|
|
56
|
+
name: pypi
|
|
57
|
+
url: https://pypi.org/p/topogen
|
|
58
|
+
permissions:
|
|
59
|
+
id-token: write
|
|
60
|
+
|
|
61
|
+
steps:
|
|
62
|
+
- name: Download distributions
|
|
63
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
64
|
+
with:
|
|
65
|
+
name: python-package-distributions
|
|
66
|
+
path: dist/
|
|
67
|
+
|
|
68
|
+
- name: Publish distribution
|
|
69
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
|
|
70
|
+
|
|
71
|
+
github-release:
|
|
72
|
+
name: Sign distribution and create draft GitHub release
|
|
73
|
+
needs: publish-to-pypi
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
permissions:
|
|
76
|
+
contents: write
|
|
77
|
+
id-token: write
|
|
78
|
+
env:
|
|
79
|
+
RELEASE_TAG: ${{ github.ref_name }}
|
|
80
|
+
REPOSITORY: ${{ github.repository }}
|
|
81
|
+
|
|
82
|
+
steps:
|
|
83
|
+
- name: Download distributions
|
|
84
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
85
|
+
with:
|
|
86
|
+
name: python-package-distributions
|
|
87
|
+
path: dist/
|
|
88
|
+
|
|
89
|
+
- name: Sign distributions with Sigstore
|
|
90
|
+
uses: sigstore/gh-action-sigstore-python@790bc6befb9d733738f18d8f895854b453640ec9 # v3.5.0
|
|
91
|
+
with:
|
|
92
|
+
inputs: >-
|
|
93
|
+
./dist/*.tar.gz
|
|
94
|
+
./dist/*.whl
|
|
95
|
+
|
|
96
|
+
- name: Create draft GitHub release
|
|
97
|
+
env:
|
|
98
|
+
GH_TOKEN: ${{ github.token }}
|
|
99
|
+
run: >-
|
|
100
|
+
gh release create "$RELEASE_TAG"
|
|
101
|
+
--repo "$REPOSITORY"
|
|
102
|
+
--draft
|
|
103
|
+
--generate-notes
|
|
104
|
+
|
|
105
|
+
- name: Upload assets to GitHub release
|
|
106
|
+
env:
|
|
107
|
+
GH_TOKEN: ${{ github.token }}
|
|
108
|
+
run: >-
|
|
109
|
+
gh release upload "$RELEASE_TAG" dist/*
|
|
110
|
+
--repo "$REPOSITORY"
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
This file lists changes.
|
|
4
4
|
|
|
5
|
+
- version 0.2.3
|
|
6
|
+
- replace the legacy LXC FRR variant with the modern CML FRR Docker node
|
|
7
|
+
- provision the FRR `node.cfg`, `boot.sh`, and `protocols` files
|
|
8
|
+
- update locked dependencies
|
|
9
|
+
- test supported Python versions 3.12 through 3.14
|
|
10
|
+
- harden and fix the release workflow
|
|
11
|
+
- enable the full Ruff rule set and resolve its findings
|
|
12
|
+
- version 0.2.2
|
|
13
|
+
- loosen dependency constraints
|
|
5
14
|
- version 0.2.1 (identical to 0.2.0, but make gh actions happy)
|
|
6
15
|
- version 0.2.0
|
|
7
16
|
- properly configure name server / domain name
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: topogen
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Generate test topology files and configurations for CML2
|
|
5
5
|
Project-URL: Homepage, https://developer.cisco.com/modeling-labs
|
|
6
6
|
Project-URL: Repository, https://github.com/rschmied/topogen
|
|
@@ -156,12 +156,17 @@ There are two modes available right now:
|
|
|
156
156
|
|
|
157
157
|
#### Templates
|
|
158
158
|
|
|
159
|
-
To list the available templates, use the `--list-templates` switch.
|
|
160
|
-
|
|
159
|
+
To list the available templates, use the `--list-templates` switch. Templates
|
|
160
|
+
are provided for IOSv, IOL-XE, and the FRR Docker node from
|
|
161
|
+
[`CiscoLearning/cml-docker-containers`](https://github.com/CiscoLearning/cml-docker-containers/tree/main/containers/frr).
|
|
161
162
|
|
|
162
|
-
|
|
163
|
+
Choose a template with `--template`, for example `--template=iosv` or
|
|
164
|
+
`--template=frr`. The template name must match the CML node-definition ID.
|
|
165
|
+
All router nodes in a generated topology use the selected template.
|
|
163
166
|
|
|
164
|
-
|
|
167
|
+
The FRR node receives its native configuration as `node.cfg`, day-zero commands
|
|
168
|
+
as `boot.sh`, and enabled daemon names as `protocols`, as required by the modern
|
|
169
|
+
FRR Docker node definition.
|
|
165
170
|
|
|
166
171
|
#### Other Configuration
|
|
167
172
|
|
|
@@ -122,12 +122,17 @@ There are two modes available right now:
|
|
|
122
122
|
|
|
123
123
|
#### Templates
|
|
124
124
|
|
|
125
|
-
To list the available templates, use the `--list-templates` switch.
|
|
126
|
-
|
|
125
|
+
To list the available templates, use the `--list-templates` switch. Templates
|
|
126
|
+
are provided for IOSv, IOL-XE, and the FRR Docker node from
|
|
127
|
+
[`CiscoLearning/cml-docker-containers`](https://github.com/CiscoLearning/cml-docker-containers/tree/main/containers/frr).
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
Choose a template with `--template`, for example `--template=iosv` or
|
|
130
|
+
`--template=frr`. The template name must match the CML node-definition ID.
|
|
131
|
+
All router nodes in a generated topology use the selected template.
|
|
129
132
|
|
|
130
|
-
|
|
133
|
+
The FRR node receives its native configuration as `node.cfg`, day-zero commands
|
|
134
|
+
as `boot.sh`, and enabled daemon names as `protocols`, as required by the modern
|
|
135
|
+
FRR Docker node definition.
|
|
131
136
|
|
|
132
137
|
#### Other Configuration
|
|
133
138
|
|
|
@@ -6,6 +6,7 @@ https://stackoverflow.com/questions/384076/how-can-i-color-python-logging-output
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import logging
|
|
9
|
+
from typing import ClassVar
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
class CustomFormatter(logging.Formatter):
|
|
@@ -22,7 +23,7 @@ class CustomFormatter(logging.Formatter):
|
|
|
22
23
|
"%(asctime)s - %(message)s - (%(filename)s:%(lineno)d)"
|
|
23
24
|
)
|
|
24
25
|
|
|
25
|
-
FORMATS = {
|
|
26
|
+
FORMATS: ClassVar[dict[int, str]] = {
|
|
26
27
|
logging.DEBUG: grey + template + reset,
|
|
27
28
|
logging.INFO: cyan + template + reset,
|
|
28
29
|
logging.WARNING: yellow + template + reset,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"""configuration for topogen"""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
-
from dataclasses import dataclass
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
5
|
from ipaddress import IPv4Network
|
|
6
6
|
|
|
7
|
-
from serde import deserialize, serialize
|
|
7
|
+
from serde import SerdeError, deserialize, serialize
|
|
8
8
|
from serde.toml import from_toml, to_toml
|
|
9
9
|
|
|
10
10
|
_LOGGER = logging.getLogger(__name__)
|
|
@@ -16,8 +16,8 @@ _LOGGER = logging.getLogger(__name__)
|
|
|
16
16
|
class Config:
|
|
17
17
|
"""topology generator configuration"""
|
|
18
18
|
|
|
19
|
-
loopbacks: IPv4Network = IPv4Network("10.0.0.0/8")
|
|
20
|
-
p2pnets: IPv4Network = IPv4Network("172.16.0.0/12")
|
|
19
|
+
loopbacks: IPv4Network = field(default_factory=lambda: IPv4Network("10.0.0.0/8"))
|
|
20
|
+
p2pnets: IPv4Network = field(default_factory=lambda: IPv4Network("172.16.0.0/12"))
|
|
21
21
|
nameserver: str = "8.8.8.8"
|
|
22
22
|
domainname: str = "virl.lab"
|
|
23
23
|
username: str = "cisco"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Day-zero configuration for the FRR Docker node."""
|
|
2
|
+
|
|
3
|
+
from textwrap import dedent
|
|
4
|
+
|
|
5
|
+
from jinja2 import BaseLoader, Environment
|
|
6
|
+
|
|
7
|
+
from topogen.config import Config
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def frr_bootconfig(cfg: Config, nameserver: str, dhcp: bool) -> str:
|
|
11
|
+
"""Render the FRR Docker node's boot.sh file."""
|
|
12
|
+
basic_config = dedent(
|
|
13
|
+
r"""
|
|
14
|
+
#!/bin/bash
|
|
15
|
+
{%- if dhcp %}
|
|
16
|
+
/sbin/udhcpc -i eth0
|
|
17
|
+
{%- endif %}
|
|
18
|
+
echo "nameserver {{ nameserver }}" >/etc/resolv.conf
|
|
19
|
+
echo "search {{ config.domainname }}" >>/etc/resolv.conf
|
|
20
|
+
exit 0
|
|
21
|
+
"""
|
|
22
|
+
).lstrip("\n")
|
|
23
|
+
|
|
24
|
+
template = Environment(loader=BaseLoader).from_string(basic_config) # type: ignore
|
|
25
|
+
return template.render(config=cfg, nameserver=nameserver, dhcp=dhcp)
|
|
@@ -9,9 +9,9 @@ import os
|
|
|
9
9
|
import sys
|
|
10
10
|
|
|
11
11
|
import topogen
|
|
12
|
+
from topogen.colorlog import CustomFormatter
|
|
12
13
|
from topogen.models import TopogenError
|
|
13
14
|
from topogen.render import Renderer, get_templates
|
|
14
|
-
from topogen.colorlog import CustomFormatter
|
|
15
15
|
|
|
16
16
|
_LOGGER = logging.getLogger(__name__)
|
|
17
17
|
|
|
@@ -141,7 +141,7 @@ def setup_logging(loglevel: str):
|
|
|
141
141
|
"""sets up the logging, takes the given loglevel and uses the custom,
|
|
142
142
|
colorful log formatter
|
|
143
143
|
"""
|
|
144
|
-
logging.basicConfig(level=logging.
|
|
144
|
+
logging.basicConfig(level=logging.WARNING)
|
|
145
145
|
level, unknown_loglevel = get_log_level(loglevel)
|
|
146
146
|
logging.root.setLevel(level)
|
|
147
147
|
custom_formatter = CustomFormatter()
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass, replace
|
|
4
4
|
from ipaddress import IPv4Address, IPv4Interface
|
|
5
|
+
from typing import ClassVar
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class TopogenError(Exception):
|
|
@@ -19,7 +20,7 @@ class Point:
|
|
|
19
20
|
class CoordsGenerator:
|
|
20
21
|
"""a generator which generates square spiral coordinates"""
|
|
21
22
|
|
|
22
|
-
DIRSM = {"l": "u", "u": "r", "r": "d", "d": "l"}
|
|
23
|
+
DIRSM: ClassVar[dict[str, str]] = {"l": "u", "u": "r", "r": "d", "d": "l"}
|
|
23
24
|
|
|
24
25
|
def __init__(self, distance: int = 200):
|
|
25
26
|
self.distance = distance
|
|
@@ -5,13 +5,12 @@ import logging
|
|
|
5
5
|
import math
|
|
6
6
|
import os
|
|
7
7
|
from argparse import Namespace
|
|
8
|
-
from datetime import
|
|
8
|
+
from datetime import UTC, datetime
|
|
9
9
|
from ipaddress import IPV4LENGTH, IPv4Interface, IPv4Network
|
|
10
|
-
from typing import Any
|
|
10
|
+
from typing import Any
|
|
11
11
|
|
|
12
12
|
import enlighten
|
|
13
13
|
import networkx as nx
|
|
14
|
-
|
|
15
14
|
from httpx import ConnectTimeout, HTTPError
|
|
16
15
|
from jinja2 import (
|
|
17
16
|
Environment,
|
|
@@ -26,7 +25,7 @@ from virl2_client.models import Interface, Lab, Node
|
|
|
26
25
|
from topogen import templates
|
|
27
26
|
from topogen.config import Config
|
|
28
27
|
from topogen.dnshost import dnshostconfig
|
|
29
|
-
from topogen.
|
|
28
|
+
from topogen.frr import frr_bootconfig
|
|
30
29
|
from topogen.models import (
|
|
31
30
|
CoordsGenerator,
|
|
32
31
|
DNShost,
|
|
@@ -59,10 +58,10 @@ def disable_pcl_loggers():
|
|
|
59
58
|
]
|
|
60
59
|
for logger in loggers:
|
|
61
60
|
if logger.name.startswith("virl2_client"):
|
|
62
|
-
logger.setLevel(logging.
|
|
61
|
+
logger.setLevel(logging.WARNING)
|
|
63
62
|
|
|
64
63
|
|
|
65
|
-
def order_iface_pair(iface_pair: dict, this: int) ->
|
|
64
|
+
def order_iface_pair(iface_pair: dict, this: int) -> tuple[Any, Any]:
|
|
66
65
|
"""order the interface pair so that the first one is the one with the
|
|
67
66
|
given index "this", and the second one is the other one.
|
|
68
67
|
"""
|
|
@@ -157,7 +156,7 @@ class Renderer:
|
|
|
157
156
|
|
|
158
157
|
def initialize_client(self) -> ClientLibrary:
|
|
159
158
|
"""initialize the PCL"""
|
|
160
|
-
cainfo:
|
|
159
|
+
cainfo: bool | str = self.args.cafile
|
|
161
160
|
try:
|
|
162
161
|
os.stat(self.args.cafile)
|
|
163
162
|
except (FileNotFoundError, TypeError):
|
|
@@ -215,8 +214,9 @@ class Renderer:
|
|
|
215
214
|
graph.nodes[key]["pos"] = Point(int(value[0]), int(value[1]))
|
|
216
215
|
return graph
|
|
217
216
|
|
|
218
|
-
def create_node(self, label: str, node_def: str, coords
|
|
217
|
+
def create_node(self, label: str, node_def: str, coords: Point | None = None):
|
|
219
218
|
"""create a CML2 node with the given attributes"""
|
|
219
|
+
coords = coords or Point(0, 0)
|
|
220
220
|
|
|
221
221
|
try:
|
|
222
222
|
node = self.lab.create_node(
|
|
@@ -233,24 +233,24 @@ class Renderer:
|
|
|
233
233
|
except HTTPError as exc:
|
|
234
234
|
raise TopogenError("API error") from exc
|
|
235
235
|
|
|
236
|
-
def create_ext_conn(self, coords
|
|
236
|
+
def create_ext_conn(self, coords: Point | None = None):
|
|
237
237
|
"""create an external connector node"""
|
|
238
238
|
return self.create_node(EXT_CON_NAME, "external_connector", coords)
|
|
239
239
|
|
|
240
|
-
def create_dns_host(self, coords
|
|
240
|
+
def create_dns_host(self, coords: Point | None = None):
|
|
241
241
|
"""create the DNS host node"""
|
|
242
242
|
node = self.create_node(DNS_HOST_NAME, "alpine", coords)
|
|
243
243
|
node.create_interface() # this is eth1
|
|
244
244
|
return node
|
|
245
245
|
|
|
246
|
-
def create_router(self, label: str, coords
|
|
246
|
+
def create_router(self, label: str, coords: Point | None = None):
|
|
247
247
|
"""create a router node (this uses the template given, e.g. iosv)"""
|
|
248
248
|
return self.create_node(label, self.args.template, coords)
|
|
249
249
|
|
|
250
|
-
def next_network(self) ->
|
|
250
|
+
def next_network(self) -> set[IPv4Interface]:
|
|
251
251
|
"""return the next point-to-point network"""
|
|
252
252
|
p2pnet = next(self.p2pnets)
|
|
253
|
-
return
|
|
253
|
+
return {IPv4Interface(f"{i}/{p2pnet.netmask}") for i in p2pnet.hosts()}
|
|
254
254
|
|
|
255
255
|
def render_node_network(self) -> int:
|
|
256
256
|
"""render the NX random network"""
|
|
@@ -331,16 +331,14 @@ class Renderer:
|
|
|
331
331
|
)
|
|
332
332
|
_LOGGER.warning("Creating ext-conn link")
|
|
333
333
|
|
|
334
|
-
core =
|
|
335
|
-
nx.degree_centrality(graph).items(), key=lambda e: e[1], reverse=True
|
|
336
|
-
)[0][0]
|
|
334
|
+
core = max(nx.degree_centrality(graph).items(), key=lambda e: e[1])[0]
|
|
337
335
|
_LOGGER.warning("Identified core node is R%s", core + 1)
|
|
338
336
|
|
|
339
337
|
_LOGGER.warning("Creating node configurations")
|
|
340
338
|
for node_index, nbrs in graph.adj.items():
|
|
341
339
|
interfaces: list[TopogenInterface] = []
|
|
342
340
|
|
|
343
|
-
for
|
|
341
|
+
for eattr in nbrs.values():
|
|
344
342
|
prefix = eattr["prefix"]
|
|
345
343
|
hosts = eattr["hosts"]
|
|
346
344
|
order = eattr["order"]
|
|
@@ -400,31 +398,33 @@ class Renderer:
|
|
|
400
398
|
config = self.template.render(
|
|
401
399
|
config=self.config,
|
|
402
400
|
node=node,
|
|
403
|
-
date=datetime.now(
|
|
401
|
+
date=datetime.now(UTC),
|
|
404
402
|
origin="" if node_index != core else dns_addr,
|
|
405
403
|
)
|
|
406
404
|
cmlnode: Node = graph.nodes[node_index]["cml2node"]
|
|
407
405
|
if cmlnode is None:
|
|
408
406
|
continue
|
|
409
|
-
#
|
|
410
|
-
if self.args.template == "
|
|
407
|
+
# The FRR Docker node uses three provisioned configuration files.
|
|
408
|
+
if self.args.template == "frr":
|
|
411
409
|
nameserver = (
|
|
412
410
|
self.config.nameserver if self.config.nameserver else dns_addr.ip
|
|
413
411
|
)
|
|
414
412
|
cfg = [
|
|
413
|
+
{
|
|
414
|
+
"name": "node.cfg",
|
|
415
|
+
"content": config,
|
|
416
|
+
},
|
|
415
417
|
{
|
|
416
418
|
"name": "boot.sh",
|
|
417
|
-
"content":
|
|
419
|
+
"content": frr_bootconfig(
|
|
418
420
|
self.config,
|
|
419
|
-
node,
|
|
420
|
-
["ospf", "bgp"],
|
|
421
421
|
str(nameserver),
|
|
422
422
|
False,
|
|
423
423
|
),
|
|
424
424
|
},
|
|
425
425
|
{
|
|
426
|
-
"name": "
|
|
427
|
-
"content":
|
|
426
|
+
"name": "protocols",
|
|
427
|
+
"content": "ospfd\nbgpd\n",
|
|
428
428
|
},
|
|
429
429
|
]
|
|
430
430
|
cmlnode.configuration = cfg # type: ignore[method-assign]
|