Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

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'

Expand Down Expand Up @@ -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):
Expand Down
14 changes: 14 additions & 0 deletions src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

TOR_ROUTER = 'ToRRouter'
BACKEND_TOR_ROUTER = 'BackEndToRRouter'
BMC_MGMT_TOR_ROUTER = 'BmcMgmtToRRouter'

class TestCfgGenCaseInsensitive(TestCase):

Expand Down Expand Up @@ -169,6 +170,19 @@ def test_minigraph_console_port(self):
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)
Expand Down