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

@ -312,7 +312,7 @@ homeassistant/components/plugwise/* @laetificat @CoMPaTech @bouwew
homeassistant/components/plum_lightpad/* @ColinHarrington homeassistant/components/plum_lightpad/* @ColinHarrington
homeassistant/components/point/* @fredrike homeassistant/components/point/* @fredrike
homeassistant/components/powerwall/* @bdraco @jrester homeassistant/components/powerwall/* @bdraco @jrester
homeassistant/components/proxmoxve/* @k4ds3 homeassistant/components/proxmoxve/* @k4ds3 @jhollowe
homeassistant/components/ps4/* @ktnrg45 homeassistant/components/ps4/* @ktnrg45
homeassistant/components/ptvsd/* @swamp-ig homeassistant/components/ptvsd/* @swamp-ig
homeassistant/components/push/* @dgomes homeassistant/components/push/* @dgomes

View File

@ -1,7 +1,6 @@
"""Support for Proxmox VE.""" """Support for Proxmox VE."""
from enum import Enum from enum import Enum
import logging import logging
import time
from proxmoxer import ProxmoxAPI from proxmoxer import ProxmoxAPI
from proxmoxer.backends.https import AuthenticationError from proxmoxer.backends.https import AuthenticationError
@ -137,25 +136,21 @@ class ProxmoxClient:
self._connection_start_time = None self._connection_start_time = None
def build_client(self): 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._proxmox = ProxmoxAPI(
self._host, self._host,
port=self._port, port=self._port,
user=f"{self._user}@{self._realm}", user=user_id,
password=self._password, password=self._password,
verify_ssl=self._verify_ssl, verify_ssl=self._verify_ssl,
) )
self._connection_start_time = time.monotonic()
def get_api_client(self): def get_api_client(self):
"""Return the ProxmoxAPI client and rebuild it if necessary.""" """Return the ProxmoxAPI client."""
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 self._proxmox return self._proxmox

View File

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

View File

@ -1115,7 +1115,7 @@ prometheus_client==0.7.1
protobuf==3.6.1 protobuf==3.6.1
# homeassistant.components.proxmoxve # homeassistant.components.proxmoxve
proxmoxer==1.0.4 proxmoxer==1.1.0
# homeassistant.components.systemmonitor # homeassistant.components.systemmonitor
psutil==5.7.0 psutil==5.7.0