Files
felhom.eu/documentation/audits/media-all-drives-2026-10-14/tools/enrol.py
T
admin 8395aee4c2
gates / gates (push) Successful in 7m46s
Media all drives, Parts A-C on Tester 1: S1-S3 proven (hardlink with one bind per drive; today's shape copies); R-1014..R-1019 filed
Two test drives enrolled through the dashboard; no test media in any backup tier (A6, three proofs); Tester 1 follows a
credential-free local mirror of the drill catalog (R-992 worked around a third way). The live-fix task may start.
2026-10-14 17:36:50 +02:00

37 lines
1.7 KiB
Python

#!/usr/bin/env python3
"""enrol.py <device> <mount_name> <label> — Part A4: enrol one blank disk on the Tester 1 box through the SAME calls
the „Új meghajtó inicializálása" wizard makes (storage_init.html): GET /api/disks/candidates, POST /api/storage/init,
then poll GET /api/storage/init/status to a terminal phase. set_default is sent FALSE (the wizard's checkbox is
checked by default — recorded in the report; this run keeps Tester 1's default drive unchanged).
Run from DooPlex: SC=~/.felhom-tester1 TARGET=tester-1 python3 enrol.py /dev/sdc media_a "Media A"
"""
import json, sys, time
sys.path.insert(0, "/mnt/5_hdd/felhom.eu/git/app-catalog-felhom.eu/scripts")
import box_walk as w
dev, name, label = sys.argv[1], sys.argv[2], sys.argv[3]
w.login()
c, d = w.ctl("GET", "/api/disks/candidates")
cands = [x["device"] for x in ((d.get("data") or {}).get("initialize") or [])]
w.say(f"candidates -> {c} {cands}")
if dev not in cands:
sys.exit(w.say(f"STOP: {dev} is not offered for initialisation") or 1)
body = {"device": dev, "fstype": "ext4", "mount_name": name, "label": label,
"set_default": False, "confirmed": False, "durable_id": ""}
c, d = w.ctl("POST", "/api/storage/init", body)
w.say(f"POST /api/storage/init {json.dumps(body)} -> {c} {json.dumps(d, ensure_ascii=False)}")
if c != "200":
sys.exit(1)
last = None
for _ in range(600):
time.sleep(2)
c, d = w.ctl("GET", "/api/storage/init/status")
ph = (d.get("data") or {}).get("phase")
if ph != last:
w.say(f"status -> {c} {json.dumps(d.get('data'), ensure_ascii=False)}")
last = ph
if ph in ("done", "failed", "refused", "needs_confirmation"):
break
print("RESULT", last)