diff options
author | Ryazanov Alexander Mihailovich <alryaz@alryaz.com> | 2024-05-18 16:50:55 +0300 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-05-22 18:02:02 +0000 |
commit | c64d877d2a1fdf6a596a5c4036b3d045703b5931 (patch) | |
tree | 88dc84cc2de8aae331882e7a5167594aa8a51226 /src | |
parent | 82b14fb2bb89eb93eb9b5275b1d94d1bc61d0806 (diff) | |
download | vyos-1x-c64d877d2a1fdf6a596a5c4036b3d045703b5931.tar.gz vyos-1x-c64d877d2a1fdf6a596a5c4036b3d045703b5931.zip |
nat: T6365: remove warnings for negated interface selections by name
(cherry picked from commit 03eae30b27433055ddc10f09fc134b83e9bd6cec)
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/nat.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/conf_mode/nat.py b/src/conf_mode/nat.py index 4cd9b570d..056351986 100755 --- a/src/conf_mode/nat.py +++ b/src/conf_mode/nat.py @@ -149,8 +149,12 @@ def verify(nat): if 'name' in config['outbound_interface'] and 'group' in config['outbound_interface']: raise ConfigError(f'{err_msg} cannot specify both interface group and interface name for nat source rule "{rule}"') elif 'name' in config['outbound_interface']: - if config['outbound_interface']['name'] not in 'any' and config['outbound_interface']['name'] not in interfaces(): - Warning(f'NAT interface "{config["outbound_interface"]["name"]}" for source NAT rule "{rule}" does not exist!') + interface_name = config['outbound_interface']['name'] + if interface_name not in 'any': + if interface_name[0] == '!': + interface_name = interface_name[1:] + if interface_name not in interfaces(): + Warning(f'NAT interface "{interface_name}" for source NAT rule "{rule}" does not exist!') else: group_name = config['outbound_interface']['group'] if group_name[0] == '!': @@ -182,8 +186,12 @@ def verify(nat): if 'name' in config['inbound_interface'] and 'group' in config['inbound_interface']: raise ConfigError(f'{err_msg} cannot specify both interface group and interface name for destination nat rule "{rule}"') elif 'name' in config['inbound_interface']: - if config['inbound_interface']['name'] not in 'any' and config['inbound_interface']['name'] not in interfaces(): - Warning(f'NAT interface "{config["inbound_interface"]["name"]}" for destination NAT rule "{rule}" does not exist!') + interface_name = config['inbound_interface']['name'] + if interface_name not in 'any': + if interface_name[0] == '!': + interface_name = interface_name[1:] + if interface_name not in interfaces(): + Warning(f'NAT interface "{interface_name}" for destination NAT rule "{rule}" does not exist!') else: group_name = config['inbound_interface']['group'] if group_name[0] == '!': |