From 6f499a62c347c9a1432d15dbd93a7343c6da1aee Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Thu, 4 Apr 2013 17:33:20 -0400 Subject: Only call getLogger after configuring logging. Logging needs to be setup properly before we try to log something. Fix a test case that loads the code but does not execute the code that results in the LOG being setup properly. Fixes LP# 1161031 Change-Id: I9d5bc6b87cfb25243f00e17b532d4485dc4454e4 --- nova/cmd/all.py | 2 +- nova/cmd/baremetal_deploy_helper.py | 3 +-- nova/cmd/compute.py | 2 +- nova/cmd/dhcpbridge.py | 3 ++- nova/tests/baremetal/test_nova_baremetal_deploy_helper.py | 3 +++ 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/nova/cmd/all.py b/nova/cmd/all.py index f7e76fe30..a6426ed33 100644 --- a/nova/cmd/all.py +++ b/nova/cmd/all.py @@ -43,12 +43,12 @@ CONF = cfg.CONF CONF.import_opt('manager', 'nova.conductor.api', group='conductor') CONF.import_opt('topic', 'nova.conductor.api', group='conductor') CONF.import_opt('enabled_apis', 'nova.service') -LOG = logging.getLogger('nova.all') def main(): config.parse_args(sys.argv) logging.setup("nova") + LOG = logging.getLogger('nova.all') utils.monkey_patch() launcher = service.ProcessLauncher() diff --git a/nova/cmd/baremetal_deploy_helper.py b/nova/cmd/baremetal_deploy_helper.py index 2a5252694..5ccd43b56 100644 --- a/nova/cmd/baremetal_deploy_helper.py +++ b/nova/cmd/baremetal_deploy_helper.py @@ -39,8 +39,6 @@ from nova.virt.baremetal import baremetal_states from nova.virt.baremetal import db -LOG = logging.getLogger('nova.virt.baremetal.deploy_helper') - QUEUE = Queue.Queue() @@ -315,6 +313,7 @@ class BareMetalDeploy(object): def main(): config.parse_args(sys.argv) logging.setup("nova") + LOG = logging.getLogger('nova.virt.baremetal.deploy_helper') app = BareMetalDeploy() srv = simple_server.make_server('', 10000, app) srv.serve_forever() diff --git a/nova/cmd/compute.py b/nova/cmd/compute.py index 07caa17b1..644462dde 100644 --- a/nova/cmd/compute.py +++ b/nova/cmd/compute.py @@ -34,7 +34,6 @@ from nova import utils CONF = cfg.CONF CONF.import_opt('compute_topic', 'nova.compute.rpcapi') CONF.import_opt('use_local', 'nova.conductor.api', group='conductor') -LOG = logging.getLogger('nova.compute') def block_db_access(): @@ -44,6 +43,7 @@ def block_db_access(): def __call__(self, *args, **kwargs): stacktrace = "".join(traceback.format_stack()) + LOG = logging.getLogger('nova.compute') LOG.error('No db access allowed in nova-compute: %s' % stacktrace) raise exception.DBNotAllowed('nova-compute') diff --git a/nova/cmd/dhcpbridge.py b/nova/cmd/dhcpbridge.py index 436039af6..c874af51e 100644 --- a/nova/cmd/dhcpbridge.py +++ b/nova/cmd/dhcpbridge.py @@ -41,7 +41,6 @@ from nova.openstack.common import rpc CONF = cfg.CONF CONF.import_opt('host', 'nova.netconf') CONF.import_opt('network_manager', 'nova.service') -LOG = logging.getLogger('nova.dhcpbridge') def add_lease(mac, ip_address): @@ -118,6 +117,8 @@ def main(): default_config_files=jsonutils.loads(config_file)) logging.setup("nova") + global LOG + LOG = logging.getLogger('nova.dhcpbridge') if CONF.action.name in ['add', 'del', 'old']: msg = (_("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") % diff --git a/nova/tests/baremetal/test_nova_baremetal_deploy_helper.py b/nova/tests/baremetal/test_nova_baremetal_deploy_helper.py index 004fce060..42ee6c8e4 100644 --- a/nova/tests/baremetal/test_nova_baremetal_deploy_helper.py +++ b/nova/tests/baremetal/test_nova_baremetal_deploy_helper.py @@ -23,10 +23,13 @@ import time import mox from nova.cmd import baremetal_deploy_helper as bmdh +from nova.openstack.common import log as logging from nova import test from nova.tests.baremetal.db import base as bm_db_base from nova.virt.baremetal import db as bm_db +bmdh.LOG = logging.getLogger('nova.virt.baremetal.deploy_helper') + _PXECONF_DEPLOY = """ default deploy -- cgit