Skip to content

Commit 9ea746e

Browse files
committed
Changes for LLDP docker to support multi-npu platforms (#4530)
* Changes for LLDP for Multi NPU Platoforms:- a) Enable LLDP for Host namespace for Management Port b) Make sure Management IP is avaliable in per asic namespace needed for LLDP Chassis configuration c) Make sure chassis mac-address is correct in per asic namespace d) Do not run lldp on eth0 of per asic namespace and avoid chassis configuration for same e) Use Linux hostname instead from Device Metadata for lldp chassis configuration since in multi-npu platforms device metadata hostname will be differnt Signed-off-by: Abhishek Dosi <[email protected]> * Address Review Comment with following changes: a) Use Device Metadata hostname even in per namespace conatiner. updated minigraph parsing for same to have hostname as system hostname and add new key for asic name b) Minigraph changes to have MGMT_INTERFACE Key in per asic/namespace config also as needed for LLDP for setting chassis management IP. Signed-off-by: Abhishek Dosi <[email protected]> * Address Review Comments
1 parent 8fc4657 commit 9ea746e

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

dockers/docker-lldp-sv2/Dockerfile.j2

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ RUN apt-get purge -y python-pip && \
3535
/python-wheels \
3636
~/.cache
3737

38+
COPY ["docker-lldp-init.sh", "/usr/bin/"]
3839
COPY ["start.sh", "/usr/bin/"]
39-
COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
40+
COPY ["supervisord.conf.j2", "/usr/share/sonic/templates/"]
4041
COPY ["lldpd.conf.j2", "/usr/share/sonic/templates/"]
4142
COPY ["lldpd", "/etc/default/"]
4243
COPY ["lldpmgrd", "/usr/bin/"]
4344
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
4445
COPY ["critical_processes", "/etc/supervisor"]
4546

