From f26fc5401d1b5978c27d0529caa9d65bf794012e Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 19 Jul 2019 15:16:42 -0400 Subject: [PATCH] Check XCC HTTP service health If the service is unreachable, emit an error explaining the situation more clearly. Change-Id: I5cc04d7fbec31869e9248936718543e480e60e29 --- pyghmi/ipmi/oem/lenovo/imm.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 3cc47c0c..0e8a7aea 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -1,7 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # coding=utf8 -# Copyright 2016-2018 Lenovo +# Copyright 2016-2019 Lenovo # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1729,6 +1729,15 @@ class XCCClient(IMMClient): def get_health(self, summary): wc = self.get_webclient(False) + if not wc: + summary['health'] = pygconst.Health.Critical; + summary['badreadings'].append( + sdr.SensorReading({'name': 'HTTPS Service', + 'states': ['Unreachable'], + 'state_ids': [3], + 'health': pygconst.Health.Critical, + 'type': 'BMC'}, '')) + raise pygexc.BypassGenericBehavior() rsp = wc.grab_json_response('/api/providers/imm_active_events') if 'items' in rsp and len(rsp['items']) == 0: ledcheck = self.wc.grab_json_response( @@ -1846,4 +1855,4 @@ class XCCClient(IMMClient): if days == 366: return 0 else: - return days \ No newline at end of file + return days