mirror of
https://opendev.org/x/pyghmi
synced 2025-04-13 08:48:38 +00:00
Avoid stale webclient in XCC client
XCC aggressively ages out a session. Check last token refresh before deciding a session is viable, discarding it if it is too old. Change-Id: I490263edb4b2a8ddbd91d6b236d4a7e689f410c7
This commit is contained in:
parent
872f53ab0a
commit
534963553b
@ -268,6 +268,7 @@ class IMMClient(object):
|
||||
def get_webclient(self):
|
||||
cv = self.ipmicmd.certverify
|
||||
wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv)
|
||||
wc.vintage = None
|
||||
try:
|
||||
wc.connect()
|
||||
except socket.error as se:
|
||||
@ -301,7 +302,8 @@ class IMMClient(object):
|
||||
|
||||
@property
|
||||
def wc(self):
|
||||
if not self._wc:
|
||||
if (not self._wc or (self._wc.vintage and
|
||||
self._wc.vintage < util._monotonic_time() - 30)):
|
||||
self._wc = self.get_webclient()
|
||||
return self._wc
|
||||
|
||||
@ -757,6 +759,7 @@ class XCCClient(IMMClient):
|
||||
def get_webclient(self, login=True):
|
||||
cv = self.ipmicmd.certverify
|
||||
wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv)
|
||||
wc.vintage = util._monotonic_time()
|
||||
try:
|
||||
wc.connect()
|
||||
except socket.error as se:
|
||||
@ -1402,6 +1405,7 @@ class XCCClient(IMMClient):
|
||||
wc.grab_json_response('/api/providers/identity')
|
||||
if '_csrf_token' in wc.cookies:
|
||||
wc.set_header('X-XSRF-TOKEN', self.wc.cookies['_csrf_token'])
|
||||
wc.vintage = util._monotonic_time()
|
||||
|
||||
def set_hostname(self, hostname):
|
||||
self.wc.grab_json_response('/api/dataset', {'IMM_HostName': hostname})
|
||||
|
Loading…
x
Reference in New Issue
Block a user