[docker-lldpd]: Various fixes (#1650)
* We don't need configure anything until we have interfaces created * Don't run lldpcli for a port, until a port is up and running * Remove lldpd socket before starting lldpd * Fix sample files for lldpd configuration * Another attempt to make the test working * Quick fix for lldpd paused after start bug
This commit is contained in:
parent
3993e58d1d
commit
18e97fba2c
@ -1,6 +1,3 @@
|
||||
{% if MGMT_INTERFACE %}
|
||||
configure ports eth0 lldp portidsubtype local {{ MGMT_INTERFACE.keys()[0][0] }}
|
||||
{% endif %}
|
||||
{% for local_port in DEVICE_NEIGHBOR %}
|
||||
configure ports {{ local_port }} lldp portidsubtype local {{ PORT[local_port]['alias'] }} description {{ DEVICE_NEIGHBOR[local_port]['name'] }}:{{ DEVICE_NEIGHBOR[local_port]['port'] }}
|
||||
{% endfor %}
|
||||
|
@ -20,6 +20,7 @@ try:
|
||||
import subprocess
|
||||
import sys
|
||||
import syslog
|
||||
import os.path
|
||||
from swsscommon import swsscommon
|
||||
except ImportError as err:
|
||||
raise ImportError("%s - required module not found" % str(err))
|
||||
@ -70,6 +71,19 @@ def signal_handler(sig, frame):
|
||||
else:
|
||||
log_warning("Caught unhandled signal '" + sig + "'")
|
||||
|
||||
# ========================== Helpers ==================================
|
||||
|
||||
def is_port_up(port_name):
|
||||
filename = "/sys/class/net/%s/operstate" % port_name
|
||||
if not os.path.exists(filename):
|
||||
return False
|
||||
|
||||
with open(filename) as fp:
|
||||
state = fp.read()
|
||||
if 'up' in state:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# ============================== Classes ==============================
|
||||
|
||||
@ -159,6 +173,11 @@ class LldpManager(object):
|
||||
to_delete = []
|
||||
|
||||
for (port_name, cmd) in self.pending_cmds.iteritems():
|
||||
if not is_port_up(port_name):
|
||||
# it doesn't make any sense to configure lldpd if the target port is unavailable
|
||||
# let's postpone the command for the next iteration
|
||||
continue
|
||||
|
||||
log_debug("Running command: '{}'".format(cmd))
|
||||
|
||||
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
@ -6,8 +6,32 @@ mkdir -p /var/sonic
|
||||
echo "# Config files managed by sonic-config-engine" > /var/sonic/config_status
|
||||
|
||||
rm -f /var/run/rsyslogd.pid
|
||||
rm -f /var/run/lldpd.socket
|
||||
|
||||
supervisorctl start rsyslogd
|
||||
supervisorctl start lldpd
|
||||
supervisorctl start lldp-syncd
|
||||
supervisorctl start lldpmgrd
|
||||
|
||||
# Current lldpd version has a bug.
|
||||
# When lldpd starts it is in the pause state by default
|
||||
# But then it execute 'lldpcli resume' to configure and unpause itself.
|
||||
# When lldpd execute lldpcli, it doesn't check the return code
|
||||
# Sometimes lldpcli returns failure, but lldpd doesn't catch it
|
||||
# and keeps working paused and unconfigured
|
||||
#
|
||||
# The fix below addresses the issue.
|
||||
#
|
||||
|
||||
# wait until lldpd started
|
||||
until [[ -e /var/run/lldpd.socket ]];
|
||||
do
|
||||
sleep 1;
|
||||
done
|
||||
|
||||
# Manually try to resume lldpd, until it's successful
|
||||
while /bin/true;
|
||||
do
|
||||
lldpcli -u /var/run/lldpd.socket -c /etc/lldpd.conf -c /etc/lldpd.d resume > /dev/null && break
|
||||
sleep 1
|
||||
done
|
||||
|
@ -1,6 +1,2 @@
|
||||
configure ports eth0 lldp portidsubtype local eth0
|
||||
configure ports Ethernet112 lldp portidsubtype local fortyGigE0/112 description ARISTA01T1:Ethernet1/1
|
||||
configure ports Ethernet116 lldp portidsubtype local fortyGigE0/116 description ARISTA02T1:Ethernet1/1
|
||||
configure ports Ethernet120 lldp portidsubtype local fortyGigE0/120 description ARISTA03T1:Ethernet1/1
|
||||
configure ports Ethernet124 lldp portidsubtype local fortyGigE0/124 description ARISTA04T1:Ethernet1/1
|
||||
|
||||
|
Reference in New Issue
Block a user