fix(get_config): strip timestamped event-log lines from running-config
Tests / Test (Python 3.10) (push) Failing after 6s
Tests / Test (Python 3.11) (push) Failing after 6s
Tests / Test (Python 3.12) (push) Failing after 5s
Tests / Test (Python 3.8) (push) Failing after 6s
Tests / Test (Python 3.9) (push) Failing after 5s

TP-Link embeds system event log entries (link up/down, etc.) in
show running-config output. These change every event and cause false-
positive config-change detections. Strip lines matching #YYYY-MM-DD.
This commit is contained in:
Christian Manivong
2026-06-30 01:29:56 +02:00
parent dccd18da65
commit 33ef6f86fa
+15 -2
View File
@@ -522,6 +522,19 @@ class TPLinkJetstreamDriver(ConfigLifecycleMixin, SwitchDriver):
return interfaces_ip
@staticmethod
def _strip_event_log(config: str) -> str:
"""Remove timestamped event-log lines from config output.
TP-Link Jetstream embeds system event log entries in ``show running-config``
output as lines like ``#2026-06-29 14:58:50,[Link]/5/Gi1/0/4 changed state``.
These lines are volatile and cause false-positive config-change events in
the config-backup feature. Strip them to keep the diff meaningful.
"""
import re
return re.sub(r"^#\d{4}-\d{2}-\d{2} .*\n?", "", config, flags=re.MULTILINE)
def get_config(
self,
retrieve: str = "all",
@@ -537,10 +550,10 @@ class TPLinkJetstreamDriver(ConfigLifecycleMixin, SwitchDriver):
configs = {"running": "", "startup": "", "candidate": ""}
if retrieve in ("all", "running"):
configs["running"] = self._send_command("show running-config")
configs["running"] = self._strip_event_log(self._send_command("show running-config"))
if retrieve in ("all", "startup"):
configs["startup"] = self._send_command("show startup-config")
configs["startup"] = self._strip_event_log(self._send_command("show startup-config"))
if sanitized:
configs = napalm_helpers.sanitize_configs(configs, C.CISCO_SANITIZE_FILTERS)