Fix alembic 'No handlers could be found for logger...'

When running 'neutron-db-manage upgrade heads', I get:

No handlers could be found for logger "oslo_config.cfg" <--
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
...

This patch moves the logging configuration from env.py to cli.py,
so the configuration is done when the CLI is invoked and not
when Alembic imports env.py.

Change-Id: I767e72f513699f21dd629241faa04cb2d8fa416c
This commit is contained in:
Assaf Muller 2016-03-23 11:30:37 -04:00
parent eccbbd113f
commit 13993764cd
2 changed files with 6 additions and 6 deletions

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from logging import config as logging_config
from alembic import context
from oslo_config import cfg
import sqlalchemy as sa
@ -40,10 +38,6 @@ MYSQL_ENGINE = None
config = context.config
neutron_config = config.neutron_config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
logging_config.fileConfig(config.config_file_name)
# set the target for 'autogenerate' support
target_metadata = model_base.BASEV2.metadata

View File

@ -13,6 +13,7 @@
# under the License.
import copy
from logging import config as logging_config
import os
from alembic import command as alembic_command
@ -62,6 +63,11 @@ BRANCHLESS_WARNING = 'Branchless migration chains are deprecated as of Mitaka.'
neutron_alembic_ini = os.path.join(os.path.dirname(__file__), 'alembic.ini')
# Interpret the config file for Python logging.
# This line sets up loggers basically.
logging_config.fileConfig(neutron_alembic_ini)
VALID_SERVICES = ['fwaas', 'lbaas', 'vpnaas']
INSTALLED_SERVICES = [service_ for service_ in VALID_SERVICES
if 'neutron-%s' % service_ in migration_entrypoints]