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 0000000000..ebc08b4bb6 --- /dev/null +++ b/changelog/undistributed/changelog_show_ntp_configuration_iosxe_202510271000.rst @@ -0,0 +1,7 @@ +---------------------- + Fix +---------------------- +* 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 406169cfad..52d2c18764 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]+))?(?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 0000000000..606839cdc7 --- /dev/null +++ b/src/genie/libs/parser/iosxe/tests/ShowNtpConfig/cli/equal/golden_output_2_expected.py @@ -0,0 +1,73 @@ +expected_output = { + 'vrf': { + 'Mgmt': { + 'address': { + '10.1.1.1': { + 'type': { + 'server': { + 'address': '10.1.1.1', + 'type': 'server', + 'vrf': 'Mgmt', + 'key_id': '2' + } + }, + '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' + } + }, + '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' + } + }, + 'isconfigured': { + 'True': { + 'address': '10.4.4.4', + 'isconfigured': True + } + } + } + } + } + } +} \ No newline at end of file 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 0000000000..b459c7eb00 --- /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