prole/knoe/ops/components/opentofu.py
chrisfu 761d80486b feat: add storage probing and operational service updates
- add reusable storage probing subsystem with discovery, bounded probe execution, IO classification, caching, and topology integration

- render per-node storage inventory in Cluster Nodes UI and extend installer test coverage for topology/storage behavior

- introduce core service operation modules and align actions, milestones, services, and supporting configs/scripts for repair/update workflows

- update CNPG/Supabase/database artifacts, placement and port mapping configs, plus related integration tests

Co-authored-by: Junie <junie@jetbrains.com>
2026-03-26 09:44:23 -07:00

54 lines
1.2 KiB
Python

from __future__ import annotations
from ..context import KnoeContext
from knoe.core.ops import opentofu as opentofu_ops
def _namespace(ctx: KnoeContext) -> str:
return ctx.service_namespace or ctx.namespace
def _run(ctx: KnoeContext, action: str) -> int:
try:
fn = getattr(opentofu_ops, action)
fn(
namespace=_namespace(ctx),
env=ctx.env,
project_root=ctx.project_root,
mode=ctx.mode,
log=ctx.logger,
)
return 0
except Exception as e:
ctx.err_logger(f"[opentofu] {action} failed: {e}")
return 1
def initialize(ctx: KnoeContext):
return _run(ctx, "initialize")
def start(ctx: KnoeContext):
return _run(ctx, "start")
def update(ctx: KnoeContext):
return _run(ctx, "update")
def restart(ctx: KnoeContext):
return _run(ctx, "restart")
def stop(ctx: KnoeContext):
return _run(ctx, "stop")
def status(ctx: KnoeContext):
try:
ok = opentofu_ops.status(namespace=_namespace(ctx), env=ctx.env)
return 0 if ok else 1
except Exception as e:
ctx.err_logger(f"[opentofu] status failed: {e}")
return 1