[sonic-config-engine]: Update minigraph parser to support enable DHCP server for BmcMgmtToRRouter (#9938)

Signed-off-by: Jing Kan jika@microsoft.com
This commit is contained in:
Jing Kan 2022-02-10 13:30:54 +08:00 committed by GitHub
parent 25a0ce5eb1
commit 914a8a1756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -37,6 +37,7 @@ chassis_backend_role = 'ChassisBackendRouter'
backend_device_types = ['BackEndToRRouter', 'BackEndLeafRouter']
console_device_types = ['MgmtTsToR']
dhcp_server_enabled_device_types = ['BmcMgmtToRRouter']
VLAN_SUB_INTERFACE_SEPARATOR = '.'
VLAN_SUB_INTERFACE_VLAN_ID = '10'
@ -1684,6 +1685,10 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
}
}
# Enable DHCP Server feature for specific device type
if current_device['type'] in dhcp_server_enabled_device_types:
results['DEVICE_METADATA']['localhost']['dhcp_server'] = 'enabled'
return results
def get_tunnel_entries(tunnel_intfs, lo_intfs, hostname):

View File

@ -9,6 +9,7 @@ from unittest import TestCase
TOR_ROUTER = 'ToRRouter'
BACKEND_TOR_ROUTER = 'BackEndToRRouter'
BMC_MGMT_TOR_ROUTER = 'BmcMgmtToRRouter'
class TestCfgGenCaseInsensitive(TestCase):
@ -169,6 +170,19 @@ class TestCfgGenCaseInsensitive(TestCase):
utils.to_dict(output.strip()),
utils.to_dict("{'1': {'baud_rate': '9600', 'remote_device': 'managed_device', 'flow_control': 1}}"))
def test_minigraph_dhcp_server_feature(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_METADATA[\'localhost\'][\'dhcp_server\']"'
output = self.run_script(argument)
self.assertEqual(output.strip(), '')
try:
# For DHCP server enabled device type
output = subprocess.check_output("sed -i \'s/%s/%s/g\' %s" % (TOR_ROUTER, BMC_MGMT_TOR_ROUTER, self.sample_graph), shell=True)
output = self.run_script(argument)
self.assertEqual(output.strip(), 'enabled')
finally:
output = subprocess.check_output("sed -i \'s/%s/%s/g\' %s" % (BMC_MGMT_TOR_ROUTER, TOR_ROUTER, self.sample_graph), shell=True)
def test_minigraph_deployment_id(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_METADATA[\'localhost\'][\'deployment_id\']"'
output = self.run_script(argument)