setup port description if minigraph has neighbor information
Signed-off-by: Guohan Lu <gulv@microsoft.com>
This commit is contained in:
parent
41bb13b834
commit
bab38e4310
@ -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():
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user