2
0
mirror of https://opendev.org/x/pyghmi synced 2025-02-15 01:59:17 +00:00

Check HTTP viability before use

If the session is dead, have the wc property function discard and
re-establish the connection, rather than passing the useless
stale session to the caller.

Change-Id: I701c396ac9eedc1749b13c196e19fb1c4e996001
This commit is contained in:
Jarrod Johnson 2019-11-22 08:45:26 -05:00
parent d5213a7369
commit 9d5e570f0e

View File

@ -77,7 +77,6 @@ class TsmHandler(generic.OEMHandler):
self._wc = None
self.username = None
self.password = None
self._wc = None
self.csrftok = None
self.fish = fish
super(TsmHandler, self).__init__(sysinfo, sysurl, webclient, cache)
@ -132,7 +131,9 @@ class TsmHandler(generic.OEMHandler):
def wc(self):
self.fwid = None
if self._wc:
return self._wc
rsp, status = self._wc.grab_json_response_with_status('/api/chassis-status')
if status == 200:
return self._wc
authdata = {
'username': self.username,
'password': self.password,
@ -342,4 +343,5 @@ class TsmHandler(generic.OEMHandler):
hdrs = wc.stdheaders.copy()
hdrs['Content-Length'] = 0
rsp = wc.grab_json_response_with_status('/api/maintenance/reset', method='POST', headers=hdrs)
self._wc = None
return 'complete'