summaryrefslogtreecommitdiff
path: root/src/conf_mode/container.py
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-04-06 08:05:19 +0200
committerChristian Breunig <christian@breunig.cc>2023-04-06 08:05:19 +0200
commit5f94bde6d6024b753765d28d2fdb69806f1968b5 (patch)
treea8ccfa5c655f5d72ff4b0ba3df1f3cb893f36711 /src/conf_mode/container.py
parent85b46a6b225c4595a23d75e5c4d9b4ed61ee1477 (diff)
downloadvyos-1x-5f94bde6d6024b753765d28d2fdb69806f1968b5.tar.gz
vyos-1x-5f94bde6d6024b753765d28d2fdb69806f1968b5.zip
container: T5147: ensure container network exists before VRF operation
Networks are started only as soon as there is a consumer. If only a network is created in the first place, no need to assign it to a VRF as there's no consumer, yet.
Diffstat (limited to 'src/conf_mode/container.py')
-rwxr-xr-xsrc/conf_mode/container.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/conf_mode/container.py b/src/conf_mode/container.py
index 05595f86f..4b7ab3444 100755
--- a/src/conf_mode/container.py
+++ b/src/conf_mode/container.py
@@ -479,8 +479,13 @@ def apply(container):
# the network interface in advance
if 'network' in container:
for network, network_config in container['network'].items():
- tmp = Interface(f'podman-{network}')
- tmp.set_vrf(network_config.get('vrf', ''))
+ network_name = f'podman-{network}'
+ # T5147: Networks are started only as soon as there is a consumer.
+ # If only a network is created in the first place, no need to assign
+ # it to a VRF as there's no consumer, yet.
+ if os.path.exists(f'/sys/class/net/{network_name}'):
+ tmp = Interface(network_name)
+ tmp.set_vrf(network_config.get('vrf', ''))
return None