recreate cache if cannot read
This commit is contained in:
parent
ec5ce90d9a
commit
27b2efbc95
|
|
@ -5,7 +5,7 @@ from VM import VM
|
||||||
from Storage import Storage
|
from Storage import Storage
|
||||||
|
|
||||||
USERNAME = "zabbix@pve"
|
USERNAME = "zabbix@pve"
|
||||||
PASSWORD = "KbCurGdt82NTgBye"
|
PASSWORD = "zabbix"
|
||||||
HOST = "localhost:8006"
|
HOST = "localhost:8006"
|
||||||
|
|
||||||
conn = PVEApi(HOST, USERNAME, PASSWORD)
|
conn = PVEApi(HOST, USERNAME, PASSWORD)
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,15 @@ class PVEApi(object):
|
||||||
Proxmox says ticket is valid for 2 hours. For safety we use 1 hour
|
Proxmox says ticket is valid for 2 hours. For safety we use 1 hour
|
||||||
:return: Boolean value of True if ticket is considered expired. False if opposite.
|
:return: Boolean value of True if ticket is considered expired. False if opposite.
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
with open(CACHEFILE, 'r') as f:
|
with open(CACHEFILE, 'r') as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
timestamp = data['timestamp']
|
timestamp = data['timestamp']
|
||||||
return True if time.time() - timestamp > 3600 else False
|
return True if time.time() - timestamp > 3600 else False
|
||||||
|
except:
|
||||||
|
self.csrftoken = get_auth(self.host, username, password)[0]
|
||||||
|
self.ticket = get_auth(self.host, username, password)[1]
|
||||||
|
self.write_ticketcache()
|
||||||
|
|
||||||
|
|
||||||
def write_ticketcache(self):
|
def write_ticketcache(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue