From 052977d58bb445ae9f38167cc5641cbfcb289c88 Mon Sep 17 00:00:00 2001 From: Johan Marcusson Date: Thu, 31 Oct 2024 09:38:03 +0100 Subject: [PATCH] Fix for junos where first line of config includes "## Last commit " comment that make config hash diff, even if the config change was only in unmanaged parts of the config --- src/cnaas_nms/devicehandler/get.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cnaas_nms/devicehandler/get.py b/src/cnaas_nms/devicehandler/get.py index b669bef3..d5781b51 100644 --- a/src/cnaas_nms/devicehandler/get.py +++ b/src/cnaas_nms/devicehandler/get.py @@ -80,6 +80,9 @@ def calc_config_hash(hostname: str, config: str, platform: str, devtype: DeviceT skip_section = get_config_section(config, section, platform) if skip_section: config = config.replace(skip_section, "") + if platform == "junos": + # remove line starting with "## Last commit" from config string so we don't get config hash mismatch + config = re.sub(r"^#{2}.*\n", "", config, flags=re.MULTILINE) config = config.replace("\n", "") try: hash_object = hashlib.sha256(config.encode())