fix(reboot): add windows99 vmx source locator
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m11s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 2m11s
CD Pipeline / post-deploy-checks (push) Has been cancelled
CD Pipeline / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -2984,6 +2984,9 @@ def _enrich_from_current_readbacks(
|
||||
apply_gitea_repo_bundle_backup_readback,
|
||||
load_latest_reboot_auto_recovery_slo_scorecard,
|
||||
)
|
||||
from src.services.windows99_vmx_source_locator_readback import (
|
||||
build_windows99_vmx_source_locator_readback,
|
||||
)
|
||||
from src.services.windows99_vmx_source_repair_package import (
|
||||
build_windows99_vmx_source_repair_package,
|
||||
)
|
||||
@@ -3029,6 +3032,12 @@ def _enrich_from_current_readbacks(
|
||||
windows99_vmx_source_repair_package = (
|
||||
build_windows99_vmx_source_repair_package(reboot_slo)
|
||||
)
|
||||
windows99_vmx_source_locator_readback = (
|
||||
build_windows99_vmx_source_locator_readback(
|
||||
reboot_slo,
|
||||
repair_package=windows99_vmx_source_repair_package,
|
||||
)
|
||||
)
|
||||
windows99_vmx_source_repair_action_chain = _dict(
|
||||
windows99_vmx_source_repair_package.get("action_chain")
|
||||
)
|
||||
@@ -3417,6 +3426,51 @@ def _enrich_from_current_readbacks(
|
||||
)
|
||||
or ""
|
||||
)
|
||||
state["windows99_vmx_source_locator_status"] = str(
|
||||
windows99_vmx_source_locator_readback.get("status") or "unknown"
|
||||
)
|
||||
state["windows99_vmx_source_locator_required"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("source_locator_required") is True
|
||||
)
|
||||
state["windows99_vmx_source_locator_check_mode_ready"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("locator_check_mode_ready") is True
|
||||
)
|
||||
state["windows99_vmx_source_locator_target_aliases"] = _strings(
|
||||
windows99_vmx_source_locator_readback.get("target_vm_aliases")
|
||||
)
|
||||
state["windows99_vmx_source_locator_next_executable_step"] = str(
|
||||
windows99_vmx_source_locator_readback.get("next_executable_step") or ""
|
||||
)
|
||||
state["windows99_vmx_source_locator_expected_vmx_path_count"] = _int(
|
||||
windows99_vmx_source_locator_readback.get("expected_vmx_path_count")
|
||||
)
|
||||
state["windows99_vmx_source_locator_candidate_source_count_known"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("candidate_source_count_known")
|
||||
is True
|
||||
)
|
||||
state["windows99_vmx_source_locator_collector_readback_present"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("collector_readback_present")
|
||||
is True
|
||||
)
|
||||
state["windows99_vmx_source_locator_collector_collection_status"] = str(
|
||||
windows99_vmx_source_locator_readback.get("collector_collection_status")
|
||||
or "unknown"
|
||||
)
|
||||
state["windows99_vmx_source_locator_raw_path_output"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("raw_path_output") is True
|
||||
)
|
||||
state["windows99_vmx_source_locator_path_fingerprint_only"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("path_fingerprint_only") is True
|
||||
)
|
||||
state["windows99_vmx_source_locator_file_content_read"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("file_content_read") is True
|
||||
)
|
||||
state["windows99_vmx_source_locator_remote_write_performed"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("remote_write_performed") is True
|
||||
)
|
||||
state["windows99_vmx_source_locator_vm_power_change_performed"] = bool(
|
||||
windows99_vmx_source_locator_readback.get("vm_power_change_performed") is True
|
||||
)
|
||||
state["stale_snapshot_or_old_cd_runs_must_not_reopen_closed_work"] = True
|
||||
state["p0_004_template_copy_apply_gate_production_http_status"] = 200
|
||||
state["p0_004_template_copy_apply_gate_runtime_readback_state"] = (
|
||||
@@ -3759,6 +3813,48 @@ def _enrich_from_current_readbacks(
|
||||
evidence["windows99_vmx_source_repair_playbook_trust_writeback_ref"] = (
|
||||
state["windows99_vmx_source_repair_playbook_trust_writeback_ref"]
|
||||
)
|
||||
evidence["windows99_vmx_source_locator_status"] = state[
|
||||
"windows99_vmx_source_locator_status"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_required"] = state[
|
||||
"windows99_vmx_source_locator_required"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_check_mode_ready"] = state[
|
||||
"windows99_vmx_source_locator_check_mode_ready"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_target_aliases"] = state[
|
||||
"windows99_vmx_source_locator_target_aliases"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_next_executable_step"] = state[
|
||||
"windows99_vmx_source_locator_next_executable_step"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_expected_vmx_path_count"] = state[
|
||||
"windows99_vmx_source_locator_expected_vmx_path_count"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_candidate_source_count_known"] = state[
|
||||
"windows99_vmx_source_locator_candidate_source_count_known"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_collector_readback_present"] = state[
|
||||
"windows99_vmx_source_locator_collector_readback_present"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_collector_collection_status"] = state[
|
||||
"windows99_vmx_source_locator_collector_collection_status"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_raw_path_output"] = state[
|
||||
"windows99_vmx_source_locator_raw_path_output"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_path_fingerprint_only"] = state[
|
||||
"windows99_vmx_source_locator_path_fingerprint_only"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_file_content_read"] = state[
|
||||
"windows99_vmx_source_locator_file_content_read"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_remote_write_performed"] = state[
|
||||
"windows99_vmx_source_locator_remote_write_performed"
|
||||
]
|
||||
evidence["windows99_vmx_source_locator_vm_power_change_performed"] = state[
|
||||
"windows99_vmx_source_locator_vm_power_change_performed"
|
||||
]
|
||||
evidence["drill_preflight_status"] = str(reboot_preflight.get("status") or "")
|
||||
evidence["drill_preflight_ready"] = (
|
||||
reboot_preflight_rollups.get("preflight_ready") is True
|
||||
@@ -4479,6 +4575,52 @@ def _set_rollups_and_summary(
|
||||
state.get("windows99_vmx_source_repair_playbook_trust_writeback_ref")
|
||||
or ""
|
||||
),
|
||||
"windows99_vmx_source_locator_status": str(
|
||||
state.get("windows99_vmx_source_locator_status") or "unknown"
|
||||
),
|
||||
"windows99_vmx_source_locator_required": (
|
||||
state.get("windows99_vmx_source_locator_required") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_check_mode_ready": (
|
||||
state.get("windows99_vmx_source_locator_check_mode_ready") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_target_aliases": _strings(
|
||||
state.get("windows99_vmx_source_locator_target_aliases")
|
||||
),
|
||||
"windows99_vmx_source_locator_next_executable_step": str(
|
||||
state.get("windows99_vmx_source_locator_next_executable_step") or ""
|
||||
),
|
||||
"windows99_vmx_source_locator_expected_vmx_path_count": _int(
|
||||
state.get("windows99_vmx_source_locator_expected_vmx_path_count")
|
||||
),
|
||||
"windows99_vmx_source_locator_candidate_source_count_known": (
|
||||
state.get("windows99_vmx_source_locator_candidate_source_count_known")
|
||||
is True
|
||||
),
|
||||
"windows99_vmx_source_locator_collector_readback_present": (
|
||||
state.get("windows99_vmx_source_locator_collector_readback_present")
|
||||
is True
|
||||
),
|
||||
"windows99_vmx_source_locator_collector_collection_status": str(
|
||||
state.get("windows99_vmx_source_locator_collector_collection_status")
|
||||
or "unknown"
|
||||
),
|
||||
"windows99_vmx_source_locator_raw_path_output": (
|
||||
state.get("windows99_vmx_source_locator_raw_path_output") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_path_fingerprint_only": (
|
||||
state.get("windows99_vmx_source_locator_path_fingerprint_only") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_file_content_read": (
|
||||
state.get("windows99_vmx_source_locator_file_content_read") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_remote_write_performed": (
|
||||
state.get("windows99_vmx_source_locator_remote_write_performed") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_vm_power_change_performed": (
|
||||
state.get("windows99_vmx_source_locator_vm_power_change_performed")
|
||||
is True
|
||||
),
|
||||
"p0_004_runtime_readback_ready": p0_004_ready,
|
||||
"reboot_drill_preflight_runtime_readback_ready": (
|
||||
state.get("reboot_drill_preflight_runtime_readback_state") == "ready"
|
||||
@@ -4725,6 +4867,52 @@ def _set_rollups_and_summary(
|
||||
state.get("windows99_vmx_source_repair_playbook_trust_writeback_ref")
|
||||
or ""
|
||||
),
|
||||
"windows99_vmx_source_locator_status": str(
|
||||
state.get("windows99_vmx_source_locator_status") or "unknown"
|
||||
),
|
||||
"windows99_vmx_source_locator_required": (
|
||||
state.get("windows99_vmx_source_locator_required") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_check_mode_ready": (
|
||||
state.get("windows99_vmx_source_locator_check_mode_ready") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_target_aliases": _strings(
|
||||
state.get("windows99_vmx_source_locator_target_aliases")
|
||||
),
|
||||
"windows99_vmx_source_locator_next_executable_step": str(
|
||||
state.get("windows99_vmx_source_locator_next_executable_step") or ""
|
||||
),
|
||||
"windows99_vmx_source_locator_expected_vmx_path_count": _int(
|
||||
state.get("windows99_vmx_source_locator_expected_vmx_path_count")
|
||||
),
|
||||
"windows99_vmx_source_locator_candidate_source_count_known": (
|
||||
state.get("windows99_vmx_source_locator_candidate_source_count_known")
|
||||
is True
|
||||
),
|
||||
"windows99_vmx_source_locator_collector_readback_present": (
|
||||
state.get("windows99_vmx_source_locator_collector_readback_present")
|
||||
is True
|
||||
),
|
||||
"windows99_vmx_source_locator_collector_collection_status": str(
|
||||
state.get("windows99_vmx_source_locator_collector_collection_status")
|
||||
or "unknown"
|
||||
),
|
||||
"windows99_vmx_source_locator_raw_path_output": (
|
||||
state.get("windows99_vmx_source_locator_raw_path_output") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_path_fingerprint_only": (
|
||||
state.get("windows99_vmx_source_locator_path_fingerprint_only") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_file_content_read": (
|
||||
state.get("windows99_vmx_source_locator_file_content_read") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_remote_write_performed": (
|
||||
state.get("windows99_vmx_source_locator_remote_write_performed") is True
|
||||
),
|
||||
"windows99_vmx_source_locator_vm_power_change_performed": (
|
||||
state.get("windows99_vmx_source_locator_vm_power_change_performed")
|
||||
is True
|
||||
),
|
||||
"windows99_winrm_http_open": (
|
||||
state.get("windows99_winrm_http_open") is True
|
||||
),
|
||||
|
||||
178
apps/api/src/services/windows99_vmx_source_locator_readback.py
Normal file
178
apps/api/src/services/windows99_vmx_source_locator_readback.py
Normal file
@@ -0,0 +1,178 @@
|
||||
"""Windows99 VMX source locator readback.
|
||||
|
||||
Builds the API-facing readback for the no-secret Windows99 VMX source locator.
|
||||
The service only projects the current repair package into an executable
|
||||
check-mode contract; it does not SSH, read VMX contents, write Windows state,
|
||||
start VMs, stop VMs, restart services, or reboot hosts.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from src.services.reboot_auto_recovery_slo_scorecard import (
|
||||
_taipei_now_iso,
|
||||
load_latest_reboot_auto_recovery_slo_scorecard,
|
||||
)
|
||||
from src.services.windows99_vmx_source_repair_package import (
|
||||
build_windows99_vmx_source_repair_package,
|
||||
)
|
||||
|
||||
_SCHEMA_VERSION = "windows99_vmx_source_locator_readback_v1"
|
||||
_COLLECTOR_SCHEMA_VERSION = "windows99_vmx_source_locator_collector_v1"
|
||||
_LOCATOR_SCHEMA_VERSION = "windows99_vmx_source_locator_v1"
|
||||
_COLLECTOR_SCRIPT_PATH = "scripts/reboot-recovery/locate-windows99-vmx-source.sh"
|
||||
_LOCATOR_SCRIPT_PATH = "scripts/reboot-recovery/windows99-vmx-source-locator.ps1"
|
||||
|
||||
|
||||
def _dict(value: Any) -> dict[str, Any]:
|
||||
return value if isinstance(value, dict) else {}
|
||||
|
||||
|
||||
def _strings(value: Any) -> list[str]:
|
||||
if isinstance(value, list):
|
||||
return [str(item).strip() for item in value if str(item).strip()]
|
||||
if isinstance(value, str):
|
||||
return [part.strip() for part in value.split(",") if part.strip()]
|
||||
return []
|
||||
|
||||
|
||||
def _bool(value: Any) -> bool:
|
||||
return value is True
|
||||
|
||||
|
||||
def _vm_rows_for_aliases(
|
||||
repair_package: dict[str, Any],
|
||||
target_aliases: list[str],
|
||||
) -> list[dict[str, Any]]:
|
||||
targets = set(target_aliases)
|
||||
rows: list[dict[str, Any]] = []
|
||||
for row in repair_package.get("vm_rows") or []:
|
||||
if not isinstance(row, dict):
|
||||
continue
|
||||
alias = str(row.get("alias") or "")
|
||||
if alias in targets:
|
||||
rows.append(row)
|
||||
return rows
|
||||
|
||||
|
||||
def build_windows99_vmx_source_locator_readback(
|
||||
scorecard: dict[str, Any],
|
||||
*,
|
||||
repair_package: dict[str, Any] | None = None,
|
||||
generated_at: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
package = repair_package or build_windows99_vmx_source_repair_package(scorecard)
|
||||
missing_aliases = _strings(package.get("missing_vmx_aliases"))
|
||||
target_aliases = missing_aliases or _strings(package.get("powered_off_aliases"))
|
||||
target_rows = _vm_rows_for_aliases(package, missing_aliases)
|
||||
expected_vmx_path_count = sum(
|
||||
len(row.get("expected_vmx_candidates") or []) for row in target_rows
|
||||
)
|
||||
source_locator_required = bool(missing_aliases)
|
||||
locator_check_mode_ready = bool(
|
||||
source_locator_required
|
||||
and package.get("package_ready") is True
|
||||
and package.get("check_mode_allowed_by_this_package") is True
|
||||
)
|
||||
if locator_check_mode_ready:
|
||||
status = "check_mode_locator_ready_windows99_vmx_source_required"
|
||||
next_step = "run_no_secret_windows99_vmx_source_locator_collect"
|
||||
safe_next_step = (
|
||||
"bash scripts/reboot-recovery/locate-windows99-vmx-source.sh "
|
||||
"--collect"
|
||||
)
|
||||
elif source_locator_required:
|
||||
status = "blocked_locator_package_not_ready"
|
||||
next_step = "repair_package_first"
|
||||
safe_next_step = "rebuild_windows99_vmx_source_repair_package"
|
||||
else:
|
||||
status = "ready_no_windows99_vmx_source_locator_required"
|
||||
next_step = "rerun_no_secret_vmware_verify_collector"
|
||||
safe_next_step = (
|
||||
"bash scripts/reboot-recovery/collect-windows99-vmware-verify.sh "
|
||||
"--collect"
|
||||
)
|
||||
|
||||
return {
|
||||
"schema_version": _SCHEMA_VERSION,
|
||||
"generated_at": generated_at
|
||||
or str(scorecard.get("generated_at") or _taipei_now_iso()),
|
||||
"status": status,
|
||||
"target_host_alias": "99",
|
||||
"target_vm_aliases": target_aliases,
|
||||
"missing_vmx_aliases": missing_aliases,
|
||||
"source_locator_required": source_locator_required,
|
||||
"locator_check_mode_ready": locator_check_mode_ready,
|
||||
"next_executable_step": next_step,
|
||||
"safe_next_step": safe_next_step,
|
||||
"collector_script_path": _COLLECTOR_SCRIPT_PATH,
|
||||
"locator_script_path": _LOCATOR_SCRIPT_PATH,
|
||||
"collector_schema_version": _COLLECTOR_SCHEMA_VERSION,
|
||||
"locator_schema_version": _LOCATOR_SCHEMA_VERSION,
|
||||
"collector_readback_present": False,
|
||||
"collector_collection_status": "not_collected_by_api_readback",
|
||||
"remote_locator_mode": "in_memory_stdin_scriptblock",
|
||||
"expected_vmx_path_count": expected_vmx_path_count,
|
||||
"expected_vmx_path_present_count": None,
|
||||
"candidate_source_count": None,
|
||||
"candidate_source_count_known": False,
|
||||
"candidate_source_fingerprint_count": None,
|
||||
"public_lan_topology_redacted": True,
|
||||
"redacted_public_display_only": True,
|
||||
"raw_path_output": False,
|
||||
"path_fingerprint_only": True,
|
||||
"file_content_read": False,
|
||||
"secret_value_read": False,
|
||||
"password_prompt_allowed": False,
|
||||
"remote_write_performed": False,
|
||||
"host_reboot_performed": False,
|
||||
"vm_power_change_performed": False,
|
||||
"windows_registry_apply_performed": False,
|
||||
"scheduled_task_write_performed": False,
|
||||
"apply_allowed_by_this_readback": False,
|
||||
"vm_power_change_allowed": False,
|
||||
"destructive_restore_allowed": False,
|
||||
"operation_boundaries": {
|
||||
"secret_value_read": False,
|
||||
"password_prompt_allowed": False,
|
||||
"file_content_read": False,
|
||||
"raw_path_output": False,
|
||||
"remote_write_performed": False,
|
||||
"host_reboot_performed": False,
|
||||
"vm_power_change_performed": False,
|
||||
"windows_registry_apply_performed": False,
|
||||
"scheduled_task_write_performed": False,
|
||||
},
|
||||
"check_mode": {
|
||||
"allowed": locator_check_mode_ready,
|
||||
"path_existence_only": True,
|
||||
"vmx_file_content_read": False,
|
||||
"raw_path_output": False,
|
||||
"path_fingerprint_only": True,
|
||||
"collector_command": safe_next_step if locator_check_mode_ready else "",
|
||||
},
|
||||
"target_selector": {
|
||||
"host_alias": "99",
|
||||
"vm_aliases": target_aliases,
|
||||
"missing_vmx_aliases": missing_aliases,
|
||||
"source_scope": "expected_vmx_paths_and_alias_named_vmx_candidates",
|
||||
"secret_collection_allowed": False,
|
||||
"vm_power_change_allowed": False,
|
||||
"destructive_restore_allowed": False,
|
||||
},
|
||||
"post_locator_verifier": [
|
||||
"bash scripts/reboot-recovery/collect-windows99-vmware-verify.sh --collect",
|
||||
"GET /api/v1/agents/reboot-auto-recovery-slo-scorecard",
|
||||
"GET /api/v1/agents/windows99-vmx-source-repair-package",
|
||||
"GET /api/v1/agents/windows99-vmx-source-locator-readback",
|
||||
],
|
||||
"source_repair_package_ready": _bool(package.get("package_ready")),
|
||||
"source_repair_work_order_id": str(package.get("work_order_id") or ""),
|
||||
"source_repair_action_stage": str(package.get("action_stage") or ""),
|
||||
}
|
||||
|
||||
|
||||
def load_latest_windows99_vmx_source_locator_readback() -> dict[str, Any]:
|
||||
scorecard = load_latest_reboot_auto_recovery_slo_scorecard()
|
||||
return build_windows99_vmx_source_locator_readback(scorecard)
|
||||
Reference in New Issue
Block a user