Merge pull request #2556 from lguohan/lldp
[docker-lldp]: fix several issues in lldpd docker
This commit is contained in:
commit
4d2cd3cf49
@ -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'] }}
|
||||
|
@ -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 ==============================
|
||||
|
||||
@ -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
|
||||
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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():
|
||||
|
@ -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
|
||||
|
@ -151,6 +151,11 @@ class TestCfgGen(TestCase):
|
||||
"'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)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 1cdcffc08f6ea1c3fc53f7aeeef5b5632124496f
|
||||
Subproject commit fe60afa7e24a7053a7bd9d7084268c1bbd203208
|
Reference in New Issue
Block a user