fix(get_config): strip timestamped event-log lines from running-config
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:
@@ -522,6 +522,19 @@ class TPLinkJetstreamDriver(ConfigLifecycleMixin, SwitchDriver):
|
|||||||
|
|
||||||
return interfaces_ip
|
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(
|
def get_config(
|
||||||
self,
|
self,
|
||||||
retrieve: str = "all",
|
retrieve: str = "all",
|
||||||
@@ -537,10 +550,10 @@ class TPLinkJetstreamDriver(ConfigLifecycleMixin, SwitchDriver):
|
|||||||
configs = {"running": "", "startup": "", "candidate": ""}
|
configs = {"running": "", "startup": "", "candidate": ""}
|
||||||
|
|
||||||
if retrieve in ("all", "running"):
|
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"):
|
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:
|
if sanitized:
|
||||||
configs = napalm_helpers.sanitize_configs(configs, C.CISCO_SANITIZE_FILTERS)
|
configs = napalm_helpers.sanitize_configs(configs, C.CISCO_SANITIZE_FILTERS)
|
||||||
|
|||||||
Reference in New Issue
Block a user