From 9d92a6fde4cb44861b2bd0a00fe785d409880f4b Mon Sep 17 00:00:00 2001 From: jlmcgraw Date: Fri, 24 Oct 2025 13:38:26 -0400 Subject: [PATCH 1/4] Handle NTP servers configured to use a key --- src/genie/libs/parser/iosxe/show_ntp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/genie/libs/parser/iosxe/show_ntp.py b/src/genie/libs/parser/iosxe/show_ntp.py index 406169cfa..ca5a5d739 100644 --- a/src/genie/libs/parser/iosxe/show_ntp.py +++ b/src/genie/libs/parser/iosxe/show_ntp.py @@ -378,7 +378,7 @@ def cli(self, output=None): # ntp server 10.3.254.100 prefer p1 = re.compile(r"^ntp +(?P\w+)( +vrf +(?P\S+))? " r"+(?P
[\w\.\:]+)( +source +" - r"(?P[\w]+))?(?P prefer)?$") + r"(?P[\w]+))?( +key +(?P\S+))?(?P prefer)?$") for line in out.splitlines(): line = line.strip() From 9c4e4c1a2e7345e0406964f7ebaf40ba35dee8d6 Mon Sep 17 00:00:00 2001 From: jlmcgraw Date: Tue, 28 Oct 2025 11:19:59 -0400 Subject: [PATCH 2/4] Handle NTP servers configured to use a key --- ...w_ntp_configuration_iosxe_202510271000.rst | 4 ++ src/genie/libs/parser/iosxe/show_ntp.py | 9 +++- .../cli/equal/golden_output_2_expected.py | 51 +++++++++++++++++++ .../cli/equal/golden_output_2_output.txt | 5 ++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst create mode 100644 src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py create mode 100644 src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_output.txt diff --git a/changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst b/changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst new file mode 100644 index 000000000..68a4250f6 --- /dev/null +++ b/changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst @@ -0,0 +1,4 @@ +* iosxe + * Modified ShowNtpConfig + * Modified regex pattern to support ntp servers configured with keys + * Changed schema to include "key_id" diff --git a/src/genie/libs/parser/iosxe/show_ntp.py b/src/genie/libs/parser/iosxe/show_ntp.py index ca5a5d739..52d2c1876 100644 --- a/src/genie/libs/parser/iosxe/show_ntp.py +++ b/src/genie/libs/parser/iosxe/show_ntp.py @@ -341,6 +341,7 @@ class ShowNtpConfigSchema(MetaParser): 'vrf': str, Optional('source'): str, Optional('preferred'): bool, + Optional('key_id'): str, } }, 'isconfigured': { @@ -376,9 +377,11 @@ def cli(self, output=None): # ntp server vrf VRF1 10.64.4.4 # ntp server 10.16.2.2 source Loopback0 # ntp server 10.3.254.100 prefer + # ntp server vrf Mgmt 10.2.2.2 key 2 + # ntp server vrf Mgmt 10.3.3.3 key 3 prefer p1 = re.compile(r"^ntp +(?P\w+)( +vrf +(?P\S+))? " r"+(?P
[\w\.\:]+)( +source +" - r"(?P[\w]+))?( +key +(?P\S+))?(?P prefer)?$") + r"(?P[\w]+))?( +key +(?P\S+))?(?P prefer)?$") for line in out.splitlines(): line = line.strip() @@ -393,6 +396,7 @@ def cli(self, output=None): address = groups['address'] source = groups['source_interface'] or '' prefer = groups['prefer'] + key_id = groups['key_id'] isconfigured = True addr_dict = ret_dict.setdefault('vrf', {}).setdefault(vrf, {})\ @@ -408,6 +412,9 @@ def cli(self, output=None): if source: addr_dict['type'][ntp_type]['source'] = source + if key_id: + addr_dict['type'][ntp_type]['key_id'] = key_id + addr_dict.setdefault('isconfigured', {}).\ setdefault(str(isconfigured), {}).update({'address': address, 'isconfigured': isconfigured}) diff --git a/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py b/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py new file mode 100644 index 000000000..f2902dfe7 --- /dev/null +++ b/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py @@ -0,0 +1,51 @@ +expected_output = { + 'vrf': { + 'Mgmt': { + 'unicast_configuration': { + 'address': { + '10.4.4.4': { + 'type': { + 'server': { + 'address': '10.4.4.4', + 'type': 'server', + 'vrf': 'Mgmt', + 'preferred': True, + 'key_id': '5' + } + } + }, + '10.3.3.3': { + 'type': { + 'server': { + 'address': '10.3.3.3', + 'type': 'server', + 'vrf': 'Mgmt', + 'key_id': '4' + } + } + }, + '10.2.2.2': { + 'type': { + 'server': { + 'address': '10.2.2.2', + 'type': 'server', + 'vrf': 'Mgmt', + 'key_id': '3' + } + } + }, + '10.1.1.1': { + 'type': { + 'server': { + 'address': '10.1.1.1', + 'type': 'server', + 'vrf': 'Mgmt', + 'key_id': '2' + } + } + } + } + } + } + } +} diff --git a/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_output.txt b/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_output.txt new file mode 100644 index 000000000..b459c7eb0 --- /dev/null +++ b/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_output.txt @@ -0,0 +1,5 @@ +R1#show ntp config +ntp server vrf Mgmt 10.1.1.1 key 2 +ntp server vrf Mgmt 10.2.2.2 key 3 +ntp server vrf Mgmt 10.3.3.3 key 4 +ntp server vrf Mgmt 10.4.4.4 key 5 prefer \ No newline at end of file From 5adb22924fb761c7fb8a66986b020e11ff32a623 Mon Sep 17 00:00:00 2001 From: Thomas Ryan Date: Tue, 28 Oct 2025 12:06:56 -0400 Subject: [PATCH 3/4] Update changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst --- .../changelog_show_ntp_configuration_iosxe_202510271000.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst b/changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst index 68a4250f6..ebc08b4bb 100644 --- a/changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst +++ b/changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst @@ -1,3 +1,6 @@ +---------------------- + Fix +---------------------- * iosxe * Modified ShowNtpConfig * Modified regex pattern to support ntp servers configured with keys From bbfabbdcf6274ee662771c4b237d37788961066a Mon Sep 17 00:00:00 2001 From: jlmcgraw Date: Tue, 28 Oct 2025 13:23:47 -0400 Subject: [PATCH 4/4] Handle NTP servers configured to use a key --- .../cli/equal/golden_output_2_expected.py | 94 ++++++++++++------- 1 file changed, 58 insertions(+), 36 deletions(-) diff --git a/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py b/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py index f2902dfe7..606839cdc 100644 --- a/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py +++ b/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py @@ -1,51 +1,73 @@ expected_output = { 'vrf': { 'Mgmt': { - 'unicast_configuration': { - 'address': { - '10.4.4.4': { - 'type': { - 'server': { - 'address': '10.4.4.4', - 'type': 'server', - 'vrf': 'Mgmt', - 'preferred': True, - 'key_id': '5' - } + 'address': { + '10.1.1.1': { + 'type': { + 'server': { + 'address': '10.1.1.1', + 'type': 'server', + 'vrf': 'Mgmt', + 'key_id': '2' } }, - '10.3.3.3': { - 'type': { - 'server': { - 'address': '10.3.3.3', - 'type': 'server', - 'vrf': 'Mgmt', - 'key_id': '4' - } + 'isconfigured': { + 'True': { + 'address': '10.1.1.1', + 'isconfigured': True + } + } + }, + '10.2.2.2': { + 'type': { + 'server': { + 'address': '10.2.2.2', + 'type': 'server', + 'vrf': 'Mgmt', + 'key_id': '3' + } + }, + 'isconfigured': { + 'True': { + 'address': '10.2.2.2', + 'isconfigured': True + } + } + }, + '10.3.3.3': { + 'type': { + 'server': { + 'address': '10.3.3.3', + 'type': 'server', + 'vrf': 'Mgmt', + 'key_id': '4' } }, - '10.2.2.2': { - 'type': { - 'server': { - 'address': '10.2.2.2', - 'type': 'server', - 'vrf': 'Mgmt', - 'key_id': '3' - } + 'isconfigured': { + 'True': { + 'address': '10.3.3.3', + 'isconfigured': True + } + } + }, + '10.4.4.4': { + 'type': { + 'server': { + 'address': '10.4.4.4', + 'type': 'server', + 'vrf': 'Mgmt', + 'preferred': True, + 'key_id': '5' } }, - '10.1.1.1': { - 'type': { - 'server': { - 'address': '10.1.1.1', - 'type': 'server', - 'vrf': 'Mgmt', - 'key_id': '2' - } + 'isconfigured': { + 'True': { + 'address': '10.4.4.4', + 'isconfigured': True } } } } } } -} +} \ No newline at end of file