Lab7: HTTPS, mTLS, OpenBao, трек 2 PKI на оценку 5
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
Wladislava1
2026-11-17 00:25:48 +03:00
parent 20afc2c790
commit 54dcf70ea6
88 changed files with 8930 additions and 58 deletions
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
"""Остановить одну API-реплику по TARGET_INSTANCE_ID (hostname контейнера)."""
from __future__ import annotations
import os
import subprocess
import sys
def main() -> int:
target = os.environ.get("TARGET_INSTANCE_ID", "").strip()
if not target:
print("TARGET_INSTANCE_ID required", file=sys.stderr)
return 1
out = subprocess.check_output(
[
"docker",
"ps",
"-q",
"--filter",
"label=com.docker.compose.project=mtusi-lab7",
"--filter",
"label=com.docker.compose.service=api",
],
text=True,
)
found = None
for line in out.splitlines():
cid = line.strip()
if not cid:
continue
host = subprocess.check_output(["docker", "inspect", "-f", "{{.Config.Hostname}}", cid], text=True).strip()
short = cid[:12]
if host == target or short == target:
found = cid
break
if not found:
print("api replica not found", file=sys.stderr)
return 1
subprocess.check_call(["docker", "stop", "--time", "5", found], stdout=subprocess.DEVNULL)
return 0
if __name__ == "__main__":
raise SystemExit(main())