Merge "Fix logging in controllerconfig package"

This commit is contained in:
Zuul 2020-07-02 17:19:56 +00:00 committed by Gerrit Code Review
commit fb3840bbad
5 changed files with 45 additions and 5 deletions

View File

@ -18,3 +18,4 @@ KEYRING_WORKDIR = '/tmp/python_keyring'
KEYRING_PERMDIR = tsconfig.KEYRING_PATH
INITIAL_CONFIG_COMPLETE_FILE = '/etc/platform/.initial_config_complete'
LOG_LOCAL1 = 'local1'

View File

@ -0,0 +1,32 @@
#
# Copyright (c) 2020 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
"""
Oslo Logging configuration
"""
from oslo_config import cfg
from oslo_log import log as logging
from controllerconfig.common import constants
def setup_logger():
""" Setup a logger """
# set in cfg what the valid syslog options are
logging.register_options(cfg.CONF)
# Send logs to /var/log/platform.log by overriding defaults
# to use syslog to local1
cfg.CONF.set_override("use_syslog", True)
cfg.CONF.set_override("syslog_log_facility", constants.LOG_LOCAL1)
logging.setup(cfg.CONF, 'controllerconfig')
def configure():
""" Setup logging """
setup_logger()

View File

@ -22,9 +22,10 @@ from cinderclient import utils as c_utils
from controllerconfig.common.rest_api_utils import get_token
from controllerconfig.common.exceptions import TidyStorageFail
from oslo_log import log
from controllerconfig.common import oslolog as log
from oslo_log import log as logging
LOG = log.getLogger(__name__)
LOG = logging.getLogger(__name__)
KEYSTONE_AUTH_SERVER_RETRY_CNT = 60
KEYSTONE_AUTH_SERVER_WAIT = 1 # 1sec wait per retry
@ -566,6 +567,8 @@ def main():
show_help()
exit(1)
log.configure()
result_file = sys.argv[1]
try:

View File

@ -43,9 +43,10 @@ from controllerconfig.common import constants
from controllerconfig import utils as cutils
from controllerconfig.upgrades import utils
from oslo_log import log
from controllerconfig.common import oslolog as log
from oslo_log import log as logging
LOG = log.getLogger(__name__)
LOG = logging.getLogger(__name__)
POSTGRES_MOUNT_PATH = '/mnt/postgresql'
POSTGRES_DUMP_MOUNT_PATH = '/mnt/db_dump'
@ -1041,6 +1042,8 @@ def main():
exit(1)
arg += 1
log.configure()
if not from_release or not to_release:
print("Both the FROM_RELEASE and TO_RELEASE must be specified")
exit(1)
@ -1335,6 +1338,8 @@ def simplex_main():
exit(1)
arg += 1
log.configure()
if not backup_file:
print("The BACKUP_FILE must be specified")
exit(1)

View File

@ -25,7 +25,6 @@ from controllerconfig.common import constants
from controllerconfig.common.exceptions import ValidateFail
from oslo_log import log
LOG = log.getLogger(__name__)
DEVNULL = open(os.devnull, 'w')