diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-12-25 11:00:04 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-12-25 11:00:04 +0100 |
commit | 1ef7ba760bc7c21a754ef7cf3e5049ec88739b12 (patch) | |
tree | ac1b162faa8243860c9d461cf5865e6a2f57b63a | |
parent | f3956a5358a713a6309dac24816d3ce59329ae06 (diff) | |
download | vyos-1x-1ef7ba760bc7c21a754ef7cf3e5049ec88739b12.tar.gz vyos-1x-1ef7ba760bc7c21a754ef7cf3e5049ec88739b12.zip |
container: T2216: add verify() for port definition
If port is specified on the CLI so must be source and destination under
the port node.
-rwxr-xr-x | src/conf_mode/container.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py index 8efeaed54..48ba409a8 100755 --- a/src/conf_mode/container.py +++ b/src/conf_mode/container.py @@ -168,6 +168,11 @@ def verify(container): if not os.path.exists(source): raise ConfigError(f'Volume "{volume}" source path "{source}" does not exist!') + if 'port' in container_config: + for tmp in container_config['port']: + if not {'source', 'destination'} <= set(container_config['port'][tmp]): + raise ConfigError(f'Both "source" and "destination" must be specified for a port mapping!') + # If 'allow-host-networks' or 'network' not set. if 'allow_host_networks' not in container_config and 'network' not in container_config: raise ConfigError(f'Must either set "network" or "allow-host-networks" for container "{name}"!') |