Skip to content

Commit 4e57a71

Browse files
authored
Generate the lab topology with a plain image name, not a registry address (#22)
* Generate the lab topology with a plain image name, not a registry address `examples/lab/topology.yaml` is committed and fetched at a tag by netclab-xp, which reads it as documentation as much as it runs it. It named `localhost:5001/netclab/ceos:4.36.1F` -- an address that is correct only on a machine running this repository's bring-up script, and meaningless everywhere else. A reader following netclab-xp's documentation imports cEOS with `docker import` and `kind load`, which leaves it as `ceos:4.36.1F`, so the fetched topology sent them to a registry they do not have. The generator's default becomes that plain name. `--image` already existed and is unchanged, so anything wanting a registry can still ask for one. kind-up.sh is the one consumer that does. It now derives the registry address itself and rewrites a temp copy rather than the committed file -- the file is an artifact other repositories fetch, and the golden test compares it to what the generator produces. The EOS version still comes from the topology, so the model keeps deciding which image the lab runs. Also fixes a trap that the temp-copy trap would have replaced, leaving a regenerated topology behind on exit. * Release v0.1.6 The topology change is consumed by netclab-xp at a tag, so it needs one.
1 parent 37ec3a2 commit 4e57a71

5 files changed

Lines changed: 33 additions & 10 deletions

File tree

examples/lab/topology.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ topology:
66
nodes:
77
- name: dc1-spine1
88
type: ceos
9-
image: localhost:5001/netclab/ceos:4.36.1F
9+
image: ceos:4.36.1F
1010
memory: 2Gi
1111
cpu: 1000m
1212
interfaces:
1313
- name: eth1
1414
network: b1
1515
- name: dc1-leaf1a
1616
type: ceos
17-
image: localhost:5001/netclab/ceos:4.36.1F
17+
image: ceos:4.36.1F
1818
memory: 2Gi
1919
cpu: 1000m
2020
interfaces:

function/netclab_topology.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,17 @@
2727
# the readable link written alongside as a comment.
2828
MAX_IFNAME = 15
2929

30-
CEOS_IMAGE = "localhost:5001/netclab/ceos:4.36.1F"
30+
# No registry, deliberately. The generated topology is committed and fetched at
31+
# a tag by other repositories, so it is read far more often than it is run here
32+
# -- and a machine-local registry address in a published artifact is wrong for
33+
# everyone but the machine that has it. `docker import` + `kind load` names the
34+
# image exactly this way, which is what a reader following netclab-xp's
35+
# documentation ends up with.
36+
#
37+
# Bring-up scripts that do serve cEOS from a registry rewrite this: it is one
38+
# line against a temp copy, and local specifics belong in a script rather than
39+
# in something published. See `scripts/kind-up.sh`.
40+
CEOS_IMAGE = "ceos:4.36.1F"
3141
CEOS_MEMORY = "2Gi"
3242
CEOS_CPU = "1000m"
3343

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "function-avd"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
description = "Living AVD model driven by Crossplane XRs (Fabric -> Device composite function)"
55
readme = "README.md"
66
authors = [

scripts/kind-up.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,21 @@ EOF
191191
else
192192
echo ">> lab topology regenerated for ${LAB_HOSTS}"
193193
TOPO="$(mktemp -t netclab-topology.XXXXXX.yaml)"
194-
trap 'rm -f "$TOPO"' EXIT
194+
TOPO_REGENERATED="$TOPO"
195195
uv run avd-topology "$LAB_FABRIC" --hosts "$LAB_HOSTS" > "$TOPO"
196196
fi
197197

198+
# The topology names the image without a registry -- the name `docker import`
199+
# plus `kind load` leaves, and the one a reader of netclab-xp's documentation
200+
# ends up with. This lab serves cEOS from the local registry instead, because
201+
# that survives teardown. The EOS version still comes from the topology: it is
202+
# generated from the AVD model, so the model decides which image the lab runs.
203+
CEOS_TAG="$(awk '/image:/ {print $2; exit}' "$TOPO")"; CEOS_TAG="${CEOS_TAG##*:}"
204+
CEOS_REPO=${CEOS_REPO:-netclab/ceos}
205+
CEOS_IMG="localhost:${REG_PORT}/${CEOS_REPO}:${CEOS_TAG}"
206+
198207
# cEOS cannot be pulled: it is licensed and needs an Arista login. Fail here
199208
# with the tag the topology asks for, rather than as an ImagePullBackOff later.
200-
CEOS_IMG="$(awk '/image:/ {print $2; exit}' "$TOPO")"
201-
CEOS_REPO="${CEOS_IMG#*/}"; CEOS_REPO="${CEOS_REPO%:*}"
202-
CEOS_TAG="${CEOS_IMG##*:}"
203209
if ! curl -sf "http://localhost:${REG_PORT}/v2/${CEOS_REPO}/tags/list" \
204210
| grep -q "\"${CEOS_TAG}\""; then
205211
echo "!! ${CEOS_IMG} is not in the local registry."
@@ -208,9 +214,16 @@ EOF
208214
exit 1
209215
fi
210216

217+
# Rewrite a copy, never the committed file: it is an artifact other
218+
# repositories fetch at a tag, and `test_topology_golden` compares it to what
219+
# the generator produces.
220+
TOPO_LOCAL="$(mktemp -t netclab-topology-local.XXXXXX.yaml)"
221+
trap 'rm -f "$TOPO_LOCAL" "${TOPO_REGENERATED:-}"' EXIT
222+
sed "s|^\( *image: \).*|\1${CEOS_IMG}|" "$TOPO" > "$TOPO_LOCAL"
223+
211224
echo ">> netclab-chart ${NETCLAB_CHART}"
212225
helm upgrade --install avd netclab/netclab --version "${NETCLAB_CHART}" \
213-
--kube-context "$CTX" -n default -f "$TOPO" >/dev/null
226+
--kube-context "$CTX" -n default -f "$TOPO_LOCAL" >/dev/null
214227
fi
215228

216229
echo

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)