From a63cb16225126f9cf487cc22da42522d3a969a37 Mon Sep 17 00:00:00 2001 From: Zhenggen Xu Date: Tue, 30 Aug 2022 22:30:20 -0700 Subject: [PATCH 1/2] [lldpmgrd] Fix lldpmgrd issue where it sets the lldp system name to None - Only check hostname field in key DEVICE_METADATA|localhost of configDB - If hostname does not exist, don't set lldp system name Signed-off-by: Zhenggen Xu --- dockers/docker-lldp/lldpmgrd | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dockers/docker-lldp/lldpmgrd b/dockers/docker-lldp/lldpmgrd index 753aa678eae..82ad32dd6c3 100755 --- a/dockers/docker-lldp/lldpmgrd +++ b/dockers/docker-lldp/lldpmgrd @@ -245,10 +245,13 @@ class LldpManager(daemon_base.DaemonBase): if not op in ["SET", "DEL"]: return self.log_info("Device Config Opcode: {} Dict {} Key {}".format(op, device_dict, key)) - hostname = device_dict.get("hostname") - if not self.hostname == hostname: - self.log_info("Hostname changed old {0}, new {1}".format(self.hostname, hostname)) - self.update_hostname(hostname) + # only check hostname in key:localhost + if key == "localhost": + hostname = device_dict.get("hostname") + # check hostname is valid and not the same as before + if hostname and not self.hostname == hostname: + self.log_info("Hostname changed old {0}, new {1}".format(self.hostname, hostname)) + self.update_hostname(hostname) def lldp_process_port_table_event(self, key, op, fvp): if (key != "PortInitDone") and (key != "PortConfigDone"): From 9f0933aa65e9949b85c3734aa6a9ec8a724d3765 Mon Sep 17 00:00:00 2001 From: Zhenggen Xu Date: Wed, 31 Aug 2022 14:21:14 -0700 Subject: [PATCH 2/2] [lldpmgrd] Address the review feedback Signed-off-by: Zhenggen Xu --- dockers/docker-lldp/lldpmgrd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockers/docker-lldp/lldpmgrd b/dockers/docker-lldp/lldpmgrd index 82ad32dd6c3..955f4a5334a 100755 --- a/dockers/docker-lldp/lldpmgrd +++ b/dockers/docker-lldp/lldpmgrd @@ -248,8 +248,8 @@ class LldpManager(daemon_base.DaemonBase): # only check hostname in key:localhost if key == "localhost": hostname = device_dict.get("hostname") - # check hostname is valid and not the same as before - if hostname and not self.hostname == hostname: + # check if hostname is valid and not the same as before + if hostname and self.hostname != hostname: self.log_info("Hostname changed old {0}, new {1}".format(self.hostname, hostname)) self.update_hostname(hostname)