Skip to content

Commit 334ba57

Browse files
mbakalarskiclaude
andauthored
Rename removeContainer to removeSection (#19)
"container" is the wrong word in a Kubernetes API: it already means a pod container, so `removeContainer: true` on a resource that configures a router reads as something it is not. What the flag actually does is take out the enclosing EOS config section -- `no router bgp 65001` -- rather than entering that section and negating one line inside it. "section" is the device's own vocabulary: `show running-config section bgp`. The flag now says what it does without a guess. Breaking: the XR spec field is renamed, so netclab-xp's EosCommand XRD has to move with it. The flag only ever applies to a nested `cmds` path; a single-line path is still removed as itself. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
1 parent 2332202 commit 334ba57

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

example/xr1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: eoscommand-1
55
spec:
66
endpoint: ceos01.default.svc.cluster.local
7-
removeContainer: false
7+
removeSection: false
88
cmds:
99
no spanning-tree vlan-id 4093-4094: {}
1010
ip prefix-list PL-Loopback0:

example/xr2.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: eoscommand-2
55
spec:
66
endpoint: ceos01.default.svc.cluster.local
7-
removeContainer: true
7+
removeSection: true
88
cmds:
99
no spanning-tree vlan-id 4093-4094: {}
1010
ip prefix-list PL-Loopback0:

function/fn.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ async def RunFunction(
5353
observed_xr_namespace = observed_xr.get("metadata").get("namespace")
5454
fqdn = observed_xr["spec"].get("endpoint")
5555
cmds = observed_xr["spec"].get("cmds")
56-
remove_container = observed_xr["spec"].get("removeContainer")
56+
remove_section = observed_xr["spec"].get("removeSection")
5757

5858
environment = resource.struct_to_dict(
5959
req.context["apiextensions.crossplane.io/environment"]
@@ -98,7 +98,7 @@ async def RunFunction(
9898
"cmds": [
9999
"enable",
100100
"configure",
101-
*build_remove_path(path, remove_container=remove_container),
101+
*build_remove_path(path, remove_section=remove_section),
102102
],
103103
}
104104
jsonrpc_remove = request_json("runCmds", params=jsonrpc_remove_params)
@@ -138,12 +138,12 @@ def toggle_no(cmd: str) -> str:
138138
return cmd.removeprefix("no ") if cmd.startswith("no ") else f"no {cmd}"
139139

140140

141-
def build_remove_path(path: list[str], *, remove_container: bool = False) -> list[str]:
141+
def build_remove_path(path: list[str], *, remove_section: bool = False) -> list[str]:
142142
"""Create cmd for remove op."""
143143
head, *tail = path
144144

145-
# remove the container
146-
if remove_container and tail:
145+
# remove the whole enclosing section, not just the setting inside it
146+
if remove_section and tail:
147147
return [f"no {head}"]
148148

149149
# remove nested items

0 commit comments

Comments
 (0)