diff options
| author | Ruben Herold <ruben@puettmann.net> | 2026-08-10 15:40:48 +0200 |
|---|---|---|
| committer | Ruben Herold <ruben@puettmann.net> | 2026-08-10 15:40:48 +0200 |
| commit | d3b48b76bd71fec1d09db6c72963de797f8ccb93 (patch) | |
| tree | 34ced83f5e0474b0a310a966b1d73183532da02c | |
| parent | 4432fcf72ca20be430aa9577eee0446d35a2539b (diff) | |
| download | vyos-1x-d3b48b76bd71fec1d09db6c72963de797f8ccb93.tar.gz vyos-1x-d3b48b76bd71fec1d09db6c72963de797f8ccb93.zip | |
ntp: T9159: apply darker/black formatting
| -rwxr-xr-x | smoketest/scripts/cli/test_service_ntp.py | 13 | ||||
| -rwxr-xr-x | src/conf_mode/service_ntp.py | 27 |
2 files changed, 26 insertions, 14 deletions
diff --git a/smoketest/scripts/cli/test_service_ntp.py b/smoketest/scripts/cli/test_service_ntp.py index 03caa73b3..0b8094963 100755 --- a/smoketest/scripts/cli/test_service_ntp.py +++ b/smoketest/scripts/cli/test_service_ntp.py @@ -145,8 +145,8 @@ class TestSystemNTP(VyOSUnitTestSHIM.TestCase): self.cli_set(base_path + ['source-address', '192.0.2.2']) try: with self.assertRaisesRegex( - ConfigSessionError, - 'Only admits one ipv4 value for source-address'): + ConfigSessionError, 'Only admits one ipv4 value for source-address' + ): self.cli_commit() finally: # remove the invalid subtree entirely (rather than leaving a @@ -172,8 +172,8 @@ class TestSystemNTP(VyOSUnitTestSHIM.TestCase): self.cli_set(base_path + ['source-address', '2001:db8::2']) try: with self.assertRaisesRegex( - ConfigSessionError, - 'Only admits one ipv6 value for source-address'): + ConfigSessionError, 'Only admits one ipv6 value for source-address' + ): self.cli_commit() finally: # see the ipv4 test above for why this is in a finally block @@ -185,8 +185,9 @@ class TestSystemNTP(VyOSUnitTestSHIM.TestCase): # source-address must be assigned to a local interface self.cli_set(base_path + ['source-address', '192.0.2.1']) try: - with self.assertRaisesRegex(ConfigSessionError, - 'not assigned to any interface'): + with self.assertRaisesRegex( + ConfigSessionError, 'not assigned to any interface' + ): self.cli_commit() finally: self.cli_delete(base_path + ['source-address']) diff --git a/src/conf_mode/service_ntp.py b/src/conf_mode/service_ntp.py index 7a49be6c1..66cf775a3 100755 --- a/src/conf_mode/service_ntp.py +++ b/src/conf_mode/service_ntp.py @@ -94,8 +94,10 @@ def verify(ntp): tmp = get_interface_config(source_interface) vrf_name = ntp['vrf'] if 'master' not in tmp or tmp['master'] != vrf_name: - raise ConfigError(f'NTP runs in VRF "{vrf_name}" - "{source_interface}" '\ - f'does not belong to this VRF!') + raise ConfigError( + f'NTP runs in VRF "{vrf_name}" - "{source_interface}" ' + f'does not belong to this VRF!' + ) if 'listen_address' in ntp: ipv4_addresses = 0 @@ -106,9 +108,13 @@ def verify(ntp): else: ipv6_addresses += 1 if ipv4_addresses > 1: - raise ConfigError('NTP Only admits one ipv4 value for listen-address parameter') + raise ConfigError( + 'NTP Only admits one ipv4 value for listen-address parameter' + ) if ipv6_addresses > 1: - raise ConfigError('NTP Only admits one ipv6 value for listen-address parameter') + raise ConfigError( + 'NTP Only admits one ipv6 value for listen-address parameter' + ) if 'source_address' in ntp: ipv4_addresses = 0 @@ -120,12 +126,17 @@ def verify(ntp): else: ipv6_addresses += 1 if not is_addr_assigned(address, vrf): - raise ConfigError(f'NTP source-address "{address}" not assigned ' - 'to any interface!') + raise ConfigError( + f'NTP source-address "{address}" not assigned ' 'to any interface!' + ) if ipv4_addresses > 1: - raise ConfigError('NTP Only admits one ipv4 value for source-address parameter') + raise ConfigError( + 'NTP Only admits one ipv4 value for source-address parameter' + ) if ipv6_addresses > 1: - raise ConfigError('NTP Only admits one ipv6 value for source-address parameter') + raise ConfigError( + 'NTP Only admits one ipv6 value for source-address parameter' + ) if 'server' in ntp: for host, server in ntp['server'].items(): |
