feat: get_clusters() for the whole cluster, node= refused for another node #39

Merged
christianmanivong merged 2 commits from feat/cluster-inventory into main 2026-11-01 19:06:53 +00:00
Owner

Summary

Implements get_clusters() from napalm-device-types for Proxmox VE, and the node keyword of create_vm_from_cloud_init() (NetOrk/netork#1820).

Changes

  • cluster_mixin.py: one cluster per answer: name and quorum from /cluster/status; every member, offline ones as offline without capacity values; threads, CPU usage and memory from /cluster/resources; cores, model and flags from each online node's /nodes/{n}/status; maintenance from the HA manager where readable (else None); storages grouped by name with the nodes they are available on (shared: one node's size, local: summed); bridges per node merged by name (vlan_aware only if on all), vnets on their zone's nodes. A standalone node is a cluster of one. Another node that does not answer loses its CPU fields and bridges with a warning; the own node, /cluster/status and /cluster/resources raise.
  • network_targets.py: the bridge part of get_network_targets(), shared; unchanged output.
  • create_vm_from_cloud_init(node=): any node but its own is refused before anything is created (netOrk creates through the target node's own device).
  • CHANGELOG entry; quality baseline tightened (complexity 26 → 25).

Related Issue

NetOrk/netork#484, NetOrk/netork#1822. Needs NAPALM/napalm-device-types feat/cluster-inventory merged first (the cluster types are imported for type checking only; the floor in pyproject.toml rises with the release that ships them).

Testing

tests/test_clusters.py (26 new): 3-node cluster with an offline node, standalone, storage grouping, bridge merge, vnet zones, HA failing/reporting maintenance, resources failing raises, node refused. Full suite 387 passed, ruff, mypy, ratchet clean.

## Summary Implements `get_clusters()` from napalm-device-types for Proxmox VE, and the `node` keyword of `create_vm_from_cloud_init()` (NetOrk/netork#1820). ## Changes - `cluster_mixin.py`: one cluster per answer: name and quorum from `/cluster/status`; every member, offline ones as `offline` without capacity values; threads, CPU usage and memory from `/cluster/resources`; cores, model and flags from each online node's `/nodes/{n}/status`; maintenance from the HA manager where readable (else None); storages grouped by name with the nodes they are `available` on (shared: one node's size, local: summed); bridges per node merged by name (`vlan_aware` only if on all), vnets on their zone's nodes. A standalone node is a cluster of one. Another node that does not answer loses its CPU fields and bridges with a warning; the own node, `/cluster/status` and `/cluster/resources` raise. - `network_targets.py`: the bridge part of `get_network_targets()`, shared; unchanged output. - `create_vm_from_cloud_init(node=)`: any node but its own is refused before anything is created (netOrk creates through the target node's own device). - CHANGELOG entry; quality baseline tightened (complexity 26 → 25). ## Related Issue NetOrk/netork#484, NetOrk/netork#1822. Needs NAPALM/napalm-device-types `feat/cluster-inventory` merged first (the cluster types are imported for type checking only; the floor in pyproject.toml rises with the release that ships them). ## Testing `tests/test_clusters.py` (26 new): 3-node cluster with an offline node, standalone, storage grouping, bridge merge, vnet zones, HA failing/reporting maintenance, resources failing raises, node refused. Full suite 387 passed, ruff, mypy, ratchet clean.
christianmanivong added 1 commit 2026-11-01 15:39:12 +00:00
feat: get_clusters() for the whole cluster, node= refused for another node
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 13s
driver / types (pull_request) Failing after 1m2s
driver / test (3.12) (pull_request) Successful in 1m9s
driver / test (3.13) (pull_request) Successful in 57s
driver / lowest (pull_request) Successful in 31s
driver / build (pull_request) Successful in 28s
driver / security (pull_request) Successful in 1m3s
CI / driver (pull_request) Failing after 2m42s
driver / publish (pull_request) Skipped
f60532e434
Every PVE node can read its whole cluster, so get_clusters() reports the
one it belongs to: name and quorum from /cluster/status, every member
(offline ones as offline, without capacity), CPU and memory from
/cluster/resources and each online node's cpuinfo, maintenance from the
HA manager where it can be read, storages grouped by name with the nodes
they are available on, and bridges and vnets with the nodes that carry
them. A standalone node is a cluster of one.

The bridge part of get_network_targets() moved to network_targets.py so
both use it. create_vm_from_cloud_init() takes node= and refuses any node
but its own before creating anything.

Refs NetOrk/netork#484, NetOrk/netork#1822
christianmanivong added 1 commit 2026-11-01 16:08:11 +00:00
refactor: import the cluster shapes from the package root
driver / standard (pull_request) Successful in 19s
driver / lint (pull_request) Successful in 14s
driver / types (pull_request) Successful in 1m10s
driver / test (3.12) (pull_request) Successful in 1m16s
driver / test (3.13) (pull_request) Successful in 1m10s
driver / lowest (pull_request) Successful in 34s
driver / build (pull_request) Successful in 32s
driver / security (pull_request) Successful in 1m21s
CI / driver (pull_request) Successful in 2m58s
driver / publish (pull_request) Skipped
25369df572
napalm-device-types keeps them in a module of their own now; the package exports them.

Refs NetOrk/netork#484
christianmanivong merged commit cb29a42c31 into main 2026-11-01 19:06:53 +00:00
christianmanivong deleted branch feat/cluster-inventory 2026-11-01 19:06:53 +00:00
Sign in to join this conversation.