From 52953b2dcd90c02f8783e836c662418b98d9c44a Mon Sep 17 00:00:00 2001 From: "Jay S. Bryant" Date: Wed, 14 Jan 2015 18:16:32 -0600 Subject: [PATCH] Move oslo.db to oslo_db namespace This is the second in a series of changes to move to using the new oslo_ namespace that is being used for oslo libraries. There is currently a shim in place that is allowing the old oslo. imports to work, but we need to be prepared for when the shims go away. Thus, we need patches like this one to move to the new namespace. This patch also updates our hacking check to ensure that no instances of oslo.db sneak back in. Change-Id: Ibebed114a362e199e03c83d7d229841e8f88932b --- cinder/cmd/manage.py | 2 +- cinder/db/api.py | 4 ++-- cinder/db/migration.py | 4 ++-- cinder/db/sqlalchemy/api.py | 6 +++--- cinder/db/sqlalchemy/models.py | 2 +- cinder/hacking/checks.py | 2 +- cinder/service.py | 2 +- cinder/tests/test_cmd.py | 2 +- cinder/tests/test_hacking.py | 4 ++++ cinder/tests/test_migrations.py | 6 +++--- cinder/tests/test_qos_specs.py | 2 +- cinder/tests/test_service.py | 2 +- cinder/volume/qos_specs.py | 2 +- cinder/volume/volume_types.py | 2 +- 14 files changed, 23 insertions(+), 19 deletions(-) diff --git a/cinder/cmd/manage.py b/cinder/cmd/manage.py index 05b491746..f278a210c 100644 --- a/cinder/cmd/manage.py +++ b/cinder/cmd/manage.py @@ -62,8 +62,8 @@ import warnings warnings.simplefilter('once', DeprecationWarning) from oslo.config import cfg -from oslo.db.sqlalchemy import migration from oslo import messaging +from oslo_db.sqlalchemy import migration from cinder import i18n i18n.enable_lazy() diff --git a/cinder/db/api.py b/cinder/db/api.py index 4a393e60d..ecd3d4bf2 100644 --- a/cinder/db/api.py +++ b/cinder/db/api.py @@ -42,8 +42,8 @@ these objects be simple dictionaries. """ from oslo.config import cfg -from oslo.db import concurrency as db_concurrency -from oslo.db import options as db_options +from oslo_db import concurrency as db_concurrency +from oslo_db import options as db_options db_opts = [ diff --git a/cinder/db/migration.py b/cinder/db/migration.py index 29f5b7ec9..f00cf55c1 100644 --- a/cinder/db/migration.py +++ b/cinder/db/migration.py @@ -20,7 +20,7 @@ import os import threading from oslo.config import cfg -from oslo import db +from oslo_db import options from stevedore import driver from cinder.db.sqlalchemy import api as db_api @@ -30,7 +30,7 @@ INIT_VERSION = 000 _IMPL = None _LOCK = threading.Lock() -db.options.set_defaults(cfg.CONF) +options.set_defaults(cfg.CONF) MIGRATE_REPO_PATH = os.path.join( os.path.abspath(os.path.dirname(__file__)), diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index fd771a9b8..2a3c2d4b2 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -27,10 +27,10 @@ import uuid import warnings from oslo.config import cfg -from oslo.db import exception as db_exc -from oslo.db import options -from oslo.db.sqlalchemy import session as db_session from oslo.utils import timeutils +from oslo_db import exception as db_exc +from oslo_db import options +from oslo_db.sqlalchemy import session as db_session import osprofiler.sqlalchemy import six import sqlalchemy diff --git a/cinder/db/sqlalchemy/models.py b/cinder/db/sqlalchemy/models.py index 73f960a33..b61a127da 100644 --- a/cinder/db/sqlalchemy/models.py +++ b/cinder/db/sqlalchemy/models.py @@ -20,8 +20,8 @@ SQLAlchemy models for cinder data. """ from oslo.config import cfg -from oslo.db.sqlalchemy import models from oslo.utils import timeutils +from oslo_db.sqlalchemy import models from sqlalchemy import Column, Integer, String, Text, schema from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import ForeignKey, DateTime, Boolean diff --git a/cinder/hacking/checks.py b/cinder/hacking/checks.py index 36da480ac..ff4e1dd33 100644 --- a/cinder/hacking/checks.py +++ b/cinder/hacking/checks.py @@ -43,7 +43,7 @@ no_audit_log = re.compile(r"(.)*LOG\.audit(.)*") # NOTE(jsbryant): When other oslo libraries switch over non-namespaced # imports, we will need to add them to the regex below. -oslo_namespace_imports = re.compile(r"from[\s]*oslo[.](concurrency)") +oslo_namespace_imports = re.compile(r"from[\s]*oslo[.](concurrency|db)") def no_vi_headers(physical_line, line_number, lines): diff --git a/cinder/service.py b/cinder/service.py index 4401373ba..5e9a3b6bd 100644 --- a/cinder/service.py +++ b/cinder/service.py @@ -23,10 +23,10 @@ import os import random from oslo.config import cfg -from oslo.db import exception as db_exc from oslo import messaging from oslo.utils import importutils from oslo_concurrency import processutils +from oslo_db import exception as db_exc import osprofiler.notifier from osprofiler import profiler import osprofiler.web diff --git a/cinder/tests/test_cmd.py b/cinder/tests/test_cmd.py index f0016bb56..18c9e81dd 100644 --- a/cinder/tests/test_cmd.py +++ b/cinder/tests/test_cmd.py @@ -337,7 +337,7 @@ class TestCinderManageCmd(test.TestCase): db_cmds.sync(version=version) db_sync.assert_called_once_with(version) - @mock.patch('oslo.db.sqlalchemy.migration.db_version') + @mock.patch('oslo_db.sqlalchemy.migration.db_version') def test_db_commands_version(self, db_version): db_cmds = cinder_manage.DbCommands() db_cmds.version() diff --git a/cinder/tests/test_hacking.py b/cinder/tests/test_hacking.py index 1849eecab..95ffcba90 100644 --- a/cinder/tests/test_hacking.py +++ b/cinder/tests/test_hacking.py @@ -116,3 +116,7 @@ class HackingTestCase(test.TestCase): "from oslo.concurrency import foo")))) self.assertEqual(0, len(list(checks.check_oslo_namespace_imports( "from oslo_concurrency import bar")))) + self.assertEqual(1, len(list(checks.check_oslo_namespace_imports( + "from oslo.db import foo")))) + self.assertEqual(0, len(list(checks.check_oslo_namespace_imports( + "from oslo_db import bar")))) diff --git a/cinder/tests/test_migrations.py b/cinder/tests/test_migrations.py index 739090c12..2c0ead4ac 100644 --- a/cinder/tests/test_migrations.py +++ b/cinder/tests/test_migrations.py @@ -24,9 +24,9 @@ import uuid from migrate.versioning import api as migration_api from migrate.versioning import repository -from oslo.db.sqlalchemy import test_base -from oslo.db.sqlalchemy import test_migrations -from oslo.db.sqlalchemy import utils as db_utils +from oslo_db.sqlalchemy import test_base +from oslo_db.sqlalchemy import test_migrations +from oslo_db.sqlalchemy import utils as db_utils import sqlalchemy from cinder.db import migration diff --git a/cinder/tests/test_qos_specs.py b/cinder/tests/test_qos_specs.py index ea8d2bb53..01ec065b6 100644 --- a/cinder/tests/test_qos_specs.py +++ b/cinder/tests/test_qos_specs.py @@ -19,7 +19,7 @@ Unit Tests for qos specs internal API import time -from oslo.db import exception as db_exc +from oslo_db import exception as db_exc from cinder import context from cinder import db diff --git a/cinder/tests/test_service.py b/cinder/tests/test_service.py index 2ddb3162a..2f80cea3f 100644 --- a/cinder/tests/test_service.py +++ b/cinder/tests/test_service.py @@ -23,8 +23,8 @@ Unit Tests for remote procedure calls using queue import mock import mox from oslo.config import cfg -from oslo.db import exception as db_exc from oslo_concurrency import processutils +from oslo_db import exception as db_exc from cinder import context from cinder import db diff --git a/cinder/volume/qos_specs.py b/cinder/volume/qos_specs.py index 3ab430ea9..020e215c8 100644 --- a/cinder/volume/qos_specs.py +++ b/cinder/volume/qos_specs.py @@ -17,7 +17,7 @@ from oslo.config import cfg -from oslo.db import exception as db_exc +from oslo_db import exception as db_exc from cinder import context from cinder import db diff --git a/cinder/volume/volume_types.py b/cinder/volume/volume_types.py index 5bff32ba5..19959681f 100644 --- a/cinder/volume/volume_types.py +++ b/cinder/volume/volume_types.py @@ -21,7 +21,7 @@ from oslo.config import cfg -from oslo.db import exception as db_exc +from oslo_db import exception as db_exc import six from cinder import context -- 2.45.2