diff options
| author | Christian Breunig <christian@breunig.cc> | 2023-04-06 08:05:19 +0200 | 
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2023-04-06 08:05:19 +0200 | 
| commit | 5f94bde6d6024b753765d28d2fdb69806f1968b5 (patch) | |
| tree | a8ccfa5c655f5d72ff4b0ba3df1f3cb893f36711 | |
| parent | 85b46a6b225c4595a23d75e5c4d9b4ed61ee1477 (diff) | |
| download | vyos-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.
| -rwxr-xr-x | src/conf_mode/container.py | 9 | 
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 | 
