diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-01-11 08:21:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-11 08:21:36 +0100 |
commit | 1a33b2f6db4781d3c48f5ddc62da530807e784c8 (patch) | |
tree | 47e707b09b83294e6a6fe6c853dac1738a178c7e | |
parent | bb76e8d7f16355b140a60feafbbed67774788343 (diff) | |
parent | 142c976ca4b37fbae9ec44487d146b2a8319391c (diff) | |
download | vyos-1x-1a33b2f6db4781d3c48f5ddc62da530807e784c8.tar.gz vyos-1x-1a33b2f6db4781d3c48f5ddc62da530807e784c8.zip |
Merge pull request #1154 from imathew/current
containers: T2216: bugfix host networking on image upgrade
-rwxr-xr-x | src/conf_mode/containers.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/conf_mode/containers.py b/src/conf_mode/containers.py index 2e14e0b25..26c50cab6 100755 --- a/src/conf_mode/containers.py +++ b/src/conf_mode/containers.py @@ -298,7 +298,7 @@ def apply(container): f'--memory {memory}m --memory-swap 0 --restart {restart} ' \ f'--name {name} {port} {volume} {env_opt}' if 'allow_host_networks' in container_config: - _cmd(f'{container_base_cmd} --net host {image}') + run(f'{container_base_cmd} --net host {image}') else: for network in container_config['network']: ipparam = '' @@ -306,19 +306,25 @@ def apply(container): address = container_config['network'][network]['address'] ipparam = f'--ip {address}' - counter = 0 - while True: - if counter >= 10: - break - try: - _cmd(f'{container_base_cmd} --net {network} {ipparam} {image}') - break - except: - counter = counter +1 - sleep(0.5) + run(f'{container_base_cmd} --net {network} {ipparam} {image}') return None +def run(container_cmd): + counter = 0 + while True: + if counter >= 10: + break + try: + _cmd(container_cmd) + break + except: + counter = counter +1 + sleep(0.5) + + return None + + if __name__ == '__main__': try: c = get_config() |