Merge "Delete HTTP tokens on `Sushy` shutdown"

This commit is contained in:
Zuul 2018-11-12 17:34:41 +00:00 committed by Gerrit Code Review
commit 817e77a115
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Tries to terminate authenticated Redfish session at BMC Session Service on
the event of ``Sushy`` object deallocation. This should reduce the chance
of authenticated sessions pool exhaustion at some BMCs.

View File

@ -110,10 +110,21 @@ class Sushy(base.ResourceBase):
super(Sushy, self).__init__(
connector or sushy_connector.Connector(base_url, verify=verify),
path=self._root_prefix)
self._base_url = base_url
self._auth = auth
self._auth.set_context(self, self._conn)
self._auth.authenticate()
def __del__(self):
if self._auth:
try:
self._auth.close()
except Exception as ex:
LOG.warning('Ignoring error while closing Redfish session '
'with %s: %s', self._base_url, ex)
self._auth = None
def _parse_attributes(self):
super(Sushy, self)._parse_attributes()
self.redfish_version = self.json.get('RedfishVersion')