fix: wordpress_client init() — CT 101 korrekt finden

- Filter auf vmid==101 UND host=='pve-hetzner' (eindeutig)
- Passwort aus PW_WP_ADMIN in cfg.raw
- check_connectivity() prüft WP_URL/WP_PASSWORD vor Request

Made-with: Cursor
This commit is contained in:
root 2026-03-09 13:13:08 +07:00
parent 7060618a59
commit 4428730807

View file

@ -16,23 +16,24 @@ def init(cfg):
ct_101 = None ct_101 = None
for c in cfg.containers: for c in cfg.containers:
if c.vmid == 101: if c.vmid == 101 and c.host == "pve-hetzner":
ct_101 = c ct_101 = c
break break
if not ct_101: if not ct_101 or not ct_101.tailscale_ip:
return False return False
# WordPress erreichbar über Tailscale IP oder Domain # WordPress erreichbar über Tailscale IP
WP_URL = f"http://{ct_101.tailscale_ip}" WP_URL = f"http://{ct_101.tailscale_ip}"
WP_USER = "admin" WP_USER = "admin"
WP_PASSWORD = cfg.passwords.get("wordpress_admin", "")
if not WP_PASSWORD: # Passwort aus config
# Fallback: aus raw config pw = cfg.raw.get("PW_WP_ADMIN", "")
WP_PASSWORD = cfg.raw.get("PW_WP_ADMIN", "") if pw:
WP_PASSWORD = pw
return True
return bool(WP_PASSWORD) return False
def _request(endpoint: str, method: str = "GET", params: dict = None) -> Optional[dict]: def _request(endpoint: str, method: str = "GET", params: dict = None) -> Optional[dict]:
@ -56,6 +57,8 @@ def _request(endpoint: str, method: str = "GET", params: dict = None) -> Optiona
def check_connectivity() -> bool: def check_connectivity() -> bool:
"""Ist WordPress erreichbar?""" """Ist WordPress erreichbar?"""
try: try:
if not WP_URL or not WP_PASSWORD:
return False
result = _request("/posts?per_page=1") result = _request("/posts?per_page=1")
return result is not None return result is not None
except: except: