feat(slice-4): implement in-memory deduplication and conflict resolution engine
This commit is contained in:
1 parent
ca9163530f
commit
14a2032c42
5 files changed
+214
-8
No files matched your search
@@ -65,12 +65,13 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
|
||||
inv = InventoryData()
|
||||
|
||||
raw_records: List[HostRecord] = []
|
||||
|
||||
# Load from sources if specified
|
||||
if args.sources:
|
||||
for src in args.sources:
|
||||
collector = StaticFileCollector(src)
|
||||
for host in collector.collect():
|
||||
inv.add_host(host)
|
||||
raw_records.extend(collector.collect())
|
||||
|
||||
# Check for Proxmox environment variables
|
||||
import os
|
||||
@@ -89,12 +90,11 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
token_secret=pve_token_secret,
|
||||
verify_ssl=verify_ssl
|
||||
)
|
||||
for host in pve_collector.collect():
|
||||
inv.add_host(host)
|
||||
raw_records.extend(pve_collector.collect())
|
||||
|
||||
# Tracer bullet fallback if no hosts loaded
|
||||
if not inv.hosts:
|
||||
inv.add_host(HostRecord(
|
||||
if not raw_records:
|
||||
raw_records.append(HostRecord(
|
||||
name="k3s-master-0",
|
||||
ansible_host="192.168.5.70",
|
||||
ansible_user="lain",
|
||||
@@ -102,7 +102,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
tags=["control-plane", "proxmox"],
|
||||
source="tracer"
|
||||
))
|
||||
inv.add_host(HostRecord(
|
||||
raw_records.append(HostRecord(
|
||||
name="node0",
|
||||
ansible_host="192.168.0.101",
|
||||
ansible_user="root",
|
||||
@@ -111,6 +111,13 @@ def main(argv: Optional[List[str]] = None) -> int:
|
||||
source="tracer"
|
||||
))
|
||||
|
||||
from inventory_collector.engine import DeduplicationEngine
|
||||
engine = DeduplicationEngine()
|
||||
inv, warnings = engine.process(raw_records)
|
||||
|
||||
for w in warnings:
|
||||
sys.stderr.write(f"[WARN] {w}\n")
|
||||
|
||||
if args.dry_run:
|
||||
sys.stderr.write(f"[INFO] Discovered {len(inv.hosts)} hosts across {len(inv.groups)} groups.\n")
|
||||
print("NAME IP ADDRESS SOURCE GROUPS")
|
||||
|
||||
Reference in new issue
Block a user