summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-12-25 11:00:04 +0100
committerChristian Poessinger <christian@poessinger.com>2022-12-25 11:00:04 +0100
commit1ef7ba760bc7c21a754ef7cf3e5049ec88739b12 (patch)
treeac1b162faa8243860c9d461cf5865e6a2f57b63a
parentf3956a5358a713a6309dac24816d3ce59329ae06 (diff)
downloadvyos-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-xsrc/conf_mode/container.py5
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}"!')