Skip to content

Commit a75b66c

Browse files
saiarcot895liushilongbuaa
authored andcommittedAug 1, 2024
Enable iburst option for NTP servers loaded from minigraph (sonic-net#19424)
Why I did it In sonic-net#15058, the NTP server configuration was modified to add additional options, such as conditionally enabling iburst, specifying the association type, and specifying the NTP version. One side effect of this was that the iburst option which was previously always enabled now requires it to be explicitly enabled in the config_db. Fixes sonic-net#19425. How I did it To restore the old behavior, when loading from minigraph, add "iburst": "true" for each NTP server loaded from minigraph. How to verify it Tested on a KVM setup, verified that the generated ntp.conf file had the iburst option. Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
1 parent e9b11e8 commit a75b66c

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed
 

‎src/sonic-config-engine/minigraph.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2612,7 +2612,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
26122612
results['SYSLOG_SERVER'] = dict((item, {}) for item in syslog_servers)
26132613
results['DHCP_SERVER'] = dict((item, {}) for item in dhcp_servers)
26142614
results['DHCP_RELAY'] = dhcp_relay_table
2615-
results['NTP_SERVER'] = dict((item, {}) for item in ntp_servers)
2615+
results['NTP_SERVER'] = dict((item, {'iburst': 'on'}) for item in ntp_servers)
26162616
# Set default DNS nameserver from dns.j2
26172617
results['DNS_NAMESERVER'] = {}
26182618
if os.environ.get("CFGGEN_UNIT_TESTING", "0") == "2":

‎src/sonic-config-engine/tests/test_cfggen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ def test_metadata_tacacs(self):
696696
def test_metadata_ntp(self):
697697
argument = ['-m', self.sample_graph_metadata, '-p', self.port_config, '-v', "NTP_SERVER"]
698698
output = self.run_script(argument)
699-
self.assertEqual(utils.to_dict(output.strip()), utils.to_dict("{'10.0.10.1': {}, '10.0.10.2': {}}"))
699+
self.assertEqual(utils.to_dict(output.strip()), utils.to_dict("{'10.0.10.1': {'iburst': 'on'}, '10.0.10.2': {'iburst': 'on'}}"))
700700

701701
def test_dns_nameserver(self):
702702
argument = ['-m', self.sample_graph_metadata, '-p', self.port_config, '-v', "DNS_NAMESERVER"]

‎src/sonic-config-engine/tests/test_chassis_cfggen.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_ntp(self):
104104
argument = ['-m', self.sample_graph, '-p',
105105
self.sample_port_config, '--var-json', 'NTP_SERVER']
106106
output = json.loads(self.run_script(argument))
107-
self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}})
107+
self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}})
108108
# NTP data is present only in the host config
109109
argument = ['-m', self.sample_graph, '--var-json', 'NTP_SERVER']
110110

@@ -416,7 +416,7 @@ def test_ntp(self):
416416
argument = ['-m', self.sample_graph, '-p',
417417
self.sample_port_config, '--var-json', 'NTP_SERVER']
418418
output = json.loads(self.run_script(argument))
419-
self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}})
419+
self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}})
420420
# NTP data is present only in the host config
421421
argument = ['-m', self.sample_graph, '--var-json', 'NTP_SERVER']
422422

@@ -884,7 +884,7 @@ def test_ntp(self):
884884
'--var-json', 'NTP_SERVER'
885885
]
886886
output = json.loads(self.run_script(argument))
887-
self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}})
887+
self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}})
888888

889889

890890
def test_mgmt_port(self):
@@ -1019,7 +1019,7 @@ def test_ntp(self):
10191019
'--var-json', 'NTP_SERVER'
10201020
]
10211021
output = json.loads(self.run_script(argument))
1022-
self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}})
1022+
self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}})
10231023
# NTP data is present only in the host config
10241024
argument = ['-m', self.sample_graph, '--var-json', 'NTP_SERVER']
10251025

‎src/sonic-config-engine/tests/test_minigraph_case.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def test_minigraph_mgmt_port(self):
283283
def test_metadata_ntp(self):
284284
argument = ['-m', self.sample_graph, '-p', self.port_config, '-v', "NTP_SERVER"]
285285
output = self.run_script(argument)
286-
self.assertEqual(output.strip(), "{'10.0.10.1': {}, '10.0.10.2': {}}")
286+
self.assertEqual(output.strip(), "{'10.0.10.1': {'iburst': 'on'}, '10.0.10.2': {'iburst': 'on'}}")
287287

288288
def test_minigraph_vnet(self):
289289
argument = ['-m', self.sample_graph, '-p', self.port_config, '-v', "VNET"]

‎src/sonic-config-engine/tests/test_multinpu_cfggen.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_metadata_tacacs(self):
151151
def test_metadata_ntp(self):
152152
argument = ['-m', self.sample_graph, '-p', self.sample_port_config, '--var-json', "NTP_SERVER"]
153153
output = json.loads(self.run_script(argument))
154-
self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}})
154+
self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}})
155155
#NTP data is present only in the host config
156156
argument = ['-m', self.sample_graph, '--var-json', "NTP_SERVER"]
157157
for asic in range(NUM_ASIC):

0 commit comments

Comments
 (0)