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).
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.
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Implements
get_clusters()from napalm-device-types for Proxmox VE, and thenodekeyword ofcreate_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 asofflinewithout 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 areavailableon (shared: one node's size, local: summed); bridges per node merged by name (vlan_awareonly 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/statusand/cluster/resourcesraise.network_targets.py: the bridge part ofget_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).Related Issue
NetOrk/netork#484, NetOrk/netork#1822. Needs NAPALM/napalm-device-types
feat/cluster-inventorymerged 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.