client.py token login

This commit is contained in:
Bruno MATEU 2023-06-17 02:31:39 +02:00 committed by GitHub
parent 4444e3f9d0
commit 19604ffe94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -44,6 +44,21 @@ class ProxmoxClient:
self.config.config["pve"]["server"], self.config.config["pve"]["user"]
)
)
if self.config.config["pve"]["token_name"]:
if !self.config.config["pve"]["token_value"]:
self.logger.error("Token name require token value to be set ! Fallback to password authentification")
self.logger.debug("Using token login")
return ProxmoxAPI(
self.config.config["pve"]["server"],
user=self.config.config["pve"]["user"],
token_name=self.config.config["pve"]["token_name"],
token_value=self.config.config["pve"]["token_value"],
verify_ssl=to_bool(self.config.config["pve"]["verify_ssl"]),
timeout=self.config.config["pve"]["auth_timeout"]
)
return ProxmoxAPI(
self.config.config["pve"]["server"],
user=self.config.config["pve"]["user"],