Skip to content

Commit

Permalink
setup port description if minigraph has neighbor information
Browse files Browse the repository at this point in the history
Signed-off-by: Guohan Lu <gulv@microsoft.com>
  • Loading branch information
lguohan committed Feb 12, 2019
1 parent dd07e2a commit 2543b71
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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
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

0 comments on commit 2543b71

Please sign in to comment.