Standardize logging delaration and use

* Make modules use getLogger(__name__) and log to the result

Change-Id: Ib6d69b4be140ec89affc86ed11e65e422d551df1
This commit is contained in:
Jason Kölker 2012-02-14 12:07:02 -06:00
parent b3ade08a21
commit c9ca372b0b
219 changed files with 325 additions and 269 deletions

View File

@ -35,6 +35,7 @@ use_forwarded_for_opt = cfg.BoolOpt('use_forwarded_for',
FLAGS = flags.FLAGS
FLAGS.register_opt(use_forwarded_for_opt)
LOG = logging.getLogger(__name__)
class InjectContext(wsgi.Middleware):
@ -58,7 +59,7 @@ class NovaKeystoneContext(wsgi.Middleware):
user_id = req.headers.get('X_USER')
user_id = req.headers.get('X_USER_ID', user_id)
if user_id is None:
logging.debug("Neither X_USER_ID nor X_USER found in request")
LOG.debug("Neither X_USER_ID nor X_USER found in request")
return webob.exc.HTTPUnauthorized()
# get the roles
roles = [r.strip() for r in req.headers.get('X_ROLE', '').split(',')]

View File

@ -41,7 +41,7 @@ from nova import utils
from nova import wsgi
LOG = logging.getLogger("nova.api")
LOG = logging.getLogger(__name__)
ec2_opts = [
cfg.IntOpt('lockout_attempts',

View File

@ -29,7 +29,7 @@ from nova import exception
from nova import flags
from nova import log as logging
LOG = logging.getLogger("nova.api.request")
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -48,7 +48,7 @@ from nova import volume
FLAGS = flags.FLAGS
flags.DECLARE('dhcp_domain', 'nova.network.manager')
LOG = logging.getLogger("nova.api.ec2.cloud")
LOG = logging.getLogger(__name__)
def _gen_key(context, user_id, key_name):

View File

@ -26,7 +26,7 @@ from nova.network import model as network_model
FLAGS = flags.FLAGS
LOG = logging.getLogger("nova.api.ec2.ec2utils")
LOG = logging.getLogger(__name__)
def image_type(image_type):

View File

@ -36,7 +36,7 @@ from nova import volume
from nova import wsgi
LOG = logging.getLogger('nova.api.metadata')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS
flags.DECLARE('use_forwarded_for', 'nova.api.auth')
flags.DECLARE('dhcp_domain', 'nova.network.manager')

View File

@ -29,7 +29,7 @@ from nova import log as logging
from nova import wsgi as base_wsgi
LOG = logging.getLogger('nova.api.openstack')
LOG = logging.getLogger(__name__)
class FaultWrapper(base_wsgi.Middleware):

View File

@ -32,7 +32,7 @@ from nova import log as logging
from nova import utils
from nova import wsgi as base_wsgi
LOG = logging.getLogger('nova.api.openstack.compute.auth')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS
flags.DECLARE('use_forwarded_for', 'nova.api.auth')

View File

@ -35,7 +35,7 @@ from nova.network import model as network_model
from nova import quota
LOG = logging.getLogger('nova.api.openstack.common')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -36,7 +36,7 @@ from nova import log as logging
from nova.openstack.common import cfg
LOG = logging.getLogger('nova.api.openstack.compute')
LOG = logging.getLogger(__name__)
allow_instance_snapshots_opt = \
cfg.BoolOpt('allow_instance_snapshots',

View File

@ -27,7 +27,7 @@ from nova.api.openstack import extensions
FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.api.openstack.compute.contrib')
LOG = logging.getLogger(__name__)
def standard_extensions(ext_mgr):

View File

@ -25,7 +25,7 @@ from nova import log as logging
FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.api.openstack.compute.contrib.accounts')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'accounts')

View File

@ -29,7 +29,7 @@ from nova.scheduler import api as scheduler_api
FLAGS = flags.FLAGS
LOG = logging.getLogger("nova.api.openstack.compute.contrib.admin_actions")
LOG = logging.getLogger(__name__)
def authorize(context, action_name):

View File

@ -23,7 +23,7 @@ from nova import exception
from nova import log as logging
LOG = logging.getLogger("nova.api.openstack.compute.contrib.host_aggregates")
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'aggregates')

View File

@ -25,7 +25,7 @@ from nova import network
from nova import rpc
LOG = logging.getLogger('nova.api.openstack.compute.contrib.certificates')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS
authorize = extensions.extension_authorizer('compute', 'certificates')

View File

@ -31,7 +31,7 @@ from nova import utils
FLAGS = flags.FLAGS
LOG = logging.getLogger("nova.api.openstack.compute.contrib.cloudpipe")
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'cloudpipe')

View File

@ -25,7 +25,7 @@ from nova.api.openstack import extensions
from nova.api.openstack import wsgi
LOG = logging.getLogger('nova.api.openstack.compute.contrib.console_output')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'console_output')

View File

@ -23,7 +23,7 @@ from nova.api.openstack import extensions
from nova.api.openstack import wsgi
LOG = logging.getLogger('nova.api.openstack.compute.contrib.console')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'consoles')

