From 7ca39a6039d58d2f9991e31bf283389e3f588a45 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 19 Feb 2013 17:20:30 -0800 Subject: [PATCH] Fix broken logging imports. This fixes all of the files incorrectly importing logging directly and removes the workaround in hacking.py that was due to improper from nova.openstack.common.log import logging statements. Change-Id: Icfc25dc148c4a7b5fa7f6a7b609cd6c3d94efee1 --- HACKING.rst | 1 - nova/api/validator.py | 4 +++- nova/tests/integrated/integrated_helpers.py | 2 +- nova/tests/integrated/test_api_samples.py | 2 +- nova/tests/integrated/test_extensions.py | 2 +- nova/tests/integrated/test_login.py | 2 +- nova/tests/integrated/test_multiprocess_api.py | 2 +- nova/tests/integrated/test_servers.py | 2 +- nova/tests/integrated/test_xml.py | 2 +- nova/tests/test_imagecache.py | 11 +++++------ nova/virt/xenapi/host.py | 3 +-- tools/hacking.py | 1 - 12 files changed, 16 insertions(+), 18 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index 30f87576f190..223f3ed7b7c1 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -63,7 +63,6 @@ Imports - imports from ``migrate`` package - imports from ``sqlalchemy`` package - imports from ``nova.db.sqlalchemy.session`` module -- imports from ``nova.openstack.common.log.logging`` package - imports from ``nova.db.sqlalchemy.migration.versioning_api`` package Example:: diff --git a/nova/api/validator.py b/nova/api/validator.py index ddcc3ed2a01b..9304387fd3c2 100644 --- a/nova/api/validator.py +++ b/nova/api/validator.py @@ -17,10 +17,12 @@ # under the License. import base64 -import logging import re import socket +from nova.openstack.common import log as logging + + LOG = logging.getLogger(__name__) diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py index 0e696a6c4337..e8fb2b6ba621 100644 --- a/nova/tests/integrated/integrated_helpers.py +++ b/nova/tests/integrated/integrated_helpers.py @@ -26,7 +26,7 @@ import uuid from oslo.config import cfg import nova.image.glance -from nova.openstack.common.log import logging +from nova.openstack.common import log as logging from nova import service from nova import test from nova.tests import fake_crypto diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 8c2723e67423..724d39f8b6c9 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -39,7 +39,7 @@ from nova import exception from nova.network import api as network_api from nova.openstack.common import importutils from nova.openstack.common import jsonutils -from nova.openstack.common.log import logging +from nova.openstack.common import log as logging from nova.openstack.common import timeutils import nova.quota from nova.scheduler import driver diff --git a/nova/tests/integrated/test_extensions.py b/nova/tests/integrated/test_extensions.py index 33499ee5ddb8..e1dc96e939fc 100644 --- a/nova/tests/integrated/test_extensions.py +++ b/nova/tests/integrated/test_extensions.py @@ -18,7 +18,7 @@ from oslo.config import cfg # Import extensions to pull in osapi_compute_extension CONF option used below. -from nova.openstack.common.log import logging +from nova.openstack.common import log as logging from nova.tests.integrated import integrated_helpers CONF = cfg.CONF diff --git a/nova/tests/integrated/test_login.py b/nova/tests/integrated/test_login.py index 80b40e6161bd..8f1601ee0efe 100644 --- a/nova/tests/integrated/test_login.py +++ b/nova/tests/integrated/test_login.py @@ -16,7 +16,7 @@ # under the License. -from nova.openstack.common.log import logging +from nova.openstack.common import log as logging from nova.tests.integrated import integrated_helpers diff --git a/nova/tests/integrated/test_multiprocess_api.py b/nova/tests/integrated/test_multiprocess_api.py index ae4fcc32fd74..855f702ba13f 100644 --- a/nova/tests/integrated/test_multiprocess_api.py +++ b/nova/tests/integrated/test_multiprocess_api.py @@ -21,7 +21,7 @@ import signal import time import traceback -from nova.openstack.common.log import logging +from nova.openstack.common import log as logging from nova import service from nova.tests.integrated import integrated_helpers diff --git a/nova/tests/integrated/test_servers.py b/nova/tests/integrated/test_servers.py index b70db93f2851..95c2da2a180f 100644 --- a/nova/tests/integrated/test_servers.py +++ b/nova/tests/integrated/test_servers.py @@ -18,7 +18,7 @@ import time import zlib -from nova.openstack.common.log import logging +from nova.openstack.common import log as logging from nova.tests import fake_network from nova.tests.integrated.api import client from nova.tests.integrated import integrated_helpers diff --git a/nova/tests/integrated/test_xml.py b/nova/tests/integrated/test_xml.py index 1c1dd1b06fd8..d9f10c630081 100644 --- a/nova/tests/integrated/test_xml.py +++ b/nova/tests/integrated/test_xml.py @@ -19,7 +19,7 @@ from lxml import etree from nova.api.openstack import common from nova.api.openstack import xmlutil -from nova.openstack.common.log import logging +from nova.openstack.common import log as logging from nova.tests.integrated import integrated_helpers diff --git a/nova/tests/test_imagecache.py b/nova/tests/test_imagecache.py index 8c752bbb9553..0c5c6d02c13f 100644 --- a/nova/tests/test_imagecache.py +++ b/nova/tests/test_imagecache.py @@ -20,7 +20,6 @@ import contextlib import cStringIO import hashlib import json -import logging import os import time @@ -30,7 +29,7 @@ from nova.compute import vm_states from nova import conductor from nova import db from nova.openstack.common import importutils -from nova.openstack.common import log +from nova.openstack.common import log as logging from nova import test from nova import utils from nova.virt.libvirt import imagecache @@ -40,7 +39,7 @@ CONF = cfg.CONF CONF.import_opt('compute_manager', 'nova.service') CONF.import_opt('host', 'nova.netconf') -LOG = log.getLogger(__name__) +LOG = logging.getLogger(__name__) class ImageCacheManagerTestCase(test.TestCase): @@ -341,10 +340,10 @@ class ImageCacheManagerTestCase(test.TestCase): @contextlib.contextmanager def _intercept_log_messages(self): try: - mylog = log.getLogger('nova') + mylog = logging.getLogger('nova') stream = cStringIO.StringIO() - handler = logging.StreamHandler(stream) - handler.setFormatter(log.LegacyFormatter()) + handler = logging.logging.StreamHandler(stream) + handler.setFormatter(logging.LegacyFormatter()) mylog.logger.addHandler(handler) yield stream finally: diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py index 045409e4fdc1..6ddc76494693 100644 --- a/nova/virt/xenapi/host.py +++ b/nova/virt/xenapi/host.py @@ -19,13 +19,12 @@ Management class for host-related functions (start, reboot, etc). """ -import logging - from nova.compute import task_states from nova.compute import vm_states from nova import context from nova import exception from nova.openstack.common import jsonutils +from nova.openstack.common import log as logging from nova.virt.xenapi import pool_states from nova.virt.xenapi import vm_utils diff --git a/tools/hacking.py b/tools/hacking.py index d7c00046c6fd..1279e87e9d64 100755 --- a/tools/hacking.py +++ b/tools/hacking.py @@ -46,7 +46,6 @@ logging.disable('LOG') #N9xx other IMPORT_EXCEPTIONS = ['sqlalchemy', 'migrate', 'nova.db.sqlalchemy.session', - 'nova.openstack.common.log.logging', 'nova.db.sqlalchemy.migration.versioning_api'] # Paste is missing a __init__ in top level directory START_DOCSTRING_TRIPLE = ['u"""', 'r"""', '"""', "u'''", "r'''", "'''"]