From 1b5ff93980fed3e45897a46fe36c5785f0c668fc Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 3 Jul 2020 13:28:18 +0200 Subject: ntp: reuse new library functions for CIDR mangling --- scripts/cli/test_system_ntp.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'scripts') 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' -- cgit v1.2.3