Make Proxmox version probe non-fatal

This commit is contained in:
2026-07-10 11:26:38 +02:00
parent 2a40d7952f
commit b3be1f3094
5 changed files with 26 additions and 8 deletions
+1
View File
@@ -15,3 +15,4 @@
| 0.2.1 | 4.4.0 | 4.6.x |
| 0.2.2 | 4.4.0 | 4.6.x |
| 0.2.3 | 4.4.0 | 4.6.x |
| 0.2.4 | 4.4.0 | 4.6.x |
+2
View File
@@ -56,6 +56,8 @@ Bei selbstsignierten Proxmox-Zertifikaten `Validate SSL` deaktiviert lassen. Wen
Der Proxmox-Client ignoriert Proxy-Umgebungsvariablen des NetBox-Dienstes, damit interne Proxmox-Adressen nicht versehentlich ueber einen HTTPS-Proxy laufen.
Der unauthentifizierte Proxmox-`version`-Probe ist nur diagnostisch. Wenn er haengt, versucht das Plugin den eigentlichen Login trotzdem.
Wenn Passwort-Login auf `access/ticket` haengt, zuerst den Realm im Benutzernamen pruefen (`root@pam`, `user@pve`, `user@ldaprealm`). Fuer produktive Imports ist ein Proxmox API-Token meistens stabiler als Passwort-Login.
Wenn `Sync interval minutes` gesetzt ist, prueft ein Systemjob alle fuenf Minuten, welche Endpoints faellig sind, und stellt die eigentlichen Sync-Jobs in die Queue.
+1 -1
View File
@@ -5,7 +5,7 @@ class VMwareImporterConfig(PluginConfig):
name = "netbox_vmware_importer"
verbose_name = "Virtualization Importer"
description = "Synchronize VMware vSphere and Proxmox VE virtual machines into NetBox."
version = "0.2.3"
version = "0.2.4"
author = "Internal NetBox Team"
base_url = "vmware-importer"
min_version = "4.4.0"
+21 -6
View File
@@ -244,6 +244,13 @@ class ProxmoxClient:
self.session = requests.Session()
self.session.trust_env = False
self.session.verify = self.endpoint.validate_ssl
self.session.headers.update(
{
"Accept": "application/json",
"Connection": "close",
"User-Agent": "netbox-vm-import/0.2",
}
)
if not self.endpoint.validate_ssl and InsecureRequestWarning is not None:
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
@@ -262,8 +269,13 @@ class ProxmoxClient:
self.session.close()
def _probe_api_availability(self):
self._request("GET", "version")
self.api_probe_succeeded = True
try:
self._request("GET", "version", timeout=(5, 10))
self.api_probe_succeeded = True
self.api_probe_error = ""
except ProxmoxConnectionError as exc:
self.api_probe_succeeded = False
self.api_probe_error = str(exc)
def _authenticate_with_password(self):
response = self._request(
@@ -288,20 +300,23 @@ class ProxmoxClient:
def _url(self, path):
return f"{self.base_url}/{path.strip('/')}"
def _request(self, method, path, **kwargs):
def _request(self, method, path, timeout=None, **kwargs):
url = self._url(path)
request_timeout = timeout or self.timeout
try:
response = self.session.request(method, url, timeout=self.timeout, **kwargs)
response = self.session.request(method, url, timeout=request_timeout, **kwargs)
response.raise_for_status()
return response
except requests.ConnectTimeout as exc:
raise ProxmoxConnectionError(
f"Proxmox API {method} {path} connect timed out after {self.timeout[0]} seconds."
f"Proxmox API {method} {path} connect timed out after {request_timeout[0]} seconds."
) from exc
except requests.ReadTimeout as exc:
detail = f"Proxmox API {method} {path} read timed out after {self.timeout[1]} seconds."
detail = f"Proxmox API {method} {path} read timed out after {request_timeout[1]} seconds."
if path == "access/ticket" and self.api_probe_succeeded:
detail += " API version endpoint responded, so the delay is likely in Proxmox authentication. Check username realm (e.g. root@pam), PAM/LDAP auth, two-factor auth, or use an API token."
elif getattr(self, "api_probe_error", "") and path != "version":
detail += f" Earlier unauthenticated version probe also failed: {self.api_probe_error}"
raise ProxmoxConnectionError(detail) from exc
except requests.exceptions.SSLError as exc:
raise ProxmoxConnectionError(
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "netbox-vmware-importer"
version = "0.2.3"
version = "0.2.4"
description = "NetBox plugin to synchronize VMware vSphere and Proxmox VE virtual machines into NetBox."
readme = "README.md"
requires-python = ">=3.12"