diff options
| author | Christian Breunig <christian@breunig.cc> | 2023-10-30 18:52:40 +0100 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-30 18:52:40 +0100 | 
| commit | 18a0accde0cb6887449be2ced3f092cce77b3d3e (patch) | |
| tree | 1a80622308918ddeb0de93cb426f6e210df1b6b2 /src | |
| parent | d223ee5fc5c0f1a252659293a3d49056616f8eef (diff) | |
| parent | cc7ba8824a5e9ec818f0bbe7fb85e1713a591527 (diff) | |
| download | vyos-1x-18a0accde0cb6887449be2ced3f092cce77b3d3e.tar.gz vyos-1x-18a0accde0cb6887449be2ced3f092cce77b3d3e.zip  | |
Merge pull request #2417 from c-po/vxlan-t5699
vxlan: T5699: migrate "external" CLI know to "parameters external"
Diffstat (limited to 'src')
| -rwxr-xr-x | src/conf_mode/interfaces-vxlan.py | 21 | ||||
| -rwxr-xr-x | src/migration-scripts/interfaces/31-to-32 | 9 | 
2 files changed, 18 insertions, 12 deletions
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:  | 
