summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-10-30 16:23:30 +0100
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-10-30 17:53:31 +0000
commit4fdecbf61b02c102f0070d9dd1f785643b056de2 (patch)
tree8e89c81ca1ee4662d9e1e72b04fe0199600c7221
parent2d60bc124447c5f978536b796bda4524b121a03c (diff)
downloadvyos-1x-4fdecbf61b02c102f0070d9dd1f785643b056de2.tar.gz
vyos-1x-4fdecbf61b02c102f0070d9dd1f785643b056de2.zip
vxlan: T5699: migrate "external" CLI know to "parameters external"
As we have a bunch of options under "paramteres" already and "external" is clearly one of them it should be migrated under that node as well. (cherry picked from commit cc7ba8824a5e9ec818f0bbe7fb85e1713a591527)
-rw-r--r--interface-definitions/interfaces-vxlan.xml.in12
-rw-r--r--python/vyos/ifconfig/vxlan.py2
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_vxlan.py4
-rwxr-xr-xsrc/conf_mode/interfaces-vxlan.py21
-rwxr-xr-xsrc/migration-scripts/interfaces/31-to-329
5 files changed, 27 insertions, 21 deletions
diff --git a/interface-definitions/interfaces-vxlan.xml.in b/interface-definitions/interfaces-vxlan.xml.in
index 3fae17178..d22e46bbc 100644
--- a/interface-definitions/interfaces-vxlan.xml.in
+++ b/interface-definitions/interfaces-vxlan.xml.in
@@ -19,12 +19,6 @@
#include <include/interface/address-ipv4-ipv6.xml.i>
#include <include/generic-description.xml.i>
#include <include/interface/disable.xml.i>
- <leafNode name="external">
- <properties>
- <help>Use external control plane</help>
- <valueless/>
- </properties>
- </leafNode>
<leafNode name="gpe">
<properties>
<help>Enable Generic Protocol extension (VXLAN-GPE)</help>
@@ -83,6 +77,12 @@
#include <include/interface/parameters-flowlabel.xml.i>
</children>
</node>
+ <leafNode name="external">
+ <properties>
+ <help>Use external control plane</help>
+ <valueless/>
+ </properties>
+ </leafNode>
<leafNode name="nolearning">
<properties>
<help>Do not add unknown addresses into forwarding database</help>
diff --git a/python/vyos/ifconfig/vxlan.py b/python/vyos/ifconfig/vxlan.py
index 1fe5db7cd..2ea48b214 100644
--- a/python/vyos/ifconfig/vxlan.py
+++ b/python/vyos/ifconfig/vxlan.py
@@ -68,8 +68,8 @@ class VXLANIf(Interface):
# - https://man7.org/linux/man-pages/man8/ip-link.8.html
mapping = {
'group' : 'group',
- 'external' : 'external',
'gpe' : 'gpe',
+ 'parameters.external' : 'external',
'parameters.ip.df' : 'df',
'parameters.ip.tos' : 'tos',
'parameters.ip.ttl' : 'ttl',
diff --git a/smoketest/scripts/cli/test_interfaces_vxlan.py b/smoketest/scripts/cli/test_interfaces_vxlan.py
index e9c9e68fd..cf05148ae 100755
--- a/smoketest/scripts/cli/test_interfaces_vxlan.py
+++ b/smoketest/scripts/cli/test_interfaces_vxlan.py
@@ -107,7 +107,7 @@ class VXLANInterfaceTest(BasicInterfaceTest.TestCase):
def test_vxlan_external(self):
interface = 'vxlan0'
source_address = '192.0.2.1'
- self.cli_set(self._base_path + [interface, 'external'])
+ self.cli_set(self._base_path + [interface, 'parameters', 'external'])
self.cli_set(self._base_path + [interface, 'source-address', source_address])
# Both 'VNI' and 'external' can not be specified at the same time.
@@ -150,7 +150,7 @@ class VXLANInterfaceTest(BasicInterfaceTest.TestCase):
'31': '10031',
}
- self.cli_set(self._base_path + [interface, 'external'])
+ self.cli_set(self._base_path + [interface, 'parameters', 'external'])
self.cli_set(self._base_path + [interface, 'source-interface', source_interface])
for vlan, vni in vlan_to_vni.items():
diff --git a/src/conf_mode/interfaces-vxlan.py b/src/conf_mode/interfaces-vxlan.py
index ff8144e74..16cc96c63 100755
--- a/src/conf_mode/interfaces-vxlan.py
+++ b/src/conf_mode/interfaces-vxlan.py
@@ -34,6 +34,7 @@ from vyos.configverify import verify_bond_bridge_member
from vyos.ifconfig import Interface
from vyos.ifconfig import VXLANIf
from vyos.template import is_ipv6
+from vyos.utils.dict import dict_search
from vyos import ConfigError
from vyos import airbag
airbag.enable()
@@ -53,7 +54,7 @@ def get_config(config=None):
# VXLAN interfaces are picky and require recreation if certain parameters
# change. But a VXLAN interface should - of course - not be re-created if
# it's description or IP address is adjusted. Feels somehow logic doesn't it?
- for cli_option in ['parameters', 'external', 'gpe', 'group', 'port', 'remote',
+ for cli_option in ['parameters', 'gpe', 'group', 'port', 'remote',
'source-address', 'source-interface', 'vni']:
if is_node_changed(conf, base + [ifname, cli_option]):
vxlan.update({'rebuild_required': {}})
@@ -94,17 +95,17 @@ def verify(vxlan):
if not any(tmp in ['group', 'remote', 'source_address', 'source_interface'] for tmp in vxlan):
raise ConfigError('Group, remote, source-address or source-interface must be configured')
- if 'vni' not in vxlan and 'external' not in vxlan:
- raise ConfigError(
- 'Must either configure VXLAN "vni" or use "external" CLI option!')
+ if 'vni' not in vxlan and dict_search('parameters.external', vxlan) == None:
+ raise ConfigError('Must either configure VXLAN "vni" or use "external" CLI option!')
- if {'external', 'vni'} <= set(vxlan):
- raise ConfigError('Can not specify both "external" and "VNI"!')
+ if dict_search('parameters.external', vxlan):
+ if 'vni' in vxlan:
+ raise ConfigError('Can not specify both "external" and "VNI"!')
- if {'external', 'other_tunnels'} <= set(vxlan):
- other_tunnels = ', '.join(vxlan['other_tunnels'])
- raise ConfigError(f'Only one VXLAN tunnel is supported when "external" '\
- f'CLI option is used. Additional tunnels: {other_tunnels}')
+ if 'other_tunnels' in vxlan:
+ other_tunnels = ', '.join(vxlan['other_tunnels'])
+ raise ConfigError(f'Only one VXLAN tunnel is supported when "external" '\
+ f'CLI option is used. Additional tunnels: {other_tunnels}')
if 'gpe' in vxlan and 'external' not in vxlan:
raise ConfigError(f'VXLAN-GPE is only supported when "external" '\
diff --git a/src/migration-scripts/interfaces/31-to-32 b/src/migration-scripts/interfaces/31-to-32
index 35b397c39..ca3d19320 100755
--- a/src/migration-scripts/interfaces/31-to-32
+++ b/src/migration-scripts/interfaces/31-to-32
@@ -27,7 +27,8 @@ if len(argv) < 2:
file_name = argv[1]
with open(file_name, 'r') as f:
config_file = f.read()
- base = ['interfaces', 'vxlan']
+
+base = ['interfaces', 'vxlan']
config = ConfigTree(config_file)
if not config.exists(base):
@@ -35,7 +36,11 @@ if not config.exists(base):
exit(0)
for vxlan in config.list_nodes(base):
- if not config.exists(base + ['port']):
+ if config.exists(base + [vxlan, 'external']):
+ config.delete(base + [vxlan, 'external'])
+ config.set(base + [vxlan, 'parameters', 'external'])
+
+ if not config.exists(base + [vxlan, 'port']):
config.set(base + [vxlan, 'port'], value='8472')
try: