Skip to content

Commit

Permalink
add systemd guard
Browse files Browse the repository at this point in the history
  • Loading branch information
zoumingzhe committed Sep 26, 2024
1 parent 5315344 commit 8b37bb6
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions casm/cmds/podman/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ..service import add_pos_services


@add_command("enable", help="Enable systemd for containers")
@add_command("enable", help="Enable systemd unit for containers")
def add_cmd_enable(_arg: argp):
_arg.add_argument("--restart-policy", dest="restart_policy",
type=str, nargs=1, metavar="STR", default=["on-failure"],
Expand All @@ -37,7 +37,7 @@ def run_cmd_enable(cmds: commands) -> int:
return 0


@add_command("disable", help="Disable systemd for containers")
@add_command("disable", help="Disable systemd unit for containers")
def add_cmd_disable(_arg: argp):
add_pos_services(_arg)

Expand All @@ -57,11 +57,28 @@ def run_cmd_disable(cmds: commands) -> int:
return 0


@add_command("guard", help="Guard systemd unit for containers")
def add_cmd_guard(_arg: argp):
add_pos_services(_arg)


@run_command(add_cmd_guard)
def run_cmd_guard(cmds: commands) -> int:
assemble: assemble_file = cmds.args.assemble_file
assert isinstance(assemble, assemble_file)
services: List[str] = cmds.args.services
for service in assemble.template.services:
cmds.logger.debug(f"{service.title}: {service.container_name}")
if len(services) > 0 and service.title not in services:
continue
return 0


@add_command("systemd", help="Manage systemd units")
def add_cmd_systemd(_arg: argp):
pass


@run_command(add_cmd_systemd, add_cmd_enable, add_cmd_disable)
@run_command(add_cmd_systemd, add_cmd_enable, add_cmd_disable, add_cmd_guard)
def run_cmd_systemd(cmds: commands) -> int:
return 0

0 comments on commit 8b37bb6

Please sign in to comment.