Commit graph

8 commits

Author SHA1 Message Date
26db771279 ha-sync: add internal/kube package with CronJob/Lease management
- internal/kube/client.go: NewClient() with in-cluster + kubeconfig fallback
- internal/kube/cronjob.go: JobSpec, ApplyCronJob, DeleteCronJob, TriggerJob,
  GetLockStatus, SuspendCronJob, ListCronJobs, ImportFromCronJob
- Makefile/Dockerfile: add ha-sync-ctl build target
- rbac.yaml: add batch/cronjobs+jobs permissions and watch verb on leases

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-08 23:38:32 +02:00
29440b68a9 fix: sudo dmidecode fallback when running without root
Without root, dmidecode exits 0 but outputs only a header comment
with no Handle blocks (DMI tables are root-only in sysfs).
The previous empty-string check never triggered the sudo retry.

Now checks for the presence of 'Handle ' lines: if absent, retries
transparently with sudo. Users with passwordless sudo get full hardware
detail (CPU slots, memory sticks/slots, cache, voltage) without needing
to explicitly invoke sudo themselves.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-06 23:45:35 +02:00
69113c1ea7 feat: richer hardware discovery — CPU cache/voltage, memory type/bandwidth/part-no, GPU discovery
- CPU: max speed, bus MHz, L1/L2/L3 cache (from sysfs), voltage, socket type; /proc/cpuinfo fallback for non-root
- Memory sticks: DDR type, form factor, part number, rank, data width, theoretical bandwidth
- GPU: new part type discovered via lspci + /sys/class/drm + nvidia-smi; shows VRAM and display outputs
- discover-only tree updated to show all new fields

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 01:20:33 +02:00
bf7a7937e0 feat(inventory-cli): build script, manpage help, discover-only command
build-cli.sh
  Simple shell script that builds inventory-cli inside Docker and
  extracts the binary to build/ (or a custom path).  Replaces the
  need to use the heavier build-and-load.sh just to compile the CLI.

--help
  Replaced the terse usage() stub with a full UNIX man-page style
  reference covering NAME, SYNOPSIS, DESCRIPTION, GLOBAL OPTIONS,
  COMMANDS (grouped by area), PART TYPES, FIELD KEYS, EXAMPLES,
  and NOTES.

discover-only [--type <type>]
  New command that runs local hardware discovery without contacting
  the inventory server and prints results as an ASCII tree rooted at
  the hostname.  Each section (CPUs, CPU Slots, Memory Sticks, Memory
  Slots, Disks, NICs) lists discovered components with key attributes
  inline.  Useful for inspection and troubleshooting.

discovery.cpp: store interface name in K_NAME for NICs
  ifname (e.g. "nic0", "eno1") is now emitted so discover-only and
  the server-side UI can display the kernel device name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-01 00:49:17 +02:00
7a8ea3e88f fix: correct CPU and memory slot deduplication on HP ProLiant
- discovery.cpp: remove K_SERIAL emission from dmidecode CPU "ID" field
  (it is the CPUID instruction result, identical across matching processors
  in a multi-socket system, not a unique per-slot serial number)
  → upsert_part now falls through to K_SOCKET natural key, correctly
    inserting both "Proc 1" and "Proc 2" as separate records

- discovery.cpp: skip memory slot blocks with missing or empty Locator
  (HP ProLiant firmware returns a phantom type-17 block with no Locator;
  this was causing a 19th slot record to be inserted with empty locator
  that could never be deduplicated on subsequent runs)

Verified on HP ProLiant DL360 G7:
  cpu=2, cpu_slots=2, memory_sticks=12, memory_slots=18, disks=5, nics=4

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 22:50:33 +02:00
a110afa40b feat(device-inventory): add management web UI and pciutils for NIC discovery
- web-ui/main.go: full CRUD REST API + dark-theme SPA (servers, parts, part-types)
- Dockerfile.cli: add pciutils runtime dep for lspci NIC enrichment

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 22:42:20 +02:00
6e1e4b4134 feat(device-inventory): hardware discovery pipeline natural key deduplication
- protocol.h: add K_LOCATOR, K_SOCKET, K_DEVICE_NAME natural key constants
- models.h: add locator/socket_designation/device_name fields to structs
- database.cpp: apply_*, serialize_*, save_nolock, load all updated;
  upsert_part gains natural key fallback for memory/cpu/disk
- discovery.cpp: emit K_LOCATOR for memory sticks/slots; fix CPU filter
  to skip phantom iLO entries; emit K_SOCKET for cpu/cpu_slot;
  emit K_DEVICE_NAME for disks with serial collision fix; replace NIC
  blocklist with /sys/class/net/<if>/device symlink check + lspci enrichment

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-31 22:37:17 +02:00
e1a482c500 feat(device-inventory): add hooks system and DNS updater hook
- Add Hook interface (filter + execute contract) in server/hooks/hook.h
- Add HookRunner in server/hooks/hook_runner.h: spawns a detached thread
  per matching hook, with try/catch protection against crashes
- Add DnsUpdaterHook in server/hooks/dns_updater_hook.{h,cpp}:
  triggers on server name changes, logs in to Technitium, deletes the
  old A record (ignores 404), and adds the new A record
  Config via env vars: TECHNITIUM_HOST/PORT/USER/PASS/ZONE, DNS_TTL
- Add Database::get_nics_for_server() to resolve a server's IPv4 address
- Wire HookRunner into InventoryServer; cmd_edit_server now fires hooks
  with before/after Server snapshots
- Update CMakeLists.txt to include dns_updater_hook.cpp
- Document env vars in Dockerfile

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-24 14:58:36 +01:00