Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docker-lldp]: fix several issues in lldpd docker #2556

Merged
merged 5 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dockers/docker-lldp-sv2/lldpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ configure ports eth0 lldp portidsubtype local {{ mgmt_port_name }}
{% endif %}
configure system ip management pattern {{ ipv4 }}
{% endif %}
configure system hostname {{ DEVICE_METADATA['localhost']['hostname'] }}
15 changes: 5 additions & 10 deletions dockers/docker-lldp-sv2/lldpmgrd
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,12 @@ def signal_handler(sig, frame):

# ========================== Helpers ==================================

def is_port_up(port_name):
filename = "/sys/class/net/%s/operstate" % port_name
def is_port_exist(port_name):
filename = "/sys/class/net/%s/ifindex" % 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
return True

# ============================== Classes ==============================

Expand Down Expand Up @@ -159,8 +154,8 @@ 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
if not is_port_exist(port_name):
# it doesn't make any sense to configure lldpd if the target port does not exist
# let's postpone the command for the next iteration
continue

Expand Down
5 changes: 3 additions & 2 deletions dockers/docker-lldp-sv2/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ 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
Expand All @@ -35,3 +33,6 @@ do
lldpcli -u /var/run/lldpd.socket -c /etc/lldpd.conf -c /etc/lldpd.d resume > /dev/null && break
sleep 1
done

supervisorctl start lldp-syncd
supervisorctl start lldpmgrd
8 changes: 6 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,14 @@ def parse_xml(filename, platform=None, port_config_file=None):

ports.setdefault(port_name, {})['description'] = port_descriptions[port_name]

# for the ports w/o description set it to alias, or port name
for port_name, port in ports.items():
if not port.get('description'):
port['description'] = port.get('alias', port_name)
if neighbors.has_key(port_name):
# for the ports w/o description set it to neighbor name:port
port['description'] = "%s:%s" % (neighbors[port_name]['name'], neighbors[port_name]['port'])
else:
# for the ports w/o neighbor info, set it to port alias
port['description'] = port.get('alias', port_name)

# set default port MTU as 9100
for port in ports.itervalues():
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/sample_output/lldpd.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
configure ports eth0 lldp portidsubtype local eth0
configure system ip management pattern 10.0.0.100

configure system hostname switch-t0
5 changes: 5 additions & 0 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ def test_minigraph_extra_neighbors(self):
"'Ethernet112': {'name': 'ARISTA01T1', 'port': 'Ethernet1/1'}, "
"'Ethernet120': {'name': 'ARISTA03T1', 'port': 'Ethernet1/1'}}")

def test_minigraph_port_description(self):
argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v "PORT[\'Ethernet124\']"'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'alias': 'fortyGigE0/124', 'admin_status': 'up', 'lanes': '101,102,103,104', 'description': 'ARISTA04T1:Ethernet1/1', 'mtu': '9100'}")

def test_minigraph_bgp(self):
argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v "BGP_NEIGHBOR[\'10.0.0.59\']"'
output = self.run_script(argument)
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-dbsyncd