Skip to content

Commit

Permalink
FIX 'defaults' handing in clab topo file
Browse files Browse the repository at this point in the history
  • Loading branch information
wdesmedt committed May 7, 2024
1 parent 9f2ffc2 commit 8bc8fa9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions nornir_srl/fsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,21 @@ def cli(
else:
prefix = f"{topo['prefix']}-{lab_name}-"
hosts: Dict[str, Dict[str, Any]] = {}
def_kind = topo["topology"].get("defaults", {}).get("kind")
srlinux_def = (
True
if "srlinux:" in topo["topology"].get("defaults", {}).get("image", "")
else False
)
srl_kinds = [
k
for k, v in topo["topology"].get("kinds", {}).items()
if "srlinux:" in v.get("image")
]
clab_nodes: Dict[str, Dict] = topo["topology"]["nodes"]
for node, node_spec in clab_nodes.items():
if node_spec.get("kind") == None:
node_spec["kind"] = def_kind
if node_spec["kind"] in srl_kinds:
if (not "kind" in node_spec and srlinux_def) or node_spec.get(
"kind"
) in srl_kinds:
hosts[f"{prefix}{node}"] = {
"hostname": f"{prefix}{node}",
"platform": "srlinux",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nornir-srl"
version = "0.2.11"
version = "0.2.12"
description = "Nornir connection plugin for SRLinux"
authors = ["Walter De Smedt <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 8bc8fa9

Please sign in to comment.