From f7f8036c7d81e9c319643ccfb73eb1a5b250470e Mon Sep 17 00:00:00 2001 From: mbakalarski <64490638+mbakalarski@users.noreply.github.com> Date: Thu, 30 Jul 2026 11:22:26 +0000 Subject: [PATCH] Rename removeContainer to removeSection "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 --- example/xr1.yaml | 2 +- example/xr2.yaml | 2 +- function/fn.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/example/xr1.yaml b/example/xr1.yaml index 79bb8dc..79bffc4 100644 --- a/example/xr1.yaml +++ b/example/xr1.yaml @@ -4,7 +4,7 @@ metadata: name: eoscommand-1 spec: endpoint: ceos01.default.svc.cluster.local - removeContainer: false + removeSection: false cmds: no spanning-tree vlan-id 4093-4094: {} ip prefix-list PL-Loopback0: diff --git a/example/xr2.yaml b/example/xr2.yaml index 4b2d4c7..3ca4051 100644 --- a/example/xr2.yaml +++ b/example/xr2.yaml @@ -4,7 +4,7 @@ metadata: name: eoscommand-2 spec: endpoint: ceos01.default.svc.cluster.local - removeContainer: true + removeSection: true cmds: no spanning-tree vlan-id 4093-4094: {} ip prefix-list PL-Loopback0: diff --git a/function/fn.py b/function/fn.py index dc6ebb4..58605c8 100644 --- a/function/fn.py +++ b/function/fn.py @@ -53,7 +53,7 @@ async def RunFunction( observed_xr_namespace = observed_xr.get("metadata").get("namespace") fqdn = observed_xr["spec"].get("endpoint") cmds = observed_xr["spec"].get("cmds") - remove_container = observed_xr["spec"].get("removeContainer") + remove_section = observed_xr["spec"].get("removeSection") environment = resource.struct_to_dict( req.context["apiextensions.crossplane.io/environment"] @@ -98,7 +98,7 @@ async def RunFunction( "cmds": [ "enable", "configure", - *build_remove_path(path, remove_container=remove_container), + *build_remove_path(path, remove_section=remove_section), ], } jsonrpc_remove = request_json("runCmds", params=jsonrpc_remove_params) @@ -138,12 +138,12 @@ def toggle_no(cmd: str) -> str: return cmd.removeprefix("no ") if cmd.startswith("no ") else f"no {cmd}" -def build_remove_path(path: list[str], *, remove_container: bool = False) -> list[str]: +def build_remove_path(path: list[str], *, remove_section: bool = False) -> list[str]: """Create cmd for remove op.""" head, *tail = path - # remove the container - if remove_container and tail: + # remove the whole enclosing section, not just the setting inside it + if remove_section and tail: return [f"no {head}"] # remove nested items