summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface-definitions/load-balancing-wan.xml.in1
-rw-r--r--python/vyos/util.py7
-rw-r--r--python/vyos/utils/dict.py2
-rwxr-xr-xsrc/conf_mode/high-availability.py10
-rw-r--r--src/tests/test_util.py16
5 files changed, 11 insertions, 25 deletions
diff --git a/interface-definitions/load-balancing-wan.xml.in b/interface-definitions/load-balancing-wan.xml.in
index 3a2c111ac..c12cab22a 100644
--- a/interface-definitions/load-balancing-wan.xml.in
+++ b/interface-definitions/load-balancing-wan.xml.in
@@ -179,6 +179,7 @@
<regex>(ping|ttl|user-defined)</regex>
</constraint>
</properties>
+ <defaultValue>ping</defaultValue>
</leafNode>
</children>
</tagNode>
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 0593184cc..d5330db13 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -1146,13 +1146,6 @@ def sysctl_write(name, value):
return True
return False
-# approach follows a discussion in:
-# https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case
-def camel_to_snake_case(name: str) -> str:
- pattern = r'\d+|[A-Z]?[a-z]+|\W|[A-Z]{2,}(?=[A-Z][a-z]|\d|\W|$)'
- words = re.findall(pattern, name)
- return '_'.join(map(str.lower, words))
-
def load_as_module(name: str, path: str):
import importlib.util
diff --git a/python/vyos/utils/dict.py b/python/vyos/utils/dict.py
index 4afc9f54e..7c93deef6 100644
--- a/python/vyos/utils/dict.py
+++ b/python/vyos/utils/dict.py
@@ -253,4 +253,4 @@ def check_mutually_exclusive_options(d, keys, required=False):
raise ValueError(f"Options {orig_keys} are mutually-exclusive but more than one of them is present: {orig_present_keys}")
if required and (len(present_keys) < 1):
- raise ValueError(f"At least one of the following options is required: {orig_present_keys}")
+ raise ValueError(f"At least one of the following options is required: {orig_keys}")
diff --git a/src/conf_mode/high-availability.py b/src/conf_mode/high-availability.py
index 7a63f5b4b..e18b426b1 100755
--- a/src/conf_mode/high-availability.py
+++ b/src/conf_mode/high-availability.py
@@ -21,6 +21,7 @@ from ipaddress import ip_interface
from ipaddress import IPv4Interface
from ipaddress import IPv6Interface
+from vyos.base import Warning
from vyos.config import Config
from vyos.configdict import dict_merge
from vyos.ifconfig.vrrp import VRRP
@@ -107,11 +108,16 @@ def verify(ha):
raise ConfigError(f'Authentication requires both type and passwortd to be set in VRRP group "{group}"')
if 'health_check' in group_config:
+ health_check_types = ["script", "ping"]
from vyos.utils.dict import check_mutually_exclusive_options
try:
- check_mutually_exclusive_options(group_config["health_check"], ["script", "ping"], required=True)
+ check_mutually_exclusive_options(group_config["health_check"], health_check_types, required=True)
except ValueError as e:
- raise ConfigError(f'Health check config is incorrect in VRRP group "{group}": {e}')
+ Warning(f'Health check configuration for VRRP group "{group}" will remain unused ' \
+ f'until it has one of the following options: {health_check_types}')
+ # XXX: health check has default options so we need to remove it
+ # to avoid generating useless config statements in keepalived.conf
+ del group_config["health_check"]
# Keepalived doesn't allow mixing IPv4 and IPv6 in one group, so we mirror that restriction
# We also need to make sure VRID is not used twice on the same interface with the
diff --git a/src/tests/test_util.py b/src/tests/test_util.py
index d8b2b7940..473052bef 100644
--- a/src/tests/test_util.py
+++ b/src/tests/test_util.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2020-2022 VyOS maintainers and contributors
+# Copyright (C) 2020-2023 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -26,17 +26,3 @@ class TestVyOSUtil(TestCase):
def test_sysctl_read(self):
self.assertEqual(sysctl_read('net.ipv4.conf.lo.forwarding'), '1')
-
- def test_camel_to_snake_case(self):
- self.assertEqual(camel_to_snake_case('ConnectionTimeout'),
- 'connection_timeout')
- self.assertEqual(camel_to_snake_case('connectionTimeout'),
- 'connection_timeout')
- self.assertEqual(camel_to_snake_case('TCPConnectionTimeout'),
- 'tcp_connection_timeout')
- self.assertEqual(camel_to_snake_case('TCPPort'),
- 'tcp_port')
- self.assertEqual(camel_to_snake_case('UseHTTPProxy'),
- 'use_http_proxy')
- self.assertEqual(camel_to_snake_case('CustomerID'),
- 'customer_id')