mirror of
https://github.com/mcloh/decision-models-benchmark.git
synced 2026-11-05 22:04:12 +00:00
- Caminho do compartimento pai e CIDR do SSH saem do código para .secrets/oci-settings.json (fora do Git), com override por DMB_*. - Relatórios de sanidade deixam de gravar o hostname local. - tests/test_sensitive.py falha se OCIDs, chaves, IPs públicos ou valores de .secrets aparecerem em arquivos versionados. - tools/plan_progress.py gera o bloco de andamento por fase no plano. - Plano: status reais das tarefas de F0, F3 e F6; README e docs/05 com GPU em sa-saopaulo-1, runtime CUDA do Rizzo e pipeline sintético. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""Sessão OCI do benchmark a partir das credenciais em .secrets/oci-credentials/."""
|
|
import configparser
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import oci
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
CRED_DIR = ROOT / ".secrets" / "oci-credentials"
|
|
REGION = "us-chicago-1"
|
|
|
|
|
|
def settings() -> dict:
|
|
"""Configuração local fora do Git (.secrets/oci-settings.json); variáveis DMB_* têm precedência."""
|
|
path = CRED_DIR.parent / "oci-settings.json"
|
|
data = json.loads(path.read_text()) if path.is_file() else {}
|
|
return {
|
|
"parent_compartment_path": os.environ.get("DMB_PARENT_COMPARTMENT", data.get("parent_compartment_path")),
|
|
"ssh_allowed_cidr": os.environ.get("DMB_SSH_CIDR", data.get("ssh_allowed_cidr")),
|
|
}
|
|
|
|
|
|
def load_config(region: str = REGION, profile: str = "DEFAULT") -> dict:
|
|
parser = configparser.ConfigParser()
|
|
parser.read(CRED_DIR / "profile.config")
|
|
cfg = dict(parser[profile])
|
|
key_file = cfg.get("key_file", "").split("#")[0].strip()
|
|
if not key_file or not Path(key_file).expanduser().is_file():
|
|
keys = [p for p in CRED_DIR.glob("*.pem") if not p.name.endswith("_public.pem")]
|
|
if len(keys) != 1:
|
|
raise RuntimeError(f"esperada 1 chave privada em {CRED_DIR}, encontradas {len(keys)}")
|
|
key_file = str(keys[0])
|
|
cfg["key_file"] = key_file
|
|
cfg["region"] = region
|
|
oci.config.validate_config(cfg)
|
|
return cfg
|