Skip to content

Commit

Permalink
[minigraph parser] add basic support for MGMT_PORT (#2103)
Browse files Browse the repository at this point in the history
* [minigraph parser] add basic support for MGMT_PORT

* Change method to determine local interface name
  • Loading branch information
taoyl-ms authored and lguohan committed Oct 2, 2018
1 parent 3f58ca1 commit f333342
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,20 @@ def parse_xml(filename, platform=None, port_config_file=None):
if mgmt_routes:
# TODO: differentiate v4 and v6
mgmt_intf.itervalues().next()['forced_mgmt_routes'] = mgmt_routes
results['MGMT_INTERFACE'] = mgmt_intf
results['MGMT_PORT'] = {}
results['MGMT_INTERFACE'] = {}
mgmt_intf_count = 0
mgmt_alias_reverse_mapping = {}
for key in mgmt_intf:
alias = key[0]
if mgmt_alias_reverse_mapping.has_key(alias):
name = mgmt_alias_reverse_mapping[alias]
else:
name = 'eth' + str(mgmt_intf_count)
mgmt_intf_count += 1
mgmt_alias_reverse_mapping[alias] = name
results['MGMT_PORT'][name] = {'alias': alias, 'admin_status': 'up'}
results['MGMT_INTERFACE'][(name, key[1])] = mgmt_intf[key]
results['LOOPBACK_INTERFACE'] = lo_intfs

phyport_intfs = {}
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 @@ -92,6 +92,11 @@ def test_minigraph_everflow(self):
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '2.2.2.2'}}")

def test_minigraph_mgmt_ports(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v MGMT_PORT'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'eth0': {'alias': 'Management0', 'admin_status': 'up'}}")

def test_minigraph_interfaces(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v \'INTERFACE.keys()\''
output = self.run_script(argument)
Expand Down

0 comments on commit f333342

Please sign in to comment.