Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains - Omit embedded publish git dirs and empty placeholders from index Made-with: Cursor
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -18,6 +19,11 @@ def _extract_ip_from_net_line(line: str) -> str | None:
|
||||
return m.group(1) if m else None
|
||||
|
||||
|
||||
def _extract_hwaddr_from_net_line(line: str) -> str | None:
|
||||
m = re.search(r"hwaddr=([0-9A-Fa-f:]+)", line, re.IGNORECASE)
|
||||
return m.group(1) if m else None
|
||||
|
||||
|
||||
def _read_config(path: str) -> str:
|
||||
try:
|
||||
with open(path, encoding="utf-8", errors="replace") as f:
|
||||
@@ -65,12 +71,16 @@ def main() -> None:
|
||||
|
||||
body = _read_config(cfg_path)
|
||||
ip = ""
|
||||
mac = ""
|
||||
for line in body.splitlines():
|
||||
if line.startswith("net0:"):
|
||||
got = _extract_ip_from_net_line(line)
|
||||
if got:
|
||||
ip = got
|
||||
break
|
||||
h = _extract_hwaddr_from_net_line(line)
|
||||
if h:
|
||||
mac = h
|
||||
break
|
||||
if not ip and t == "qemu":
|
||||
for line in body.splitlines():
|
||||
if line.startswith("ipconfig0:"):
|
||||
@@ -84,6 +94,11 @@ def main() -> None:
|
||||
got = _extract_ip_from_net_line(line)
|
||||
if got:
|
||||
ip = got
|
||||
if not mac:
|
||||
h = _extract_hwaddr_from_net_line(line)
|
||||
if h:
|
||||
mac = h
|
||||
if ip:
|
||||
break
|
||||
|
||||
guests.append(
|
||||
@@ -94,14 +109,40 @@ def main() -> None:
|
||||
"name": name,
|
||||
"status": status,
|
||||
"ip": ip,
|
||||
"mac": mac,
|
||||
"config_path": cfg_path,
|
||||
}
|
||||
)
|
||||
|
||||
out = {
|
||||
out: dict = {
|
||||
"collected_at": collected_at,
|
||||
"guests": sorted(guests, key=lambda g: int(g["vmid"])),
|
||||
}
|
||||
|
||||
if os.environ.get("IT_COLLECT_IP_NEIGH", "").strip().lower() in (
|
||||
"1",
|
||||
"yes",
|
||||
"true",
|
||||
):
|
||||
neigh_lines: list[str] = []
|
||||
try:
|
||||
raw_neigh = subprocess.check_output(
|
||||
["ip", "-4", "neigh", "show", "dev", "vmbr0"],
|
||||
text=True,
|
||||
stderr=subprocess.DEVNULL,
|
||||
timeout=30,
|
||||
)
|
||||
neigh_lines = [
|
||||
ln.strip() for ln in raw_neigh.splitlines() if ln.strip()
|
||||
][:500]
|
||||
except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError):
|
||||
neigh_lines = []
|
||||
out["ip_neigh_vmbr0_sample"] = {
|
||||
"collected_at": collected_at,
|
||||
"line_count": len(neigh_lines),
|
||||
"lines": neigh_lines,
|
||||
}
|
||||
|
||||
json.dump(out, sys.stdout, indent=2)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user