diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-08-02 17:05:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-02 17:05:55 +0200 |
commit | 89890f5b07a3d59eefe5ce210a20715068c10e0e (patch) | |
tree | 77f2632c5b4b2d0ec5aeff8a814e4c6136875ab2 | |
parent | b72a7dc0fd33f1f0bca9016ed4d70effc55bfd75 (diff) | |
parent | 08cb762347208b21a8cbf81f7b35707d7e6dd4ac (diff) | |
download | vyos-1x-89890f5b07a3d59eefe5ce210a20715068c10e0e.tar.gz vyos-1x-89890f5b07a3d59eefe5ce210a20715068c10e0e.zip |
Merge pull request #1456 from sever-sever/T4585
containers: T4585: Add option restart to containers.py
-rw-r--r-- | op-mode-definitions/container.xml.in | 2 | ||||
-rwxr-xr-x | src/op_mode/container.py | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/op-mode-definitions/container.xml.in b/op-mode-definitions/container.xml.in index 90bbc6889..a7048e5ed 100644 --- a/op-mode-definitions/container.xml.in +++ b/op-mode-definitions/container.xml.in @@ -149,7 +149,7 @@ <path>container name</path> </completionHelp> </properties> - <command>sudo podman restart "$3"</command> + <command>sudo ${vyos_op_scripts_dir}/container.py restart name="$3"</command> </tagNode> </children> </node> diff --git a/src/op_mode/container.py b/src/op_mode/container.py index 02d4a13b7..78d42f800 100755 --- a/src/op_mode/container.py +++ b/src/op_mode/container.py @@ -64,6 +64,17 @@ def show_network(raw: bool): return cmd(command) +def restart(name: str): + from vyos.util import rc_cmd + + rc, output = rc_cmd(f'sudo podman restart {name}') + if rc != 0: + print(output) + return None + print(f'Container name "{name}" restarted!') + return output + + if __name__ == '__main__': try: res = vyos.opmode.run(sys.modules[__name__]) |