From 13cfccb38e03402c0b75bdd6c061effeb2a80ae3 Mon Sep 17 00:00:00 2001 From: Saikrishna Arcot Date: Thu, 11 Jul 2024 16:14:58 -0700 Subject: [PATCH] Enable iburst option for NTP servers loaded from minigraph (#19424) Why I did it In #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 #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 --- src/sonic-config-engine/minigraph.py | 2 +- src/sonic-config-engine/tests/test_cfggen.py | 2 +- src/sonic-config-engine/tests/test_chassis_cfggen.py | 8 ++++---- src/sonic-config-engine/tests/test_minigraph_case.py | 2 +- src/sonic-config-engine/tests/test_multinpu_cfggen.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/sonic-config-engine/minigraph.py b/src/sonic-config-engine/minigraph.py index fb815ba80d1b..453c406e3626 100644 --- a/src/sonic-config-engine/minigraph.py +++ b/src/sonic-config-engine/minigraph.py @@ -2611,7 +2611,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw results['SYSLOG_SERVER'] = dict((item, {}) for item in syslog_servers) results['DHCP_SERVER'] = dict((item, {}) for item in dhcp_servers) results['DHCP_RELAY'] = dhcp_relay_table - results['NTP_SERVER'] = dict((item, {}) for item in ntp_servers) + results['NTP_SERVER'] = dict((item, {'iburst': 'on'}) for item in ntp_servers) # Set default DNS nameserver from dns.j2 results['DNS_NAMESERVER'] = {} if os.environ.get("CFGGEN_UNIT_TESTING", "0") == "2": diff --git a/src/sonic-config-engine/tests/test_cfggen.py b/src/sonic-config-engine/tests/test_cfggen.py index 6126522bb6dd..19e0af5cd4dd 100644 --- a/src/sonic-config-engine/tests/test_cfggen.py +++ b/src/sonic-config-engine/tests/test_cfggen.py @@ -696,7 +696,7 @@ def test_metadata_tacacs(self): def test_metadata_ntp(self): argument = ['-m', self.sample_graph_metadata, '-p', self.port_config, '-v', "NTP_SERVER"] output = self.run_script(argument) - self.assertEqual(utils.to_dict(output.strip()), utils.to_dict("{'10.0.10.1': {}, '10.0.10.2': {}}")) + self.assertEqual(utils.to_dict(output.strip()), utils.to_dict("{'10.0.10.1': {'iburst': 'on'}, '10.0.10.2': {'iburst': 'on'}}")) def test_dns_nameserver(self): argument = ['-m', self.sample_graph_metadata, '-p', self.port_config, '-v', "DNS_NAMESERVER"] diff --git a/src/sonic-config-engine/tests/test_chassis_cfggen.py b/src/sonic-config-engine/tests/test_chassis_cfggen.py index a2be6ed6b8ce..c5f1e148e9f1 100644 --- a/src/sonic-config-engine/tests/test_chassis_cfggen.py +++ b/src/sonic-config-engine/tests/test_chassis_cfggen.py @@ -104,7 +104,7 @@ def test_ntp(self): argument = ['-m', self.sample_graph, '-p', self.sample_port_config, '--var-json', 'NTP_SERVER'] output = json.loads(self.run_script(argument)) - self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}}) + self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}}) # NTP data is present only in the host config argument = ['-m', self.sample_graph, '--var-json', 'NTP_SERVER'] @@ -416,7 +416,7 @@ def test_ntp(self): argument = ['-m', self.sample_graph, '-p', self.sample_port_config, '--var-json', 'NTP_SERVER'] output = json.loads(self.run_script(argument)) - self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}}) + self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}}) # NTP data is present only in the host config argument = ['-m', self.sample_graph, '--var-json', 'NTP_SERVER'] @@ -884,7 +884,7 @@ def test_ntp(self): '--var-json', 'NTP_SERVER' ] output = json.loads(self.run_script(argument)) - self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}}) + self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}}) def test_mgmt_port(self): @@ -1019,7 +1019,7 @@ def test_ntp(self): '--var-json', 'NTP_SERVER' ] output = json.loads(self.run_script(argument)) - self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}}) + self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}}) # NTP data is present only in the host config argument = ['-m', self.sample_graph, '--var-json', 'NTP_SERVER'] diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index a5578b841df4..9e19fbdaeaff 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -283,7 +283,7 @@ def test_minigraph_mgmt_port(self): def test_metadata_ntp(self): argument = ['-m', self.sample_graph, '-p', self.port_config, '-v', "NTP_SERVER"] output = self.run_script(argument) - self.assertEqual(output.strip(), "{'10.0.10.1': {}, '10.0.10.2': {}}") + self.assertEqual(output.strip(), "{'10.0.10.1': {'iburst': 'on'}, '10.0.10.2': {'iburst': 'on'}}") def test_minigraph_vnet(self): argument = ['-m', self.sample_graph, '-p', self.port_config, '-v', "VNET"] diff --git a/src/sonic-config-engine/tests/test_multinpu_cfggen.py b/src/sonic-config-engine/tests/test_multinpu_cfggen.py index bba0adeae752..5f7646f48f1c 100644 --- a/src/sonic-config-engine/tests/test_multinpu_cfggen.py +++ b/src/sonic-config-engine/tests/test_multinpu_cfggen.py @@ -151,7 +151,7 @@ def test_metadata_tacacs(self): def test_metadata_ntp(self): argument = ['-m', self.sample_graph, '-p', self.sample_port_config, '--var-json', "NTP_SERVER"] output = json.loads(self.run_script(argument)) - self.assertDictEqual(output, {'17.39.1.130': {}, '17.39.1.129': {}}) + self.assertDictEqual(output, {'17.39.1.130': {'iburst': 'on'}, '17.39.1.129': {'iburst': 'on'}}) #NTP data is present only in the host config argument = ['-m', self.sample_graph, '--var-json', "NTP_SERVER"] for asic in range(NUM_ASIC):