Skip to content

Commit 2543b71

Browse files
committed
setup port description if minigraph has neighbor information
Signed-off-by: Guohan Lu <[email protected]>
1 parent dd07e2a commit 2543b71

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/sonic-config-engine/minigraph.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,14 @@ def parse_xml(filename, platform=None, port_config_file=None):
538538

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

541-
# for the ports w/o description set it to alias, or port name
542541
for port_name, port in ports.items():
543542
if not port.get('description'):
544-
port['description'] = port.get('alias', port_name)
543+
if neighbors.has_key(port_name):
544+
# for the ports w/o description set it to neighbor name:port
545+
port['description'] = "%s:%s" % (neighbors[port_name]['name'], neighbors[port_name]['port'])
546+
else:
547+
# for the ports w/o neighbor info, set it to port alias
548+
port['description'] = port.get('alias', port_name)
545549

546550
# set default port MTU as 9100
547551
for port in ports.itervalues():

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ def test_minigraph_extra_neighbors(self):
151151
"'Ethernet112': {'name': 'ARISTA01T1', 'port': 'Ethernet1/1'}, "
152152
"'Ethernet120': {'name': 'ARISTA03T1', 'port': 'Ethernet1/1'}}")
153153

154+
def test_minigraph_port_description(self):
155+
argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v "PORT[\'Ethernet124\']"'
156+
output = self.run_script(argument)
157+
self.assertEqual(output.strip(), "{'alias': 'fortyGigE0/124', 'admin_status': 'up', 'lanes': '101,102,103,104', 'description': 'ARISTA04T1:Ethernet1/1', 'mtu': '9100'}")
158+
154159
def test_minigraph_bgp(self):
155160
argument = '-m "' + self.sample_graph_bgp_speaker + '" -p "' + self.port_config + '" -v "BGP_NEIGHBOR[\'10.0.0.59\']"'
156161
output = self.run_script(argument)

0 commit comments

Comments
 (0)