From f288c016294730f25c1603d31e5c684c22937bfa Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Mon, 22 Jun 2026 19:47:38 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20add=20get=5Fsystem=5Fconfig()=20?= =?UTF-8?q?=E2=80=94=20cluster=20name,=20timezone,=20node=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements get_system_config() in ProxmoxSystemMixin: - cluster_name from /cluster/status (type=cluster entry) - cluster_nodes list of online node hostnames - timezone from /nodes/{node}/time - hostname, ssh_port, ssh_password_auth with safe defaults Used by NetOrk's sync task to name the NetBox Cluster after the actual Proxmox cluster rather than falling back to the site name. Co-Authored-By: Claude Sonnet 4.6 --- napalm_proxmox/system_mixin.py | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/napalm_proxmox/system_mixin.py b/napalm_proxmox/system_mixin.py index 7b70efb..b2aa271 100644 --- a/napalm_proxmox/system_mixin.py +++ b/napalm_proxmox/system_mixin.py @@ -820,3 +820,47 @@ class ProxmoxSystemMixin: result[dev] = entry return result + + def get_system_config(self) -> dict[str, Any]: + """Return system-level configuration for this Proxmox node. + + Collected from ``/cluster/status`` and the node config API: + + * ``cluster_name`` (str | None) — Proxmox cluster name; ``None`` when + the node is standalone (not part of a cluster). + * ``cluster_nodes`` (list[str]) — hostnames of all online cluster nodes. + * ``hostname`` (str) — this node's name as reported by the cluster. + * ``timezone`` (str | None) — e.g. ``"Europe/Berlin"``. + * ``ntp_servers`` (list[str]). + * ``ssh_port`` (int) — always 22 for Proxmox nodes. + * ``ssh_password_auth`` (bool) — ``False`` as a safe default. + """ + cfg: dict[str, Any] = { + "cluster_name": None, + "cluster_nodes": [], + "hostname": self._node_name, + "timezone": None, + "ntp_servers": [], + "ssh_port": 22, + "ssh_password_auth": False, + } + + # Cluster name and node list from /cluster/status + try: + status = self._api.cluster.status.get() or [] + for entry in status: + if entry.get("type") == "cluster": + cfg["cluster_name"] = entry.get("name") + elif entry.get("type") == "node" and entry.get("online"): + cfg["cluster_nodes"].append(entry.get("name", "")) + except Exception as exc: + logger.debug("Failed to fetch cluster status for system config: %s", exc) + + # Timezone from node time API + try: + time_cfg = self._node_api().time.get() or {} + cfg["timezone"] = time_cfg.get("timezone") or None + except Exception as exc: + logger.debug("Failed to fetch node time config: %s", exc) + + return cfg