From f7867c9e516f28843b498e69399c6029adf52bca Mon Sep 17 00:00:00 2001 From: Bin Xu Date: Tue, 3 Apr 2018 18:13:55 +0800 Subject: [PATCH] workaround python agent when /dev/log is not available (#5051) --- xCAT-openbmc-py/lib/python/agent/common/utils.py | 6 +++++- xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/xCAT-openbmc-py/lib/python/agent/common/utils.py b/xCAT-openbmc-py/lib/python/agent/common/utils.py index e84bca7b1..a2f2e00b0 100644 --- a/xCAT-openbmc-py/lib/python/agent/common/utils.py +++ b/xCAT-openbmc-py/lib/python/agent/common/utils.py @@ -23,7 +23,11 @@ def getxCATLog(name=None): return xl def enableSyslog(name='xcat'): - h = SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL4) + try: + h = SysLogHandler(address='/dev/log', facility=SysLogHandler.LOG_LOCAL4) + except: + # this will connect localhost:514 + h = SysLogHandler(facility=SysLogHandler.LOG_LOCAL4) h.setFormatter(logging.Formatter('%s: ' % name + '%(levelname)s %(message)s')) logging.getLogger('xcatagent').addHandler(h) diff --git a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py index 7f8039a68..c7cf2a85c 100644 --- a/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py +++ b/xCAT-openbmc-py/lib/python/agent/xcatagent/openbmc.py @@ -33,8 +33,11 @@ from hwctl.eventlog import DefaultEventlogManager from xcatagent import base import logging logger = logging.getLogger('xcatagent') -if not logger.handlers: - utils.enableSyslog('xcat.agent') +try: + if not logger.handlers: + utils.enableSyslog('xcat.agent') +except: + pass HTTP_PROTOCOL = "https://" PROJECT_URL = "/xyz/openbmc_project"