summaryrefslogtreecommitdiff
path: root/src/conf_mode/container.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-24 13:21:42 +0100
committerChristian Breunig <christian@breunig.cc>2023-12-28 15:09:08 +0100
commit410d66f5f087f50972781224404eb060609f5a09 (patch)
tree6a5561620dbc24b1033d677e53f8628f691db244 /src/conf_mode/container.py
parent0ac1f1b69fd52464cef91c9c455562fe72c10ce1 (diff)
downloadvyos-1x-410d66f5f087f50972781224404eb060609f5a09.tar.gz
vyos-1x-410d66f5f087f50972781224404eb060609f5a09.zip
container: T5829: verify container network used supports the given AFI
(cherry picked from commit e70ca62c474b4e2cc135851a6e5cceee037bf378)
Diffstat (limited to 'src/conf_mode/container.py')
-rwxr-xr-xsrc/conf_mode/container.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py
index daad9186e..f1bd018c1 100755
--- a/src/conf_mode/container.py
+++ b/src/conf_mode/container.py
@@ -142,11 +142,17 @@ def verify(container):
for address in container_config['network'][network_name]['address']:
network = None
if is_ipv4(address):
- network = [x for x in container['network'][network_name]['prefix'] if is_ipv4(x)][0]
- cnt_ipv4 += 1
+ try:
+ network = [x for x in container['network'][network_name]['prefix'] if is_ipv4(x)][0]
+ cnt_ipv4 += 1
+ except:
+ raise ConfigError(f'Network "{network_name}" does not contain an IPv4 prefix!')
elif is_ipv6(address):
- network = [x for x in container['network'][network_name]['prefix'] if is_ipv6(x)][0]
- cnt_ipv6 += 1
+ try:
+ network = [x for x in container['network'][network_name]['prefix'] if is_ipv6(x)][0]
+ cnt_ipv6 += 1
+ except:
+ raise ConfigError(f'Network "{network_name}" does not contain an IPv6 prefix!')
# Specified container IP address must belong to network prefix
if ip_address(address) not in ip_network(network):