View File

@ -25,7 +25,7 @@ from nova import exception
from nova import log as logging
LOG = logging.getLogger("nova.api.openstack.compute.contrib.deferred-delete")
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'deferred_delete')

View File

@ -26,7 +26,7 @@ from nova import log as logging
FLAGS = flags.FLAGS
LOG = logging.getLogger("nova.api.openstack.compute.contrib.extendedstatus")
LOG = logging.getLogger(__name__)
authorize = extensions.soft_extension_authorizer('compute', 'extended_status')

View File

@ -23,7 +23,7 @@ from nova import exception
from nova import log as logging
LOG = logging.getLogger('nova.api.openstack.compute.contrib.flavormanage')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'flavormanage')

View File

@ -26,7 +26,7 @@ from nova import log as logging
from nova import network
LOG = logging.getLogger('nova.api.openstack.compute.contrib.floating_ip_dns')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'floating_ip_dns')

View File

@ -21,7 +21,7 @@ from nova import log as logging
from nova import network
LOG = logging.getLogger('nova.api.openstack.compute.contrib.floating_ip_pools')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'floating_ip_pools')

View File

@ -29,7 +29,7 @@ from nova import network
from nova import rpc
LOG = logging.getLogger('nova.api.openstack.compute.contrib.floating_ips')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'floating_ips')

View File

@ -30,7 +30,7 @@ from nova import log as logging
from nova.scheduler import api as scheduler_api
LOG = logging.getLogger("nova.api.openstack.compute.contrib.hosts")
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS
authorize = extensions.extension_authorizer('compute', 'hosts')

View File

@ -25,7 +25,7 @@ from nova import exception
from nova import log as logging
LOG = logging.getLogger("nova.api.openstack.compute.contrib.multinic")
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'multinic')

View File

@ -27,7 +27,7 @@ import nova.network.api
FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.api.openstack.compute.contrib.networks')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'networks')

View File

@ -27,7 +27,7 @@ from nova import utils
FLAGS = flags.FLAGS
LOG = logging.getLogger("nova.api.openstack.compute.contrib.rescue")
LOG = logging.getLogger(__name__)
authorize = exts.extension_authorizer('compute', 'rescue')

View File

@ -20,7 +20,7 @@ from nova.api.openstack import extensions
from nova.api.openstack import wsgi
import nova.log as logging
LOG = logging.getLogger('nova.api.openstack.compute.contrib.scheduler_hints')
LOG = logging.getLogger(__name__)
class SchedulerHintsController(wsgi.Controller):

View File

@ -33,7 +33,7 @@ from nova import log as logging
from nova import utils
LOG = logging.getLogger("nova.api.openstack.compute.contrib.security_groups")
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS
authorize = extensions.extension_authorizer('compute', 'security_groups')

View File

@ -23,7 +23,7 @@ from nova import exception
from nova import log as logging
LOG = logging.getLogger('nova.api.openstack.compute.contrib.server_start_stop')
LOG = logging.getLogger(__name__)
class ServerStartStopActionController(wsgi.Controller):

View File

@ -26,7 +26,7 @@ from nova import log as logging
FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.api.openstack.users')
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'users')

View File

@ -24,8 +24,7 @@ from nova import log as logging
from nova import network
LOG = logging.getLogger("nova.api.openstack.compute."
"contrib.virtual_interfaces")
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute', 'virtual_interfaces')

View File

@ -38,7 +38,7 @@ from nova import volume
FLAGS = flags.FLAGS
LOG = logging.getLogger("nova.api.openstack.compute.contrib.vsa")
LOG = logging.getLogger(__name__)
authorize = extensions.extension_authorizer('compute',
'virtual_storage_arrays')

View File

@ -31,7 +31,7 @@ from nova import volume
from nova.volume import volume_types
LOG = logging.getLogger("nova.api.openstack.compute.contrib.volumes")
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS
authorize = extensions.extension_authorizer('compute', 'volumes')

View File

@ -32,7 +32,7 @@ from nova import log as logging
import nova.scheduler.api
LOG = logging.getLogger("nova.api.openstack.compute.contrib.zones")
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS
authorize = extensions.extension_authorizer('compute', 'zones')

View File

