summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-07-03 13:28:18 +0200
committerChristian Poessinger <christian@poessinger.com>2020-07-03 13:28:18 +0200
commit1b5ff93980fed3e45897a46fe36c5785f0c668fc (patch)
treeae57253eece7e9f74adde0e98ba95461142cef59 /scripts
parent2ac2c022d82b572caf40ae04e197ad736233939b (diff)
downloadvyos-1x-1b5ff93980fed3e45897a46fe36c5785f0c668fc.tar.gz
vyos-1x-1b5ff93980fed3e45897a46fe36c5785f0c668fc.zip
ntp: reuse new library functions for CIDR mangling
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cli/test_system_ntp.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/scripts/cli/test_system_ntp.py b/scripts/cli/test_system_ntp.py
index ede096376..856a28916 100755
--- a/scripts/cli/test_system_ntp.py
+++ b/scripts/cli/test_system_ntp.py
@@ -18,9 +18,9 @@ import re
import os
import unittest
-from ipaddress import ip_network
from psutil import process_iter
from vyos.configsession import ConfigSession, ConfigSessionError
+from vyos.template import vyos_address_from_cidr, vyos_netmask_from_cidr
from vyos.util import read_file
NTP_CONF = '/etc/ntp.conf'
@@ -29,7 +29,8 @@ base_path = ['system', 'ntp']
def get_config_value(key):
tmp = read_file(NTP_CONF)
tmp = re.findall(r'\n?{}\s+(.*)'.format(key), tmp)
- return tmp
+ # remove possible trailing whitespaces
+ return [item.strip() for item in tmp]
class TestSystemNTP(unittest.TestCase):
def setUp(self):
@@ -86,8 +87,8 @@ class TestSystemNTP(unittest.TestCase):
# Check generated client address configuration
for network in networks:
- network_address = ip_network(network).network_address
- network_netmask = ip_network(network).netmask
+ network_address = vyos_address_from_cidr(network)
+ network_netmask = vyos_netmask_from_cidr(network)
tmp = get_config_value(f'restrict {network_address}')[0]
test = f'mask {network_netmask} nomodify notrap nopeer'