From 66471624bc1c76ac9568df02c2e48e8e565810eb Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 12 Dec 2018 09:53:36 -0500 Subject: [PATCH] Support caching SDR for pyghmi versions that support it This will improve performance across confluent restarts for commands like nodesensors, nodehealth, and nodeinventory. --- .../confluent/plugins/hardwaremanagement/ipmi.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index a064524e..8612c1bb 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -27,6 +27,7 @@ import eventlet.greenpool as greenpool import eventlet.queue as queue import eventlet.support.greendns from fnmatch import fnmatch +import os import pyghmi.constants as pygconstants import pyghmi.exceptions as pygexc import pyghmi.storage as storage @@ -172,6 +173,17 @@ class IpmiCommandWrapper(ipmicommand.Command): 'hardwaremanagement.manager'), self._attribschanged) super(self.__class__, self).__init__(**kwargs) self.setup_confluent_keyhandler() + try: + os.makedirs('/var/cache/confluent/ipmi/') + except OSError as e: + if e.errno != errno.EEXIST or not os.path.isdir( + '/var/cache/confluent/ipmi/'): + raise + try: + self.set_sdr_cachedir('/var/cache/confluent/ipmi/') + except Exception: + pass + def setup_confluent_keyhandler(self): self.register_key_handler(util.TLSCertVerifier(