Update proxmoxer to 1.1.0 (#35951)

This commit is contained in:
John Hollowell 2020-05-22 16:53:17 -04:00 committed by GitHub
parent 7043d1e163
commit f74e2f8abb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 17 deletions

View file

@ -1,7 +1,6 @@
"""Support for Proxmox VE."""
from enum import Enum
import logging
import time
from proxmoxer import ProxmoxAPI
from proxmoxer.backends.https import AuthenticationError
@ -137,25 +136,21 @@ class ProxmoxClient:
self._connection_start_time = None
def build_client(self):
"""Construct the ProxmoxAPI client."""
"""Construct the ProxmoxAPI client. Allows inserting the realm within the `user` value."""
if "@" in self._user:
user_id = self._user
else:
user_id = f"{self._user}@{self._realm}"
self._proxmox = ProxmoxAPI(
self._host,
port=self._port,
user=f"{self._user}@{self._realm}",
user=user_id,
password=self._password,
verify_ssl=self._verify_ssl,
)
self._connection_start_time = time.monotonic()
def get_api_client(self):
"""Return the ProxmoxAPI client and rebuild it if necessary."""
connection_age = time.monotonic() - self._connection_start_time
# Workaround for the Proxmoxer bug where the connection stops working after some time
if connection_age > 30 * 60:
self.build_client()
"""Return the ProxmoxAPI client."""
return self._proxmox

View file

@ -2,6 +2,6 @@
"domain": "proxmoxve",
"name": "Proxmox VE",
"documentation": "https://www.home-assistant.io/integrations/proxmoxve",
"codeowners": ["@k4ds3"],
"requirements": ["proxmoxer==1.0.4"]
"codeowners": ["@k4ds3", "@jhollowe"],
"requirements": ["proxmoxer==1.1.0"]
}