Use olso.log directly

As the openstack/common is deprecated, Watcher should use oslo lib
directly to run in the openstack env. So there is much work to do
with oslo. This patch fixed the log part.

Change-Id: I3145a842fe3a22b3d08fec60d180329073edd50f
This commit is contained in:
unknown
2015-11-12 11:45:50 +08:00
committed by wangxiyuan
parent f763d6c608
commit 0c348313a4
41 changed files with 74 additions and 70 deletions

View File

@@ -7,7 +7,7 @@ oslo.config==1.14.0
PasteDeploy==1.5.2
oslo.messaging==1.16.0
oslo.db==2.1.0
oslo.log==1.6.0
oslo.log>=1.8.0 # Apache-2.0
oslo.i18n==2.1.0
oslo.utils==1.8.0 # Apache-2.0
pecan>=0.8

View File

@@ -15,12 +15,13 @@
import re
from oslo_log import log
from keystonemiddleware import auth_token
from watcher.common import exception
from watcher.common.i18n import _
from watcher.common import utils
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -26,9 +26,10 @@ from xml import etree as et
import webob
from oslo_log import log
from watcher.common.i18n import _
from watcher.common.i18n import _LE
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -20,6 +20,8 @@
import random
import time
from oslo_log import log
import cinderclient.exceptions as ciexceptions
import cinderclient.v2.client as ciclient
import glanceclient.v2.client as glclient
@@ -27,7 +29,6 @@ import keystoneclient.v3.client as ksclient
import neutronclient.neutron.client as netclient
import novaclient.exceptions as nvexceptions
import novaclient.v2.client as nvclient
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -16,6 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_log import log
from watcher.applier.framework.default_command_mapper import \
DefaultCommandMapper
@@ -24,7 +26,6 @@ from watcher.applier.framework.messaging.events import Events
from watcher.common.messaging.events.event import Event
from watcher.objects import Action
from watcher.objects.action_plan import Status
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -16,7 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from watcher.openstack.common import log
from oslo_log import log
LOG = log.getLogger(__name__)

View File

@@ -19,13 +19,13 @@
from concurrent.futures import ThreadPoolExecutor
from oslo_config import cfg
from oslo_log import log
from watcher.applier.framework.messaging.trigger_action_plan import \
TriggerActionPlan
from watcher.common.messaging.messaging_core import MessagingCore
from watcher.common.messaging.notification_handler import NotificationHandler
from watcher.decision_engine.framework.messaging.events import Events
from watcher.openstack.common import log
CONF = cfg.CONF

View File

@@ -16,6 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_log import log
from watcher.applier.api.messaging.applier_command import ApplierCommand
from watcher.applier.framework.default_applier import DefaultApplier
from watcher.applier.framework.messaging.events import Events
@@ -23,8 +25,6 @@ from watcher.common.messaging.events.event import Event
from watcher.objects.action_plan import ActionPlan
from watcher.objects.action_plan import Status
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -16,10 +16,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_log import log
from watcher.applier.framework.messaging.launch_action_plan import \
LaunchActionPlanCommand
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -17,6 +17,7 @@
# limitations under the License.
#
from oslo_config import cfg
from oslo_log import log
import oslo_messaging as om
@@ -30,7 +31,6 @@ from watcher.common.messaging.messaging_core import MessagingCore
from watcher.common.messaging.notification_handler import NotificationHandler
from watcher.common.messaging.utils.transport_url_builder import \
TransportUrlBuilder
from watcher.openstack.common import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -22,14 +22,15 @@ import os
from wsgiref import simple_server
from oslo_config import cfg
from oslo_log import log as logging
from watcher.api import app as api_app
from watcher.common.i18n import _
from watcher.openstack.common import log as logging
from watcher import service
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
def main():
@@ -41,7 +42,7 @@ def main():
host, port = cfg.CONF.api.host, cfg.CONF.api.port
srv = simple_server.make_server(host, port, app)
logging.setup('watcher')
logging.setup(CONF, 'watcher')
LOG.info(_('Starting server in PID %s') % os.getpid())
LOG.debug("Watcher configuration:")
cfg.CONF.log_opt_values(LOG, std_logging.DEBUG)

View File

