summaryrefslogtreecommitdiff
path: root/src/conf_mode/containers.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf_mode/containers.py')
-rwxr-xr-xsrc/conf_mode/containers.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/conf_mode/containers.py b/src/conf_mode/containers.py
index 32320a4b2..3a93bf062 100755
--- a/src/conf_mode/containers.py
+++ b/src/conf_mode/containers.py
@@ -19,6 +19,7 @@ import json
from ipaddress import ip_address
from ipaddress import ip_network
+from time import sleep
from vyos.config import Config
from vyos.configdict import dict_merge
@@ -28,6 +29,9 @@ from vyos.util import cmd
from vyos.util import run
from vyos.util import read_file
from vyos.util import write_file
+from vyos.util import is_systemd_service_active
+from vyos.util import is_systemd_service_running
+
from vyos.template import render
from vyos.template import is_ipv4
from vyos.template import is_ipv6
@@ -199,6 +203,18 @@ def apply(container):
for network in container['network_remove']:
call(f'podman network rm --force {network}')
+ service_name = 'podman.service'
+ if 'network' in container or 'name' in container:
+ # Start podman if it's required and not yet running
+ if not is_systemd_service_active(service_name):
+ _cmd(f'systemctl start {service_name}')
+ # Wait for podman to be running
+ while not is_systemd_service_running(service_name):
+ sleep(0.250)
+ else:
+ _cmd(f'systemctl stop {service_name}')
+
+
# Add network
if 'network' in container:
for network, network_config in container['network'].items():