From d022a4099c5476b78b2215fcc2f1c06559ceaf09 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 20 Jul 2024 03:29:21 +0300 Subject: [PATCH 1/2] tools: Do not append an empty list (pim_vrfs) to the config lines If pim_vrfs is empty, we append [] into the lines array, and the reload is broken since it expects only strings, but gets an array inside at the end. ``` Traceback (most recent call last): File "/usr/lib/frr/frr-reload.py", line 2227, in log.debug("New Frr Config\n%s", newconf.get_lines()) File "/usr/lib/frr/frr-reload.py", line 436, in get_lines return "\n".join(self.lines) TypeError: sequence item 45: expected str instance, list found ``` Fixes: 98d47f43fbba4e376c8351c724e8c625799805f7 ("tools: Fix frr-reload to support legacy pim configuration from file") Signed-off-by: Donatas Abraitis --- tools/frr-reload.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/frr-reload.py b/tools/frr-reload.py index 47e3637550e1..8a39f4204dae 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -400,7 +400,8 @@ def load_from_file(self, filename): self.lines.append(line) - self.lines.append(pim_vrfs) + if len(pim_vrfs) > 0: + self.lines.append(pim_vrfs) self.load_contexts() From 01b7bd3b133e0d09d86ff7d626616c2a66606694 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Sat, 20 Jul 2024 03:30:08 +0300 Subject: [PATCH 2/2] tools: Apply black formatting for the recent frr-reload.py changes Signed-off-by: Donatas Abraitis --- tools/frr-reload.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/frr-reload.py b/tools/frr-reload.py index 8a39f4204dae..342c57964cde 100755 --- a/tools/frr-reload.py +++ b/tools/frr-reload.py @@ -328,7 +328,10 @@ def load_from_file(self, filename): vrf_context = re_vrf.group(1) # Detect legacy pim commands that need to move under the router pim context - re_pim = re.match("^ip(v6)? pim ((ecmp|join|keep|mlag|packets|register|rp|send|spt|ssm).*)$", line) + re_pim = re.match( + "^ip(v6)? pim ((ecmp|join|keep|mlag|packets|register|rp|send|spt|ssm).*)$", + line, + ) if re_pim and re_pim.group(2): router_pim = "router pim" if re_pim.group(1): @@ -340,7 +343,7 @@ def load_from_file(self, filename): pim_vrfs.append(router_pim) pim_vrfs.append(re_pim.group(2)) pim_vrfs.append("exit") - line="# PIM VRF LINE MOVED TO ROUTER PIM" + line = "# PIM VRF LINE MOVED TO ROUTER PIM" else: self.lines.append(router_pim) self.lines.append(re_pim.group(2)) @@ -358,7 +361,7 @@ def load_from_file(self, filename): pim_vrfs.append(router_pim) pim_vrfs.append(re_pim.group(2)) pim_vrfs.append("exit") - line="# PIM VRF LINE MOVED TO ROUTER PIM" + line = "# PIM VRF LINE MOVED TO ROUTER PIM" else: self.lines.append(router_pim) self.lines.append(re_pim.group(2))