@ -20,7 +20,7 @@ from nova import flags
from nova import log as logging
LOG = logging.getLogger('nova.api.openstack.compute.extensions')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -23,11 +23,11 @@ from nova import compute
from nova import exception
from nova import flags
import nova.image
from nova import log
from nova import log as logging
import nova.utils
LOG = log.getLogger('nova.api.openstack.compute.images')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS
SUPPORTED_FILTERS = {

View File

@ -26,7 +26,7 @@ from nova import log as logging
from nova import flags
LOG = logging.getLogger('nova.api.openstack.compute.ips')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -37,7 +37,7 @@ from nova.scheduler import api as scheduler_api
from nova import utils
LOG = logging.getLogger('nova.api.openstack.compute.servers')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -23,7 +23,7 @@ from nova import log as logging
FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.api.openstack.compute.views.addresses')
LOG = logging.getLogger(__name__)
class ViewBuilder(common.ViewBuilder):

View File

@ -26,7 +26,7 @@ from nova import log as logging
from nova import utils
LOG = logging.getLogger('nova.api.openstack.compute.views.servers')
LOG = logging.getLogger(__name__)
class ViewBuilder(common.ViewBuilder):

View File

@ -34,7 +34,7 @@ from nova import utils
from nova import wsgi as base_wsgi
LOG = logging.getLogger('nova.api.openstack.extensions')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -28,7 +28,7 @@ _option_header_piece_re = re.compile(r';\s*([^\s;=]+|%s)\s*'
r'(?:=\s*([^;]+|%s))?\s*' %
(_quoted_string_re, _quoted_string_re))
LOG = logging.getLogger('nova.api.openstack.compute.map')
LOG = logging.getLogger(__name__)
def unquote_header_value(value):

View File

@ -29,7 +29,7 @@ from nova.api.openstack.volume import versions
from nova import log as logging
LOG = logging.getLogger('nova.api.openstack.volume')
LOG = logging.getLogger(__name__)
class APIRouter(nova.api.openstack.APIRouter):

View File

@ -27,7 +27,7 @@ from nova.api.openstack import extensions
FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.api.openstack.volume.contrib')
LOG = logging.getLogger(__name__)
def standard_extensions(ext_mgr):

View File

@ -20,7 +20,7 @@ from nova import flags
from nova import log as logging
LOG = logging.getLogger('nova.api.openstack.volume.extensions')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -27,7 +27,7 @@ from nova import log as logging
from nova import volume
LOG = logging.getLogger("nova.api.openstack.volume.snapshots")
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -28,7 +28,7 @@ from nova import volume
from nova.volume import volume_types
LOG = logging.getLogger("nova.api.openstack.volume.volumes")
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -34,7 +34,7 @@ XMLNS_V11 = 'http://docs.openstack.org/compute/api/v1.1'
XMLNS_ATOM = 'http://www.w3.org/2005/Atom'
LOG = logging.getLogger('nova.api.openstack.wsgi')
LOG = logging.getLogger(__name__)
# The vendor content types should serialize identically to the non-vendor
# content types. So to avoid littering the code with both options, we

View File

@ -23,7 +23,7 @@ import socket
from nova import exception
LOG = logging.getLogger("nova.api.validator")
LOG = logging.getLogger(__name__)
def _get_path_validator_regex():

View File

@ -90,7 +90,7 @@ ldap_opts = [
FLAGS = flags.FLAGS
FLAGS.register_opts(ldap_opts)
LOG = logging.getLogger("nova.ldapdriver")
LOG = logging.getLogger(__name__)
if FLAGS.memcached_servers:

View File

@ -96,7 +96,7 @@ FLAGS.register_opts(auth_opts)
flags.DECLARE('osapi_compute_listen_port', 'nova.service')
LOG = logging.getLogger('nova.auth.manager')
LOG = logging.getLogger(__name__)
if FLAGS.memcached_servers:

View File

@ -57,7 +57,7 @@ from nova import exception
from nova import log as logging
LOG = logging.getLogger('nova.signer')
LOG = logging.getLogger(__name__)
class Signer(object):

View File

@ -30,7 +30,7 @@ from nova import flags
from nova import log as logging
from nova import manager
LOG = logging.getLogger('nova.cert.manager')
LOG = logging.getLogger(__name__)
FLAGS = flags.FLAGS

View File

@ -56,7 +56,7 @@ FLAGS = flags.FLAGS
FLAGS.register_opts(cloudpipe_opts)
LOG = logging.getLogger('nova.cloudpipe')
LOG = logging.getLogger(__name__)
class CloudPipe(object):

View File

@ -48,7 +48,7 @@ from nova import utils
from nova import volume
LOG = logging.getLogger('nova.compute.api')
LOG = logging.getLogger(__name__)
find_host_timeout_opt = cfg.StrOpt('find_host_timeout',
default=30,

View File

@ -27,7 +27,7 @@ from nova import flags
from nova import log as logging
FLAGS = flags.FLAGS
LOG = logging.getLogger('nova.instance_types')
LOG = logging.getLogger(__name__)
def create(name, memory, vcpus, root_gb, ephemeral_gb, flavorid, swap=None,

View File

@ -121,7 +121,7 @@ compute_opts = [
FLAGS = flags.FLAGS
FLAGS.register_opts(compute_opts)
LOG = logging.getLogger('nova.compute.manager')
LOG = logging.getLogger(__name__)
def publisher_id(host=None):

View File

@ -42,6 +42,7 @@ console_manager_opts = [
FLAGS = flags.FLAGS
FLAGS.register_opts(console_manager_opts)
LOG = logging.getLogger(__name__)
class ConsoleProxyManager(manager.Manager):
@ -73,7 +74,7 @@ class ConsoleProxyManager(manager.Manager):
pool['id'],
instance_id)
except exception.NotFound:
logging.debug(_('Adding console'))
LOG.debug(_('Adding console'))
if not password:
password = utils.generate_password(8)
if not port:
@ -93,7 +94,7 @@ class ConsoleProxyManager(manager.Manager):
try:
console = self.db.console_get(context, console_id)
except exception.NotFound:
logging.debug(_('Tried to remove non-existant console '
LOG.debug(_('Tried to remove non-existant console '
'%(console_id)s.') %
{'console_id': console_id})
return

View File

@ -27,7 +27,7 @@ from nova import utils
from nova.virt import vmwareapi_conn
LOG = logging.getLogger("nova.console.vmrc_manager")
LOG = logging.getLogger(__name__)
vmrc_manager_opts = [
cfg.StrOpt('console_public_hostname',

View File

@ -51,6 +51,7 @@ xvp_opts = [
FLAGS = flags.FLAGS
FLAGS.register_opts(xvp_opts)
LOG = logging.getLogger(__name__)
class XVPConsoleProxy(object):
@ -94,13 +95,13 @@ class XVPConsoleProxy(object):
return self._xvp_encrypt(password)
def _rebuild_xvp_conf(self, context):
logging.debug(_('Rebuilding xvp conf'))
LOG.debug(_('Rebuilding xvp conf'))
pools = [pool for pool in
db.console_pool_get_all_by_host_type(context, self.host,
self.console_type)
if pool['consoles']]
if not pools:
logging.debug('No console pools!')
LOG.debug('No console pools!')
self._xvp_stop()
return
conf_data = {'multiplex_port': FLAGS.console_xvp_multiplex_port,
@ -112,12 +113,12 @@ class XVPConsoleProxy(object):
self._xvp_restart()
def _write_conf(self, config):
logging.debug(_('Re-wrote %s') % FLAGS.console_xvp_conf)
LOG.debug(_('Re-wrote %s') % FLAGS.console_xvp_conf)
with open(FLAGS.console_xvp_conf, 'w') as cfile:
cfile.write(config)
def _xvp_stop(self):
logging.debug(_('Stopping xvp'))
LOG.debug(_('Stopping xvp'))
pid = self._xvp_pid()
if not pid:
return
@ -130,19 +131,19 @@ class XVPConsoleProxy(object):
def _xvp_start(self):
if self._xvp_check_running():
return
logging.debug(_('Starting xvp'))
LOG.debug(_('Starting xvp'))
try:
utils.execute('xvp',
'-p', FLAGS.console_xvp_pid,
'-c', FLAGS.console_xvp_conf,
'-l', FLAGS.console_xvp_log)
except exception.ProcessExecutionError, err:
logging.error(_('Error starting xvp: %s') % err)
LOG.error(_('Error starting xvp: %s') % err)
def _xvp_restart(self):
logging.debug(_('Restarting xvp'))
LOG.debug(_('Restarting xvp'))
if not self._xvp_check_running():
logging.debug(_('xvp not running...'))
LOG.debug(_('xvp not running...'))
self._xvp_start()
else:
pid = self._xvp_pid()

View File

@ -29,7 +29,7 @@ from nova.openstack.common import cfg
from nova import utils
LOG = logging.getLogger('nova.consoleauth')
LOG = logging.getLogger(__name__)
consoleauth_opts = [
cfg.IntOpt('console_token_ttl',

View File

@ -42,7 +42,7 @@ from nova.openstack.common import cfg
from nova import utils
LOG = logging.getLogger("nova.crypto")
LOG = logging.getLogger(__name__)
crypto_opts = [
cfg.StrOpt('ca_file',

View File

@ -47,7 +47,7 @@ FLAGS = flags.FLAGS
flags.DECLARE('reserved_host_disk_mb', 'nova.scheduler.host_manager')
flags.DECLARE('reserved_host_memory_mb', 'nova.scheduler.host_manager')
LOG = logging.getLogger("nova.db.sqlalchemy")
LOG = logging.getLogger(__name__)
def is_admin_context(context):

View File

@ -23,6 +23,7 @@ from sqlalchemy import Table, Text
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
auth_tokens = Table('auth_tokens', meta,
Column('created_at', DateTime(timezone=False)),
@ -516,8 +517,8 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
logging.exception('Exception while creating table')
LOG.info(repr(table))
LOG.exception('Exception while creating table')
meta.drop_all(tables=tables)
raise

View File

@ -21,6 +21,7 @@ from sqlalchemy import Integer, MetaData, String, Table, Text
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Just for the ForeignKey and column creation to succeed, these are not the
# actual definitions of instances or services.
@ -213,8 +214,8 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
logging.exception('Exception while creating table')
LOG.info(repr(table))
LOG.exception('Exception while creating table')
meta.drop_all(tables=tables)
raise

View File

@ -18,6 +18,7 @@ from sqlalchemy import MetaData, String, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
#
# New Tables
@ -55,4 +56,4 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
LOG.info(repr(table))

View File

@ -19,7 +19,10 @@ from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer
from sqlalchemy import MetaData, String, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Just for the ForeignKey and column creation to succeed, these are not the
# actual definitions of instances or services.
@ -68,8 +71,8 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
logging.exception('Exception while creating table')
LOG.info(repr(table))
LOG.exception('Exception while creating table')
raise
quotas.create_column(quota_metadata_items)

View File

@ -18,6 +18,7 @@ from sqlalchemy import MetaData, String, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
#
@ -50,8 +51,8 @@ def upgrade(migrate_engine):
try:
instance_types.create()
except Exception:
logging.info(repr(instance_types))
logging.exception('Exception while creating instance_types table')
LOG.info(repr(instance_types))
LOG.exception('Exception while creating instance_types table')
raise
# Here are the old static instance types
@ -71,8 +72,8 @@ def upgrade(migrate_engine):
'local_gb': values["local_gb"],
'flavorid': values["flavorid"]})
except Exception:
logging.info(repr(instance_types))
logging.exception('Exception while seeding instance_types table')
LOG.info(repr(instance_types))
LOG.exception('Exception while seeding instance_types table')
raise

View File

@ -20,6 +20,7 @@ from sqlalchemy import MetaData, String, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Just for the ForeignKey and column creation to succeed, these are not the
# actual definitions of instances or services.
@ -54,6 +55,6 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
logging.exception('Exception while creating table')
LOG.info(repr(table))
LOG.exception('Exception while creating table')
raise

View File

@ -21,6 +21,7 @@ from sqlalchemy import Table, Text
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
instances = Table('instances', meta,
Column('id', Integer(), primary_key=True, nullable=False),
@ -74,8 +75,8 @@ def upgrade(migrate_engine):
try:
compute_nodes.create()
except Exception:
logging.info(repr(compute_nodes))
logging.exception('Exception while creating table')
LOG.info(repr(compute_nodes))
LOG.exception('Exception while creating table')
meta.drop_all(tables=[compute_nodes])
raise

View File

@ -1,7 +1,25 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from sqlalchemy import Column, Integer, MetaData, String, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
def upgrade(migrate_engine):
@ -17,7 +35,7 @@ def upgrade(migrate_engine):
try:
types[instance.id] = int(instance.instance_type_id)
except ValueError:
logging.warn("Instance %s did not have instance_type_id "
LOG.warn("Instance %s did not have instance_type_id "
"converted to an integer because its value is %s" %
(instance.id, instance.instance_type_id))
types[instance.id] = None

View File

@ -20,7 +20,10 @@ from sqlalchemy import Integer, DateTime, Boolean, String
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
snapshots = Table('snapshots', meta,
Column('created_at', DateTime(timezone=False)),
@ -59,8 +62,8 @@ def upgrade(migrate_engine):
try:
snapshots.create()
except Exception:
logging.info(repr(snapshots))
logging.exception('Exception while creating table')
LOG.info(repr(snapshots))
LOG.exception('Exception while creating table')
meta.drop_all(tables=[snapshots])
raise

View File

@ -19,6 +19,7 @@ from sqlalchemy import ForeignKey
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Just for the ForeignKey and column creation to succeed, these are not the
# actual definitions of instances or services.
@ -76,8 +77,8 @@ def upgrade(migrate_engine):
try:
block_device_mapping.create()
except Exception:
logging.info(repr(block_device_mapping))
logging.exception('Exception while creating table')
LOG.info(repr(block_device_mapping))
LOG.exception('Exception while creating table')
meta.drop_all(tables=[block_device_mapping])
raise

View File

@ -17,7 +17,10 @@ from sqlalchemy import Boolean, Column, DateTime, Integer
from sqlalchemy import MetaData, String, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
#
# New Tables
@ -64,7 +67,7 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
LOG.info(repr(table))
instances = Table('instances', meta, autoload=True,
autoload_with=migrate_engine)

View File

@ -23,6 +23,7 @@ from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Just for the ForeignKey and column creation to succeed, these are not the
@ -69,6 +70,6 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
logging.exception('Exception while creating table')
LOG.info(repr(table))
LOG.exception('Exception while creating table')
raise

View File

@ -19,6 +19,7 @@ from sqlalchemy import MetaData, String, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Just for the ForeignKey and column creation to succeed, these are not the
# actual definitions of instances or services.
@ -56,8 +57,8 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
logging.exception('Exception while creating table')
LOG.info(repr(table))
LOG.exception('Exception while creating table')
raise

View File

@ -19,6 +19,7 @@ from migrate import *
from nova import log as logging
from nova import utils
LOG = logging.getLogger(__name__)
meta = MetaData()
# virtual interface table to add to DB
@ -71,21 +72,21 @@ def upgrade(migrate_engine):
try:
networks.create_column(interface)
except Exception:
logging.error(_("interface column not added to networks table"))
LOG.error(_("interface column not added to networks table"))
raise
# create virtual_interfaces table
try:
virtual_interfaces.create()
except Exception:
logging.error(_("Table |%s| not created!"), repr(virtual_interfaces))
LOG.error(_("Table |%s| not created!"), repr(virtual_interfaces))
raise
# add virtual_interface_id column to fixed_ips table
try:
fixed_ips.create_column(virtual_interface_id)
except Exception:
logging.error(_("VIF column not added to fixed_ips table"))
LOG.error(_("VIF column not added to fixed_ips table"))
raise
# populate the virtual_interfaces table
@ -95,7 +96,7 @@ def upgrade(migrate_engine):
fixed_ips.c.instance_id == instances.c.id)
keys = ('instance_id', 'address', 'network_id')
join_list = [dict(zip(keys, row)) for row in s.execute()]
logging.debug(_("join list for moving mac_addresses |%s|"), join_list)
LOG.debug(_("join list for moving mac_addresses |%s|"), join_list)
# insert data into the table
if join_list:
@ -119,5 +120,5 @@ def upgrade(migrate_engine):
def downgrade(migrate_engine):
logging.error(_("Can't downgrade without losing data"))
LOG.error(_("Can't downgrade without losing data"))
raise Exception

View File

@ -19,6 +19,7 @@ from migrate import *
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
def upgrade(migrate_engine):
@ -35,7 +36,7 @@ def upgrade(migrate_engine):
ForeignKeyConstraint(columns=[fixed_ips.c.virtual_interface_id],
refcolumns=[virtual_interfaces.c.id]).create()
except Exception:
logging.error(_("foreign key constraint couldn't be added"))
LOG.error(_("foreign key constraint couldn't be added"))
raise
@ -49,5 +50,5 @@ def downgrade(migrate_engine):
ForeignKeyConstraint(columns=[fixed_ips.c.virtual_interface_id],
refcolumns=[virtual_interfaces.c.id]).drop()
except Exception:
logging.error(_("foreign key constraint couldn't be dropped"))
LOG.error(_("foreign key constraint couldn't be dropped"))
raise

View File

@ -21,6 +21,8 @@ from sqlalchemy import Boolean, ForeignKey
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Just for the ForeignKey and column creation to succeed, these are not the
# actual definitions of tables .
@ -99,8 +101,8 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
logging.exception('Exception while creating table')
LOG.info(repr(table))
LOG.exception('Exception while creating table')
raise
volumes.create_column(volume_type_id)

View File

@ -21,6 +21,7 @@ from sqlalchemy import Boolean
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
#
# New Tables
@ -64,8 +65,8 @@ def upgrade(migrate_engine):
try:
virtual_storage_arrays.create()
except Exception:
logging.info(repr(table))
logging.exception('Exception while creating table')
LOG.info(repr(virtual_storage_arrays))
LOG.exception('Exception while creating table')
raise

View File

@ -20,6 +20,8 @@ from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
networks = Table('networks', meta,
Column("id", Integer(), primary_key=True, nullable=False))
@ -34,7 +36,7 @@ def upgrade(migrate_engine):
try:
networks.create_column(priority)
except Exception:
logging.error(_("priority column not added to networks table"))
LOG.error(_("priority column not added to networks table"))
raise

View File

@ -17,7 +17,9 @@ from migrate import ForeignKeyConstraint
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
def upgrade(migrate_engine):
@ -38,7 +40,7 @@ def upgrade(migrate_engine):
name=fkey_name).drop()
except Exception:
logging.error(_("foreign key constraint couldn't be removed"))
LOG.error(_("foreign key constraint couldn't be removed"))
raise
@ -56,5 +58,5 @@ def downgrade(migrate_engine):
ForeignKeyConstraint(columns=[vifs.c.instance_id],
refcolumns=[instances.c.id]).create()
except Exception:
logging.error(_("foreign key constraint couldn't be added"))
LOG.error(_("foreign key constraint couldn't be added"))
raise

View File

@ -20,6 +20,7 @@ from migrate import *
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
instances = Table('instances', meta,
Column("id", Integer(), primary_key=True, nullable=False))
@ -34,7 +35,7 @@ def upgrade(migrate_engine):
try:
instances.create_column(progress)
except Exception:
logging.error(_("progress column not added to instances table"))
LOG.error(_("progress column not added to instances table"))
raise

View File

@ -19,6 +19,8 @@ from sqlalchemy import MetaData, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Table definition
volumes = Table('volumes', meta,
@ -45,8 +47,8 @@ def downgrade(migrate_engine):
try:
export_devices.create()
except Exception:
logging.info(repr(export_devices))
logging.exception('Exception while creating table')
LOG.info(repr(export_devices))
LOG.exception('Exception while creating table')
raise

View File

@ -21,6 +21,8 @@ from sqlalchemy import Integer, BigInteger, DateTime, Boolean, String
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
bw_cache = Table('bw_usage_cache', meta,
Column('created_at', DateTime(timezone=False)),
@ -46,8 +48,8 @@ def upgrade(migrate_engine):
try:
bw_cache.create()
except Exception:
logging.info(repr(bw_cache))
logging.exception('Exception while creating table')
LOG.info(repr(bw_cache))
LOG.exception('Exception while creating table')
meta.drop_all(tables=[bw_cache])
raise

View File

@ -22,7 +22,7 @@ import sqlalchemy
from nova import log as logging
LOG = logging.getLogger('nova.db.sqlalchemy.migrate_repo.versions')
LOG = logging.getLogger(__name__)
meta = sqlalchemy.MetaData()

View File

@ -21,6 +21,7 @@ from nova import log as logging
meta = sqlalchemy.MetaData()
LOG = logging.getLogger(__name__)
s3_images = sqlalchemy.Table('s3_images', meta,
@ -46,7 +47,7 @@ def upgrade(migrate_engine):
try:
s3_images.create()
except Exception:
logging.exception("Exception while creating table 's3_images'")
LOG.exception("Exception while creating table 's3_images'")
meta.drop_all(tables=[s3_images])
raise

View File

@ -19,6 +19,8 @@ from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Table stub-definitions
# Just for the ForeignKey and column creation to succeed, these are not the
@ -95,7 +97,7 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.info(repr(table))
LOG.info(repr(table))
def downgrade(migrate_engine):
@ -104,4 +106,4 @@ def downgrade(migrate_engine):
try:
table.drop()
except Exception:
logging.info(repr(table))
LOG.info(repr(table))

View File

@ -18,6 +18,7 @@ from migrate import ForeignKeyConstraint
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
def upgrade(migrate_engine):
@ -38,7 +39,7 @@ def upgrade(migrate_engine):
name=fkey_name).drop()
except Exception:
logging.error(_("foreign key constraint couldn't be removed"))
LOG.error(_("foreign key constraint couldn't be removed"))
raise
@ -56,5 +57,5 @@ def downgrade(migrate_engine):
ForeignKeyConstraint(columns=[vifs.c.network_id],
refcolumns=[networks.c.id]).create()
except Exception:
logging.error(_("foreign key constraint couldn't be added"))
LOG.error(_("foreign key constraint couldn't be added"))
raise

View File

@ -20,6 +20,8 @@ from nova import log as logging
from nova import utils
meta = MetaData()
LOG = logging.getLogger(__name__)
# instance info cache table to add to DB
instance_info_caches = Table('instance_info_caches', meta,
@ -48,7 +50,7 @@ def upgrade(migrate_engine):
try:
instance_info_caches.create()
except Exception:
logging.error(_("Table |%s| not created!"), repr(instance_info_caches))
LOG.error(_("Table |%s| not created!"), repr(instance_info_caches))
raise
@ -56,5 +58,5 @@ def downgrade(migrate_engine):
try:
instance_info_caches.drop()
except Exception:
logging.error(_("instance_info_caches tables not dropped"))
LOG.error(_("instance_info_caches tables not dropped"))
raise

View File

@ -18,6 +18,7 @@ from sqlalchemy import MetaData, String, Table, Text
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
#
# New Tables
@ -54,7 +55,7 @@ def upgrade(migrate_engine):
try:
instance_faults.create()
except Exception:
logging.info(repr(instance_faults))
LOG.info(repr(instance_faults))
def downgrade(migrate_engine):

View File

@ -22,7 +22,7 @@ from migrate import ForeignKeyConstraint
from nova import log as logging
LOG = logging.getLogger('nova.db.sqlalchemy.migrate_repo.versions')
LOG = logging.getLogger(__name__)
meta = sqlalchemy.MetaData()
@ -57,7 +57,7 @@ def upgrade(migrate_engine):
refcolumns=[instances.c.id],
name=fkey_name).drop()
except:
logging.error(_("foreign key constraint couldn't be removed"))
LOG.error(_("foreign key constraint couldn't be removed"))
raise
instance_actions.c.instance_id.drop()

View File

@ -23,6 +23,7 @@ from nova import log as logging
from nova import utils
meta = MetaData()
LOG = logging.getLogger(__name__)
def upgrade(migrate_engine):
@ -192,20 +193,20 @@ def upgrade(migrate_engine):
# preload caches table
# list is made up of a row(instance_id, nw_info_json) for each instance
for instance in get_instances():
logging.info("Updating %s" % (instance['uuid']))
LOG.info("Updating %s" % (instance['uuid']))
instance_id = instance['id']
instance_uuid = instance['uuid']
# instances have vifs so aninstance nw_info is
# is a list of dicts, 1 dict for each vif
nw_info = get_vifs_by_instance_id(instance_id)
logging.info("VIFs for Instance %s: \n %s" %
LOG.info("VIFs for Instance %s: \n %s" %
(instance['uuid'], nw_info))
for vif in nw_info:
networks_ = get_network_by_id(vif['network_id'])
if networks_:
network = networks_[0]
logging.info("Network for Instance %s: \n %s" %
LOG.info("Network for Instance %s: \n %s" %
(instance['uuid'], network))
_update_network(vif, network)
else:
@ -218,7 +219,7 @@ def upgrade(migrate_engine):
# vif['meta'] could also be set to contain rxtx data here
# but it isn't exposed in the api and is still being rewritten
logging.info("VIF network for instance %s: \n %s" %
LOG.info("VIF network for instance %s: \n %s" %
(instance['uuid'], vif['network']))
# jsonify nw_info

View File

@ -20,6 +20,8 @@ from sqlalchemy import Column, Integer, MetaData, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
# Add disk_available_least column to compute_nodes table.
# Thinking about qcow2 image support, both compressed and virtual disk size
@ -40,7 +42,7 @@ def upgrade(migrate_engine):
try:
compute_nodes.create_column(disk_available_least)
except Exception:
logging.error(_("progress column not added to compute_nodes table"))
LOG.error(_("progress column not added to compute_nodes table"))
raise

View File

@ -18,6 +18,7 @@ from migrate import ForeignKeyConstraint
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
def upgrade(migrate_engine):
@ -64,7 +65,7 @@ def upgrade(migrate_engine):
name=fkey_name).drop()
except Exception:
logging.error(_("foreign key constraint couldn't be removed"))
LOG.error(_("foreign key constraint couldn't be removed"))
raise
@ -94,5 +95,5 @@ def downgrade(migrate_engine):
ForeignKeyConstraint(columns=[floating_ips.c.fixed_ip_id],
refcolumns=[fixed_ips.c.id]).create()
except Exception:
logging.error(_("foreign key constraint couldn't be added"))
LOG.error(_("foreign key constraint couldn't be added"))
raise

View File

@ -19,6 +19,7 @@ from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
aggregates = Table('aggregates', meta,
@ -85,7 +86,7 @@ def upgrade(migrate_engine):
try:
table.create()
except Exception:
logging.exception(repr(table))
LOG.exception(repr(table))
def downgrade(migrate_engine):
@ -94,4 +95,4 @@ def downgrade(migrate_engine):
try:
table.drop()
except Exception:
logging.exception(repr(table))
LOG.exception(repr(table))

View File

@ -18,6 +18,7 @@ from sqlalchemy import MetaData, String, Table
from nova import log as logging
meta = MetaData()
LOG = logging.getLogger(__name__)
#
# New Tables
@ -54,7 +55,7 @@ def upgrade(migrate_engine):
try:
dns_domains.create()
except Exception:
logging.error(_("Table |%s| not created!"), repr(dns_domains))
LOG.error(_("Table |%s| not created!"), repr(dns_domains))
raise
@ -62,5 +63,5 @@ def downgrade(migrate_engine):
try:
dns_domains.drop()
except Exception:
logging.error(_("dns_domains table not dropped"))
LOG.error(_("dns_domains table not dropped"))
raise

View File

@ -20,11 +20,8 @@ from sqlalchemy import select, Column, Integer
from nova import exception
from nova import flags
from nova import log as logging
LOG = logging.getLogger('nova.db.sqlalchemy.migrate_repo.versions')
FLAGS = flags.FLAGS
meta = sqlalchemy.MetaData()

Some files were not shown because too many files have changed in this diff Show More