@@ -22,18 +22,19 @@ import os
import sys
from oslo_config import cfg
from oslo_log import log as logging
from watcher.applier.framework.manager_applier import ApplierManager
from watcher.openstack.common._i18n import _LI
from watcher.openstack.common import log as logging
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
def main():
cfg.CONF(sys.argv[1:], project='watcher')
logging.setup('watcher')
logging.setup(CONF, 'watcher')
LOG.info(_LI('Starting server in PID %s') % os.getpid())
LOG.debug("Configuration:")

View File

@@ -22,22 +22,23 @@ import os
import sys
from oslo_config import cfg
from oslo_log import log as logging
from watcher.decision_engine.framework.manager_decision_engine import \
DecisionEngineManager
from watcher.openstack.common._i18n import _LI
from watcher.openstack.common import log as logging
cfg.CONF.import_opt('hostname',
'watcher.metrics_engine.framework.'
'datasources.influxdb_collector',
group='watcher_influxdb_collector')
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
def main():
cfg.CONF(sys.argv[1:], project='watcher')
logging.setup('watcher')
logging.setup(CONF, 'watcher')
LOG.info(_LI('Starting server in PID %s') % os.getpid())
LOG.debug("Configuration:")

View File

@@ -23,11 +23,12 @@ SHOULD include dedicated exception logging.
"""
from oslo_config import cfg
from oslo_log import log as logging
import six
from watcher.common.i18n import _
from watcher.common.i18n import _LE
from watcher.openstack.common import log as logging
LOG = logging.getLogger(__name__)

View File

@@ -14,9 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log
from watcher.decision_engine.framework.messaging.events import Events
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -16,7 +16,7 @@
from oslo_config import cfg
from oslo_log import log
from watcher.common.messaging.events.event_dispatcher import \
EventDispatcher
from watcher.common.messaging.messaging_handler import \
@@ -24,7 +24,6 @@ from watcher.common.messaging.messaging_handler import \
from watcher.common.rpc import RequestContextSerializer
from watcher.objects.base import WatcherObjectSerializer
from watcher.openstack.common import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -16,13 +16,13 @@
import eventlet
from oslo_config import cfg
from oslo_log import log
import oslo_messaging as om
from threading import Thread
from watcher.common.messaging.utils.transport_url_builder import \
TransportUrlBuilder
from watcher.common.rpc import JsonPayloadSerializer
from watcher.common.rpc import RequestContextSerializer
from watcher.openstack.common import log
eventlet.monkey_patch()
LOG = log.getLogger(__name__)

View File

@@ -16,10 +16,10 @@
import eventlet
from oslo import messaging
from oslo_log import log
from watcher.common.messaging.utils.observable import \
Observable
from watcher.openstack.common import log
eventlet.monkey_patch()

View File

@@ -14,10 +14,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log
from watcher.common.messaging.utils.synchronization import \
Synchronization
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -15,7 +15,7 @@
# limitations under the License.
from oslo_config import cfg
from watcher.openstack.common import log
from oslo_log import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -19,6 +19,8 @@ import socket
from oslo import messaging
from oslo_config import cfg
from oslo_log import _options
from oslo_log import log
from oslo_utils import importutils
from watcher.common import config
@@ -27,7 +29,6 @@ from watcher.common.i18n import _LI
from watcher.common import rpc
from watcher.objects import base as objects_base
from watcher.openstack.common import context
from watcher.openstack.common import log
from watcher.openstack.common import service
@@ -115,22 +116,16 @@ class RPCService(service.Service):
signal.signal(signal.SIGUSR1, self._handle_signal)
_DEFAULT_LOG_LEVELS = ['amqp=WARN', 'amqplib=WARN', 'qpid.messaging=INFO',
'oslo.messaging=INFO', 'sqlalchemy=WARN',
'keystoneclient=INFO', 'stevedore=INFO',
'eventlet.wsgi.server=WARN', 'iso8601=WARN',
'paramiko=WARN', 'requests=WARN', 'neutronclient=WARN',
'glanceclient=WARN', 'watcher.openstack.common=WARN']
def prepare_service(argv=[]):
config.parse_args(argv)
cfg.set_defaults(log.log_opts,
default_log_levels=['amqp=WARN',
'amqplib=WARN',
'qpid.messaging=INFO',
'oslo.messaging=INFO',
'sqlalchemy=WARN',
'keystoneclient=INFO',
'stevedore=INFO',
'eventlet.wsgi.server=WARN',
'iso8601=WARN',
'paramiko=WARN',
'requests=WARN',
'neutronclient=WARN',
'glanceclient=WARN',
'watcher.openstack.common=WARN',
])
log.setup('watcher')
cfg.set_defaults(_options.log_opts,
default_log_levels=_DEFAULT_LOG_LEVELS)
log.setup(cfg.CONF, 'watcher')

View File

@@ -17,6 +17,7 @@
"""Utilities and helper functions."""
from oslo_config import cfg
from oslo_log import log as logging
import re
import six
@@ -24,7 +25,6 @@ import uuid
from watcher.common.i18n import _LW
from watcher.openstack.common import log as logging
UTILS_OPTS = [
cfg.StrOpt('rootwrap_config',

View File

@@ -21,6 +21,7 @@ from oslo_config import cfg
from oslo_db import exception as db_exc
from oslo_db.sqlalchemy import session as db_session
from oslo_db.sqlalchemy import utils as db_utils
from oslo_log import log
from sqlalchemy.orm.exc import MultipleResultsFound
from sqlalchemy.orm.exc import NoResultFound
@@ -30,7 +31,6 @@ from watcher.db import api
from watcher.db.sqlalchemy import models
from watcher.objects.audit import AuditStatus
from watcher.openstack.common._i18n import _
from watcher.openstack.common import log
CONF = cfg.CONF

View File

@@ -13,6 +13,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log
from watcher.common.messaging.events.event import Event
from watcher.decision_engine.api.messaging.decision_engine_command import \
@@ -24,7 +25,6 @@ from watcher.decision_engine.framework.strategy.StrategyManagerImpl import \
from watcher.objects.audit import Audit
from watcher.objects.audit import AuditStatus
from watcher.objects.audit_template import AuditTemplate
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_log import log
from enum import Enum
from watcher.common.exception import MetaActionNotFound
@@ -31,7 +32,6 @@ from watcher.decision_engine.framework.meta_actions.power_state import \
ChangePowerState
from watcher.objects.action import Status as AStatus
from watcher.objects.action_plan import Status as APStatus
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -16,8 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_log import log
from watcher.decision_engine.api.solution.solution import Solution
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -19,6 +19,7 @@
from concurrent.futures import ThreadPoolExecutor
from oslo_config import cfg
from oslo_log import log
from watcher.decision_engine.framework.events.event_consumer_factory import \
EventConsumerFactory
@@ -33,7 +34,6 @@ from watcher.common.messaging.notification_handler import \
NotificationHandler
from watcher.decision_engine.framework.strategy.StrategyManagerImpl import \
StrategyContextImpl
from watcher.openstack.common import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -16,10 +16,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_log import log
from watcher.decision_engine.framework.command.trigger_audit_command import \
TriggerAuditCommand
from watcher.metrics_engine.framework.collector_manager import CollectorManager
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -13,10 +13,9 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log
from threading import Lock
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -13,6 +13,7 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log
from watcher.common.exception import HypervisorNotFound
from watcher.common.exception import IllegalArgumentException
@@ -20,7 +21,6 @@ from watcher.common.exception import VMNotFound
from watcher.decision_engine.framework.model.hypervisor import Hypervisor
from watcher.decision_engine.framework.model.mapping import Mapping
from watcher.decision_engine.framework.model.vm import VM
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -19,6 +19,7 @@
from oslo_config import cfg
from oslo_log import log
import oslo_messaging as om
from watcher.common import exception
@@ -38,8 +39,6 @@ from watcher.decision_engine.framework.manager_decision_engine import \
from watcher.decision_engine.framework.messaging.events import Events
from watcher.openstack.common import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -13,13 +13,13 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log
from watcher.decision_engine.api.strategy.strategy_context import \
StrategyContext
from watcher.decision_engine.framework.default_planner import DefaultPlanner
from watcher.decision_engine.framework.strategy.strategy_selector import \
StrategySelector
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -17,10 +17,10 @@
# limitations under the License.
#
from oslo_config import cfg
from oslo_log import log
from stevedore import driver
from watcher.decision_engine.strategies.basic_consolidation import \
BasicConsolidation
from watcher.openstack.common import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -15,11 +15,11 @@
# limitations under the License.
from oslo_config import cfg
from oslo_log import log
from watcher.decision_engine.api.strategy.selector import Selector
from watcher.decision_engine.framework.strategy.strategy_loader import \
StrategyLoader
from watcher.objects.audit_template import Goal
from watcher.openstack.common import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -16,6 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_log import log
from watcher.decision_engine.framework.model.vm_state import VMState
from watcher.metrics_engine.api.metrics_resource_collector import \
AggregationFunction
@@ -38,7 +40,6 @@ from watcher.decision_engine.framework.meta_actions.power_state import \
from watcher.decision_engine.framework.model.hypervisor_state import \
HypervisorState
from watcher.decision_engine.framework.model.resource import ResourceType
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -16,9 +16,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from oslo_log import log
from watcher.decision_engine.api.strategy.strategy import Strategy
from watcher.openstack.common import log
LOG = log.getLogger(__name__)

View File

@@ -20,11 +20,11 @@ from keystoneclient.auth.identity import v3
from keystoneclient import session
from oslo_config import cfg
from oslo_log import log
from stevedore import driver
from watcher.applier.framework.command.wrapper.nova_wrapper import NovaWrapper
from watcher.metrics_engine.framework.statedb_collector import NovaCollector
from watcher.openstack.common import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -23,6 +23,7 @@ import parsedatetime
from influxdb import InfluxDBClient
from oslo_config import cfg
from oslo_log import log
from watcher.metrics_engine.api.metrics_resource_collector import \
AggregationFunction
from watcher.metrics_engine.api.metrics_resource_collector import Measure
@@ -33,7 +34,6 @@ from watcher.metrics_engine.framework.datasources.sql_ast.build_db_query import
from watcher.metrics_engine.framework.datasources.sql_ast.sql_ast import And
from watcher.metrics_engine.framework.datasources.sql_ast.sql_ast import \
Condition
from watcher.openstack.common import log
LOG = log.getLogger(__name__)
CONF = cfg.CONF

View File

@@ -19,6 +19,8 @@
from oslo_config import cfg
from oslo_log import log
from watcher.decision_engine.framework.model.hypervisor import Hypervisor
from watcher.decision_engine.framework.model.model_root import ModelRoot
from watcher.decision_engine.framework.model.resource import Resource
@@ -26,7 +28,6 @@ from watcher.decision_engine.framework.model.resource import ResourceType
from watcher.decision_engine.framework.model.vm import VM
from watcher.metrics_engine.api.cluster_state_collector import \
ClusterStateCollector
from watcher.openstack.common import log
CONF = cfg.CONF
LOG = log.getLogger(__name__)

View File

@@ -17,6 +17,7 @@
import collections
import copy
from oslo_log import log as logging
import oslo_messaging as messaging
import six
@@ -24,7 +25,6 @@ from watcher.common import exception
from watcher.common.i18n import _
from watcher.common.i18n import _LE
from watcher.objects import utils as obj_utils
from watcher.openstack.common import log as logging
from watcher.openstack.common import versionutils

View File

@@ -16,12 +16,12 @@
# limitations under the License.
import itertools
from oslo_log import _options
import watcher.api.app
from watcher.applier.framework import manager_applier
import watcher.common.messaging.messaging_core
import watcher.openstack.common.log
from watcher.decision_engine.framework import manager_decision_engine
from watcher.decision_engine.framework.strategy import strategy_loader
@@ -33,10 +33,10 @@ from watcher.metrics_engine.framework.datasources import influxdb_collector
def list_opts():
return [
('DEFAULT', itertools.chain(
watcher.openstack.common.log.generic_log_opts,
watcher.openstack.common.log.log_opts,
watcher.openstack.common.log.common_cli_opts,
watcher.openstack.common.log.logging_cli_opts
_options.generic_log_opts,
_options.log_opts,
_options.common_cli_opts,
_options.logging_cli_opts
)),
('api', watcher.api.app.API_SERVICE_OPTS),
('watcher_messaging',