client.py token login

This commit is contained in:
Bruno MATEU 2023-06-17 02:31:39 +02:00 committed by Robert Kaussow
parent 27628c5cf0
commit 907f4cb6fb
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0

View File

@ -44,6 +44,21 @@ class ProxmoxClient:
self.config.config["pve"]["server"], self.config.config["pve"]["user"] 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( return ProxmoxAPI(
self.config.config["pve"]["server"], self.config.config["pve"]["server"],
user=self.config.config["pve"]["user"], user=self.config.config["pve"]["user"],