From d7961e8d0efbe6db3cfd4e373edc4d3f0d54f62f Mon Sep 17 00:00:00 2001 From: Renato Orgito Date: Fri, 29 Jun 2018 19:35:00 -0300 Subject: [PATCH] Implement get_ntp_peers on Cisco IOS (#752) --- napalm/ios/ios.py | 6 ++++++ .../test_get_ntp_peers/normal/expected_result.json | 3 +++ .../test_get_ntp_peers/normal/show_ntp_associations.txt | 4 ++++ 3 files changed, 13 insertions(+) create mode 100644 test/ios/mocked_data/test_get_ntp_peers/normal/expected_result.json create mode 100644 test/ios/mocked_data/test_get_ntp_peers/normal/show_ntp_associations.txt diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 611bf0ad1..bf80bbbcf 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -1856,6 +1856,12 @@ def cli(self, commands): return cli_output + def get_ntp_peers(self): + """Implementation of get_ntp_peers for IOS.""" + ntp_stats = self.get_ntp_stats() + + return {ntp_peer.get('remote'): {} for ntp_peer in ntp_stats if ntp_peer.get('remote')} + def get_ntp_servers(self): """Implementation of get_ntp_servers for IOS. diff --git a/test/ios/mocked_data/test_get_ntp_peers/normal/expected_result.json b/test/ios/mocked_data/test_get_ntp_peers/normal/expected_result.json new file mode 100644 index 000000000..dba350192 --- /dev/null +++ b/test/ios/mocked_data/test_get_ntp_peers/normal/expected_result.json @@ -0,0 +1,3 @@ +{ + "172.29.50.34" : {} +} diff --git a/test/ios/mocked_data/test_get_ntp_peers/normal/show_ntp_associations.txt b/test/ios/mocked_data/test_get_ntp_peers/normal/show_ntp_associations.txt new file mode 100644 index 000000000..67a1a3e06 --- /dev/null +++ b/test/ios/mocked_data/test_get_ntp_peers/normal/show_ntp_associations.txt @@ -0,0 +1,4 @@ + + address ref clock st when poll reach delay offset disp +*~172.29.50.34 83.168.200.199 3 54 1024 377 1.186 0.122 18.659 + * sys.peer, # selected, + candidate, - outlyer, x falseticker, ~ configured