Use requests client for Proxmox password auth
This commit is contained in:
@@ -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.
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user