summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-09-21 22:07:33 +0200
committerChristian Poessinger <christian@poessinger.com>2021-09-21 22:11:49 +0200
commitb9d4d8c67d6b41ebbf5b570c7c6b09e05520e737 (patch)
tree8ba912776fddc2ef299c1675822c909c1da86ef4
parent2a57f786931793d59cc5ec2c3a925807b6ee3938 (diff)
downloadvyos-1x-b9d4d8c67d6b41ebbf5b570c7c6b09e05520e737.tar.gz
vyos-1x-b9d4d8c67d6b41ebbf5b570c7c6b09e05520e737.zip
vrrp: keepalived: T3847: migrate/streamline CLI options
Rename virtual-address -> address as we always talk about an IP address.
-rw-r--r--data/templates/vrrp/keepalived.conf.tmpl8
-rw-r--r--interface-definitions/vrrp.xml.in7
-rwxr-xr-xsmoketest/scripts/cli/test_ha_vrrp.py6
-rwxr-xr-xsrc/conf_mode/vrrp.py6
-rwxr-xr-xsrc/migration-scripts/vrrp/2-to-310
5 files changed, 23 insertions, 14 deletions
diff --git a/data/templates/vrrp/keepalived.conf.tmpl b/data/templates/vrrp/keepalived.conf.tmpl
index a1e47abc3..e31bfaac0 100644
--- a/data/templates/vrrp/keepalived.conf.tmpl
+++ b/data/templates/vrrp/keepalived.conf.tmpl
@@ -60,16 +60,16 @@ vrrp_instance {{ name }} {
{% endif %}
}
{% endif %}
-{% if group_config.virtual_address is defined and group_config.virtual_address is not none %}
+{% if group_config.address is defined and group_config.address is not none %}
virtual_ipaddress {
-{% for addr in group_config.virtual_address %}
+{% for addr in group_config.address %}
{{ addr }}
{% endfor %}
}
{% endif %}
-{% if group_config.virtual_address_excluded is defined and group_config.virtual_address_excluded is not none %}
+{% if group_config.excluded_address is defined and group_config.excluded_address is not none %}
virtual_ipaddress_excluded {
-{% for addr in group_config.virtual_address_excluded %}
+{% for addr in group_config.excluded_address %}
{{ addr }}
{% endfor %}
}
diff --git a/interface-definitions/vrrp.xml.in b/interface-definitions/vrrp.xml.in
index 44bd7e454..44a9a1f54 100644
--- a/interface-definitions/vrrp.xml.in
+++ b/interface-definitions/vrrp.xml.in
@@ -185,9 +185,9 @@
</properties>
</leafNode>
#include <include/vrrp-transition-script.xml.i>
- <leafNode name="virtual-address">
+ <leafNode name="address">
<properties>
- <help>Virtual address (IPv4 or IPv6, but they must not be mixed in one group)</help>
+ <help>Virtual IP address</help>
<valueHelp>
<format>ipv4</format>
<description>IPv4 virtual address</description>
@@ -200,11 +200,10 @@
<validator name="ipv4-host"/>
<validator name="ipv6-host"/>
</constraint>
- <constraintErrorMessage>Virtual address must be a valid IPv4 or IPv6 address with prefix length (e.g. 192.0.2.3/24 or 2001:db8:ff::10/64)</constraintErrorMessage>
<multi/>
</properties>
</leafNode>
- <leafNode name="virtual-address-excluded">
+ <leafNode name="excluded-address">
<properties>
<help>Virtual address (If you need additional IPv4 and IPv6 in same group)</help>
<valueHelp>
diff --git a/smoketest/scripts/cli/test_ha_vrrp.py b/smoketest/scripts/cli/test_ha_vrrp.py
index 9c8d26699..4a743fe5e 100755
--- a/smoketest/scripts/cli/test_ha_vrrp.py
+++ b/smoketest/scripts/cli/test_ha_vrrp.py
@@ -59,7 +59,7 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase):
self.cli_set(group_base + ['description', group])
self.cli_set(group_base + ['interface', f'{vrrp_interface}.{vlan_id}'])
- self.cli_set(group_base + ['virtual-address', vip])
+ self.cli_set(group_base + ['address', vip])
self.cli_set(group_base + ['vrid', vlan_id])
# commit changes
@@ -93,7 +93,7 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase):
self.cli_set(group_base + ['description', group])
self.cli_set(group_base + ['interface', f'{vrrp_interface}.{vlan_id}'])
- self.cli_set(group_base + ['virtual-address', vip])
+ self.cli_set(group_base + ['address', vip])
self.cli_set(group_base + ['vrid', vlan_id])
self.cli_set(group_base + ['advertise-interval', advertise_interval])
@@ -139,7 +139,7 @@ class TestVRRP(VyOSUnitTestSHIM.TestCase):
self.cli_set(['interfaces', 'ethernet', vrrp_interface, 'vif', vlan_id, 'address', inc_ip(vip, 1) + '/' + vip.split('/')[-1]])
self.cli_set(group_base + ['interface', f'{vrrp_interface}.{vlan_id}'])
- self.cli_set(group_base + ['virtual-address', vip])
+ self.cli_set(group_base + ['address', vip])
self.cli_set(group_base + ['vrid', vlan_id])
self.cli_set(base_path + ['sync-group', sync_group, 'member', group])
diff --git a/src/conf_mode/vrrp.py b/src/conf_mode/vrrp.py
index ba156e915..ffe9dd276 100755
--- a/src/conf_mode/vrrp.py
+++ b/src/conf_mode/vrrp.py
@@ -72,8 +72,8 @@ def verify(vrrp):
if 'interface' not in group_config:
raise ConfigError(f'Interface is required but not set in VRRP group "{group}"')
- if 'virtual_address' not in group_config:
- raise ConfigError(f'virtual-address is required but not set in VRRP group "{group}"')
+ if 'address' not in group_config:
+ raise ConfigError(f'Virtual IP address is required but not set in VRRP group "{group}"')
if 'authentication' in group_config:
if not {'password', 'type'} <= set(group_config['authentication']):
@@ -92,7 +92,7 @@ def verify(vrrp):
# XXX: filter on map object is destructive, so we force it to list.
# Additionally, filter objects always evaluate to True, empty or not,
# so we force them to lists as well.
- vaddrs = list(map(lambda i: ip_interface(i), group_config['virtual_address']))
+ vaddrs = list(map(lambda i: ip_interface(i), group_config['address']))
vaddrs4 = list(filter(lambda x: isinstance(x, IPv4Interface), vaddrs))
vaddrs6 = list(filter(lambda x: isinstance(x, IPv6Interface), vaddrs))
diff --git a/src/migration-scripts/vrrp/2-to-3 b/src/migration-scripts/vrrp/2-to-3
index b96ca139d..1151ae18c 100755
--- a/src/migration-scripts/vrrp/2-to-3
+++ b/src/migration-scripts/vrrp/2-to-3
@@ -44,6 +44,16 @@ if config.exists(base + ['group']):
if config.exists(tmp):
config.delete(tmp)
+ # Rename virtual-address -> address
+ tmp = group_base + ['virtual-address']
+ if config.exists(tmp):
+ config.rename(tmp, 'address')
+
+ # Rename virtual-address-excluded -> excluded-address
+ tmp = group_base + ['virtual-address-excluded']
+ if config.exists(tmp):
+ config.rename(tmp, 'excluded-address')
+
try:
with open(file_name, 'w') as f:
f.write(config.to_string())