db: Move remaining 'nova.db.sqlalchemy' modules
The two remaining modules, 'api_models' and 'api_migrations', are moved to the new 'nova.db.api' module. Change-Id: I138670fe36b07546db5518f78c657197780c5040 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
aec2ca9468
commit
bf8b5fc7d0
@ -177,7 +177,7 @@ Schema Migrations
|
||||
|
||||
Schema migrations are defined in
|
||||
``nova/db/main/legacy_migrations/versions`` and in
|
||||
``nova/db/sqlalchemy/api_migrations/migrate_repo/versions``. They are
|
||||
``nova/db/api/legacy_migrations/versions``. They are
|
||||
the routines that transform our database structure, which should be
|
||||
additive and able to be applied to a running system before service
|
||||
code has been upgraded.
|
||||
|
@ -15,7 +15,7 @@ from migrate import UniqueConstraint
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import dialects
|
||||
|
||||
from nova.db.sqlalchemy.api_models import MediumText
|
||||
from nova.db.api.models import MediumText
|
||||
from nova.objects import keypair
|
||||
|
||||
|
@ -45,9 +45,7 @@ def get_engine(database='main', context=None):
|
||||
def find_migrate_repo(database='main'):
|
||||
"""Get the path for the migrate repository."""
|
||||
global _REPOSITORY
|
||||
rel_path = os.path.join('main', 'legacy_migrations')
|
||||
if database == 'api':
|
||||
rel_path = os.path.join('sqlalchemy', 'api_migrations', 'migrate_repo')
|
||||
rel_path = os.path.join(database, 'legacy_migrations')
|
||||
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), rel_path)
|
||||
assert os.path.exists(path)
|
||||
if _REPOSITORY.get(database) is None:
|
||||
|
@ -19,8 +19,8 @@ from oslo_utils import uuidutils
|
||||
from sqlalchemy import orm
|
||||
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova import objects
|
||||
|
@ -18,8 +18,8 @@ from oslo_serialization import jsonutils
|
||||
from oslo_utils import versionutils
|
||||
from oslo_versionedobjects import exception as ovoo_exc
|
||||
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
|
@ -18,8 +18,8 @@ from sqlalchemy import sql
|
||||
from sqlalchemy.sql import expression
|
||||
|
||||
import nova.conf
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
|
@ -21,8 +21,8 @@ from sqlalchemy import sql
|
||||
from sqlalchemy.sql import expression
|
||||
|
||||
import nova.conf
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova.notifications.objects import base as notification
|
||||
from nova.notifications.objects import flavor as flavor_notification
|
||||
|
@ -14,8 +14,8 @@ from oslo_db import exception as db_exc
|
||||
from sqlalchemy import orm
|
||||
|
||||
from nova import context
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova.objects import base
|
||||
|
@ -22,8 +22,8 @@ from oslo_utils import versionutils
|
||||
from sqlalchemy import orm
|
||||
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
|
@ -20,8 +20,8 @@ from sqlalchemy import sql
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from nova import context as nova_context
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova import objects
|
||||
|
@ -17,8 +17,8 @@ from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import versionutils
|
||||
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
|
@ -16,9 +16,9 @@ import collections
|
||||
|
||||
from oslo_db import exception as db_exc
|
||||
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db
|
||||
from nova.db.main import models as main_models
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
|
@ -20,8 +20,8 @@ from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import versionutils
|
||||
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
|
@ -24,8 +24,8 @@ from sqlalchemy import sql
|
||||
|
||||
import nova.conf
|
||||
from nova import context as nova_context
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.scheduler.client import report
|
||||
|
@ -37,9 +37,9 @@ from oslo_db.sqlalchemy import test_fixtures
|
||||
from oslo_db.sqlalchemy import test_migrations
|
||||
import testtools
|
||||
|
||||
from nova.db.api import legacy_migrations
|
||||
from nova.db.api import models
|
||||
from nova.db import migration
|
||||
from nova.db.sqlalchemy.api_migrations import migrate_repo
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import test
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
|
||||
@ -63,7 +63,7 @@ class NovaAPIModelsSync(test_migrations.ModelsMigrationsSync):
|
||||
return self.migrate_engine
|
||||
|
||||
def get_metadata(self):
|
||||
return api_models.API_BASE.metadata
|
||||
return models.API_BASE.metadata
|
||||
|
||||
def include_object(self, object_, name, type_, reflected, compare_to):
|
||||
if type_ == 'table':
|
||||
@ -154,7 +154,7 @@ class NovaAPIMigrationsWalk(test_migrations.WalkVersionsMixin):
|
||||
@property
|
||||
def REPOSITORY(self):
|
||||
return repository.Repository(
|
||||
os.path.abspath(os.path.dirname(migrate_repo.__file__)))
|
||||
os.path.abspath(os.path.dirname(legacy_migrations.__file__)))
|
||||
|
||||
@property
|
||||
def migration_api(self):
|
||||
|
@ -18,8 +18,8 @@ from oslo_utils.fixture import uuidsentinel
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from nova import context
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
import nova.objects.aggregate as aggregate_obj
|
||||
from nova import test
|
||||
@ -401,8 +401,9 @@ class AggregateObjectDbTestCase(test.TestCase):
|
||||
|
||||
def test_aggregate_metadata_add_retry(self):
|
||||
result = _create_aggregate(self.context, metadata=None)
|
||||
with mock.patch('nova.db.sqlalchemy.api_models.'
|
||||
'AggregateMetadata.__table__.insert') as insert_mock:
|
||||
with mock.patch(
|
||||
'nova.db.api.models.AggregateMetadata.__table__.insert'
|
||||
) as insert_mock:
|
||||
insert_mock.side_effect = db_exc.DBDuplicateEntry
|
||||
self.assertRaises(db_exc.DBDuplicateEntry,
|
||||
aggregate_obj._metadata_add_to_db,
|
||||
|
@ -10,8 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import models
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import test
|
||||
|
||||
|
||||
|
@ -11,8 +11,8 @@
|
||||
# under the License.
|
||||
|
||||
from nova import context
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova import test
|
||||
|
@ -10,8 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import models
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import test
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_versionedobjects import fixture as ovo_fixture
|
||||
|
||||
from nova import context
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova.db.api import models as api_models
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
|
@ -10,8 +10,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import models
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import test
|
||||
|
||||
|
||||
|
@ -39,8 +39,8 @@ from nova.conductor.tasks import live_migrate
|
||||
from nova.conductor.tasks import migrate
|
||||
from nova import conf
|
||||
from nova import context
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception as exc
|
||||
from nova.image import glance as image_api
|
||||
from nova import objects
|
||||
|
@ -274,10 +274,7 @@ class ProjectTestCase(test.NoDBTestCase):
|
||||
includes_downgrade = []
|
||||
for directory in (
|
||||
os.path.join(topdir, 'db', 'main', 'legacy_migrations'),
|
||||
os.path.join(
|
||||
topdir, 'db', 'sqlalchemy', 'api_migrations',
|
||||
'migrate_repo',
|
||||
),
|
||||
os.path.join(topdir, 'db', 'api', 'legacy_migrations'),
|
||||
):
|
||||
py_glob = os.path.join(directory, 'versions', '*.py')
|
||||
for path in glob.iglob(py_glob):
|
||||
|
@ -13,8 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import models
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import test
|
||||
|
||||
|
||||
|
@ -19,8 +19,8 @@ from oslo_db import exception as db_exc
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from nova import context as nova_context
|
||||
from nova.db.api import models as api_models
|
||||
from nova.db.main import api as db_api
|
||||
from nova.db.sqlalchemy import api_models
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import fields
|
||||
@ -189,7 +189,7 @@ class _TestFlavor(object):
|
||||
flavor = flavor_obj.Flavor(context=self.context, id=123)
|
||||
self.assertRaises(exception.ObjectActionError, flavor.create)
|
||||
|
||||
@mock.patch('nova.db.sqlalchemy.api_models.Flavors')
|
||||
@mock.patch('nova.db.api.models.Flavors')
|
||||
def test_create_duplicate(self, mock_flavors):
|
||||
mock_flavors.return_value.save.side_effect = db_exc.DBDuplicateEntry
|
||||
fields = dict(fake_flavor)
|
||||
|
@ -6,7 +6,7 @@ import os
|
||||
import subprocess
|
||||
|
||||
BASE = 'nova/db/main/legacy_migrations/versions'.split('/')
|
||||
API_BASE = 'nova/db/sqlalchemy/api_migrations/migrate_repo/versions'.split('/')
|
||||
API_BASE = 'nova/db/api/legacy_migrations/versions'.split('/')
|
||||
|
||||
STUB = \
|
||||
"""# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
|
Loading…
Reference in New Issue
Block a user