46-
ENTRYPOINT ["/usr/bin/supervisord"]
47+
ENTRYPOINT ["/usr/bin/docker-lldp-init.sh"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
#Generate supervisord.conf based on device metadata
3+
mkdir -p /etc/supervisor/conf.d/
4+
sonic-cfggen -d -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf
5+
exec /usr/bin/supervisord

dockers/docker-lldp-sv2/supervisord.conf renamed to dockers/docker-lldp-sv2/supervisord.conf.j2

+4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ stderr_logfile=syslog
3131
# - `-dd` means to stay in foreground, log warnings to console
3232
# - `-ddd` means to stay in foreground, log warnings and info to console
3333
# - `-dddd` means to stay in foreground, log all to console
34+
{% if DEVICE_METADATA['localhost']['sub_role'] is defined and DEVICE_METADATA['localhost']['sub_role']|length %}
35+
command=/usr/sbin/lldpd -d -I Ethernet* -C Ethernet*
36+
{% else %}
3437
command=/usr/sbin/lldpd -d -I Ethernet*,eth0 -C eth0
38+
{% endif %}
3539
priority=3
3640
autostart=false
3741
autorestart=false

files/build_templates/lldp.service.j2

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
per_namespace/lldp.service.j2

src/sonic-config-engine/minigraph.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,24 @@ def parse_asic_png(png, asic_name, hostname):
252252
return (neighbors, devices, port_speeds)
253253

254254
def parse_dpg(dpg, hname):
255+
aclintfs = None
256+
mgmtintfs = None
255257
for child in dpg:
256-
"""In Multi-NPU platforms the acl intfs are defined only for the host not for individual asic.
258+
"""
259+
In Multi-NPU platforms the acl intfs are defined only for the host not for individual asic.
257260
There is just one aclintf node in the minigraph
258-
Get the aclintfs node first.
261+
Get the aclintfs node first.
259262
"""
260-
if child.find(str(QName(ns, "AclInterfaces"))) is not None:
263+
if aclintfs is None and child.find(str(QName(ns, "AclInterfaces"))) is not None:
261264
aclintfs = child.find(str(QName(ns, "AclInterfaces")))
262-
265+
"""
266+
In Multi-NPU platforms the mgmt intfs are defined only for the host not for individual asic
267+
There is just one mgmtintf node in the minigraph
268+
Get the mgmtintfs node first. We need mgmt intf to get mgmt ip in per asic dockers.
269+
"""
270+
if mgmtintfs is None and child.find(str(QName(ns, "ManagementIPInterfaces"))) is not None:
271+
mgmtintfs = child.find(str(QName(ns, "ManagementIPInterfaces")))
272+
263273
hostname = child.find(str(QName(ns, "Hostname")))
264274
if hostname.text.lower() != hname.lower():
265275
continue
@@ -295,7 +305,6 @@ def parse_dpg(dpg, hname):
295305
mvrf_en_flag = mv.find(str(QName(ns, "mgmtVrfEnabled"))).text
296306
mvrf["vrf_global"] = {"mgmtVrfEnabled": mvrf_en_flag}
297307

298-
mgmtintfs = child.find(str(QName(ns, "ManagementIPInterfaces")))
299308
mgmt_intf = {}
300309
for mgmtintf in mgmtintfs.findall(str(QName(ns1, "ManagementIPInterface"))):
301310
intfname = mgmtintf.find(str(QName(ns, "AttachTo"))).text
@@ -807,18 +816,16 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
807816

808817
if asic_name is None:
809818
current_device = [devices[key] for key in devices if key.lower() == hostname.lower()][0]
810-
name = hostname
811819
else:
812820
current_device = [devices[key] for key in devices if key.lower() == asic_name.lower()][0]
813-
name = asic_name
814821

815822
results = {}
816823
results['DEVICE_METADATA'] = {'localhost': {
817824
'bgp_asn': bgp_asn,
818825
'deployment_id': deployment_id,
819826
'region': region,
820827
'docker_routing_config_mode': docker_routing_config_mode,
821-
'hostname': name,
828+
'hostname': hostname,
822829
'hwsku': hwsku,
823830
'type': current_device['type']
824831
}
@@ -828,6 +835,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
828835
if sub_role is not None:
829836
current_device['sub_role'] = sub_role
830837
results['DEVICE_METADATA']['localhost']['sub_role'] = sub_role
838+
results['DEVICE_METADATA']['localhost']['asic_name'] = asic_name
831839
results['BGP_NEIGHBOR'] = bgp_sessions
832840
results['BGP_MONITORS'] = bgp_monitors
833841
results['BGP_PEER_RANGE'] = bgp_peers_with_range

src/sonic-config-engine/tests/test_multinpu_cfggen.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_mgmt_port(self):
116116
self.assertDictEqual(output, {'eth0': {'alias': 'eth0', 'admin_status': 'up'}})
117117
for asic in range(NUM_ASIC):
118118
output = json.loads(self.run_script_for_asic(argument, asic, self.port_config[asic]))
119-
self.assertDictEqual(output, {})
119+
self.assertDictEqual(output, {'eth0': {'alias': 'eth0', 'admin_status': 'up'}})
120120

121121
def test_frontend_asic_portchannels(self):
122122
argument = "-m {} -p {} -n asic0 --var-json \"PORTCHANNEL\"".format(self.sample_graph, self.port_config[0])
@@ -213,7 +213,8 @@ def test_device_asic_metadata(self):
213213
for asic in range(NUM_ASIC):
214214
output = json.loads(self.run_script_for_asic(argument, asic,self.port_config[asic]))
215215
asic_name = "asic{}".format(asic)
216-
self.assertEqual(output['localhost']['hostname'], asic_name)
216+
self.assertEqual(output['localhost']['hostname'], 'multi_npu_platform_01')
217+
self.assertEqual(output['localhost']['asic_name'], asic_name)
217218
self.assertEqual(output['localhost']['type'], 'Asic')
218219
if asic == 0 or asic == 1:
219220
self.assertEqual(output['localhost']['sub_role'], 'FrontEnd')

0 commit comments

Comments
 (0)