mirror of
https://opendev.org/x/pyghmi
synced 2025-08-21 18:40:20 +00:00
Improve performance of get_health for XCC
Provide a quicker health assessment for XCC. Generally provide a way for OEMs to replace or augment or conditionally replace the generic behavior. Change-Id: I54c9b9a91aabd6025d17d65846be164b87694019
This commit is contained in:
@@ -54,3 +54,9 @@ class UnsupportedFunctionality(PyghmiException):
|
||||
# Indicates when functionality is requested that is not supported by
|
||||
# current endpoint
|
||||
pass
|
||||
|
||||
|
||||
class BypassGenericBehavior(PyghmiException):
|
||||
# Indicates that an OEM handler wants to abort any standards based
|
||||
# follow up
|
||||
pass
|
||||
|
@@ -657,10 +657,15 @@ class Command(object):
|
||||
warning, critical, or failed assessments.
|
||||
"""
|
||||
summary = {'badreadings': [], 'health': const.Health.Ok}
|
||||
for reading in self.get_sensor_data():
|
||||
if reading.health != const.Health.Ok:
|
||||
summary['health'] |= reading.health
|
||||
summary['badreadings'].append(reading)
|
||||
try:
|
||||
self.oem_init()
|
||||
self._oem.get_health(summary)
|
||||
for reading in self.get_sensor_data():
|
||||
if reading.health != const.Health.Ok:
|
||||
summary['health'] |= reading.health
|
||||
summary['badreadings'].append(reading)
|
||||
except exc.BypassGenericBehavior:
|
||||
pass
|
||||
return summary
|
||||
|
||||
def get_sensor_reading(self, sensorname):
|
||||
|
@@ -265,6 +265,19 @@ class OEMHandler(object):
|
||||
"""
|
||||
raise exc.UnsupportedFunctionality()
|
||||
|
||||
def get_health(self, summary):
|
||||
"""Provide an alternative or augmented health assessment
|
||||
|
||||
An OEM handler can preprocess the summary and extend it with OEM
|
||||
specific data, and then return to let generic processing occur.
|
||||
It can also raise the pyghmi exception BypassGenericBehavior to
|
||||
suppress the standards based routine, for enhanced performance.
|
||||
|
||||
:param summary: The health summary as prepared by the generic function
|
||||
:return: Nothing, modifies the summary object
|
||||
"""
|
||||
return
|
||||
|
||||
def set_alert_ipv6_destination(self, ip, destination, channel):
|
||||
"""Set an IPv6 alert destination
|
||||
|
||||
|
@@ -923,3 +923,8 @@ class OEMHandler(generic.OEMHandler):
|
||||
if self.has_xcc:
|
||||
return self.immhandler.list_media()
|
||||
return super(OEMHandler, self).list_media()
|
||||
|
||||
def get_health(self, summary):
|
||||
if self.has_xcc:
|
||||
return self.immhandler.get_health(summary)
|
||||
return super(OEMHandler, self).get_health(summary)
|
||||
|
@@ -569,7 +569,7 @@ class XCCClient(IMMClient):
|
||||
super(XCCClient, self).__init__(ipmicmd)
|
||||
self.adp_referer = None
|
||||
|
||||
def get_webclient(self):
|
||||
def get_webclient(self, login=True):
|
||||
cv = self.ipmicmd.certverify
|
||||
wc = webclient.SecureHTTPConnection(self.imm, 443, verifycallback=cv)
|
||||
try:
|
||||
@@ -578,6 +578,8 @@ class XCCClient(IMMClient):
|
||||
if se.errno != errno.ECONNREFUSED:
|
||||
raise
|
||||
return None
|
||||
if not login:
|
||||
return wc
|
||||
adata = json.dumps({'username': self.username,
|
||||
'password': self.password
|
||||
})
|
||||
@@ -1251,3 +1253,11 @@ class XCCClient(IMMClient):
|
||||
if bank == 'backup':
|
||||
return 'complete'
|
||||
return 'pending'
|
||||
|
||||
def get_health(self, summary):
|
||||
wc = self.get_webclient(False)
|
||||
rsp = wc.grab_json_response('/api/providers/imm_active_events')
|
||||
if 'items' in rsp and len(rsp['items']) == 0:
|
||||
# The XCC reports healthy, no need to interrogate
|
||||
raise pygexc.BypassGenericBehavior()
|
||||
# Will use the generic handling for unhealthy systems
|
||||
|
Reference in New Issue
Block a user