From 7d8819c3746431b377e739aef74b05b95b39a27c Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 20 Jul 2026 13:42:01 +0200 Subject: [PATCH] Use requests client for Proxmox password auth --- README.md | 2 +- netbox_vmware_importer/sync.py | 10 +++++++++- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 073f9c7..e99e514 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ sudo systemctl restart netbox netbox-rq Bei selbstsignierten Proxmox-Zertifikaten `Validate SSL` deaktiviert lassen. Wenn Proxmox langsam antwortet, kann `API timeout` am Endpoint erhoeht werden. -Der Proxmox-Client nutzt bevorzugt `proxmox-sdk` wie `netbox-proxbox`/`proxbox-api`. Falls dieses Paket nicht installiert ist, faellt er auf den bisherigen `requests`-Client zurueck. Proxy-Umgebungsvariablen des NetBox-Dienstes werden im Fallback ignoriert, damit interne Proxmox-Adressen nicht versehentlich ueber einen HTTPS-Proxy laufen. +Der Proxmox-Client nutzt fuer API-Token bevorzugt `proxmox-sdk` wie `netbox-proxbox`/`proxbox-api`. Passwort-Logins laufen ueber den eigenen `requests`-Client, weil `proxmox-sdk==0.0.12` die Ticket-URL fuer Passwort-Authentifizierung ohne `/api2/json` aufbaut. Proxy-Umgebungsvariablen des NetBox-Dienstes werden im `requests`-Client ignoriert, damit interne Proxmox-Adressen nicht versehentlich ueber einen HTTPS-Proxy laufen. Im `requests`-Fallback ist der unauthentifizierte Proxmox-`version`-Probe nur diagnostisch. Wenn er haengt, versucht das Plugin den eigentlichen Login trotzdem. Im bevorzugten SDK-Pfad wird `version` als erste SDK-Anfrage genutzt und authentifiziert dabei automatisch. diff --git a/netbox_vmware_importer/sync.py b/netbox_vmware_importer/sync.py index 7c8eaf1..d3c655d 100644 --- a/netbox_vmware_importer/sync.py +++ b/netbox_vmware_importer/sync.py @@ -291,7 +291,7 @@ class ProxmoxClient: if "@" not in self.endpoint.username: raise ProxmoxConnectionError("Proxmox username must include a realm, e.g. root@pam or user@pve.") - if ProxmoxSDK is not None: + if self._should_use_sdk(): self._connect_with_sdk() return self @@ -327,6 +327,14 @@ class ProxmoxClient: return f"[{host}]" return host + def _should_use_sdk(self): + # proxmox-sdk 0.0.12 builds password ticket URLs without /api2/json. + # Keep it for stateless API-token auth, where no ticket endpoint is used. + return ( + ProxmoxSDK is not None + and self.endpoint.auth_method == EndpointAuthMethodChoices.METHOD_API_TOKEN + ) + def _connect_with_sdk(self): user = (self.endpoint.username or "").strip() kwargs = { diff --git a/pyproject.toml b/pyproject.toml index f06e11b..abc9a1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "netbox-vmware-importer" -version = "0.2.6" +version = "0.2.7" description = "NetBox plugin to synchronize VMware vSphere and Proxmox VE virtual machines into NetBox." readme = "README.md" requires-python = ">=3.12"