Change oslo.db to oslo_db
The oslo libraries are moving away from namespace packages. A hacking check is added to enforce use of the new location. bp drop-namespace-packages Change-Id: I9b4b1ff0abde2084d3645825d08dab5670ae7979
This commit is contained in:
parent
89dac6262d
commit
d7266cb4d7
@ -22,10 +22,10 @@ import contextlib
|
|||||||
import functools
|
import functools
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from oslo.db import exception as db_exception
|
from oslo_db import exception as db_exception
|
||||||
from oslo.db import options as db_options
|
from oslo_db import options as db_options
|
||||||
from oslo.db.sqlalchemy import models
|
from oslo_db.sqlalchemy import models
|
||||||
from oslo.db.sqlalchemy import session as db_session
|
from oslo_db.sqlalchemy import session as db_session
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
import six
|
||||||
import sqlalchemy as sql
|
import sqlalchemy as sql
|
||||||
@ -401,7 +401,7 @@ def handle_conflicts(conflict_type='object'):
|
|||||||
details=_('Duplicate Entry'))
|
details=_('Duplicate Entry'))
|
||||||
except db_exception.DBError as e:
|
except db_exception.DBError as e:
|
||||||
# TODO(blk-u): inspecting inner_exception breaks encapsulation;
|
# TODO(blk-u): inspecting inner_exception breaks encapsulation;
|
||||||
# oslo.db should provide exception we need.
|
# oslo_db should provide exception we need.
|
||||||
if isinstance(e.inner_exception, IntegrityError):
|
if isinstance(e.inner_exception, IntegrityError):
|
||||||
# LOG the exception for debug purposes, do not send the
|
# LOG the exception for debug purposes, do not send the
|
||||||
# exception details out with the raised Conflict exception
|
# exception details out with the raised Conflict exception
|
||||||
|
@ -19,7 +19,7 @@ import sys
|
|||||||
|
|
||||||
import migrate
|
import migrate
|
||||||
from migrate import exceptions
|
from migrate import exceptions
|
||||||
from oslo.db.sqlalchemy import migration
|
from oslo_db.sqlalchemy import migration
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
import six
|
import six
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo.db.sqlalchemy import utils
|
from oslo_db.sqlalchemy import utils
|
||||||
import sqlalchemy as sql
|
import sqlalchemy as sql
|
||||||
|
|
||||||
|
|
||||||
|
@ -399,8 +399,10 @@ class CheckForLoggingIssues(BaseASTChecker):
|
|||||||
|
|
||||||
def check_oslo_namespace_imports(logical_line, blank_before, filename):
|
def check_oslo_namespace_imports(logical_line, blank_before, filename):
|
||||||
oslo_namespace_imports = re.compile(
|
oslo_namespace_imports = re.compile(
|
||||||
r"(((from)|(import))\s+oslo\.((messaging)|(serialization)|(utils)))|"
|
r"(((from)|(import))\s+oslo\.("
|
||||||
"(from\s+oslo\s+import\s+((messaging)|(serialization)|(utils)))")
|
"(db)|(messaging)|(serialization)|(utils)))|"
|
||||||
|
"(from\s+oslo\s+import\s+("
|
||||||
|
"(db)|(messaging)|(serialization)|(utils)))")
|
||||||
|
|
||||||
if re.match(oslo_namespace_imports, logical_line):
|
if re.match(oslo_namespace_imports, logical_line):
|
||||||
msg = ("K333: '%s' must be used instead of '%s'.") % (
|
msg = ("K333: '%s' must be used instead of '%s'.") % (
|
||||||
|
@ -16,8 +16,8 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from oslo.db import options as db_options
|
from oslo_db import options as db_options
|
||||||
from oslo.db.sqlalchemy import migration
|
from oslo_db.sqlalchemy import migration
|
||||||
|
|
||||||
from keystone.common import sql
|
from keystone.common import sql
|
||||||
from keystone.common.sql import migration_helpers
|
from keystone.common.sql import migration_helpers
|
||||||
|
@ -204,6 +204,14 @@ class HackingCode(fixtures.Fixture):
|
|||||||
from oslo import messaging
|
from oslo import messaging
|
||||||
from oslo.messaging import conffixture
|
from oslo.messaging import conffixture
|
||||||
from oslo_messaging import conffixture
|
from oslo_messaging import conffixture
|
||||||
|
|
||||||
|
import oslo.db
|
||||||
|
import oslo_db
|
||||||
|
import oslo.db.api
|
||||||
|
import oslo_db.api
|
||||||
|
from oslo import db
|
||||||
|
from oslo.db import api
|
||||||
|
from oslo_db import api
|
||||||
""",
|
""",
|
||||||
'expected_errors': [
|
'expected_errors': [
|
||||||
(1, 0, 'K333'),
|
(1, 0, 'K333'),
|
||||||
@ -218,6 +226,10 @@ class HackingCode(fixtures.Fixture):
|
|||||||
(19, 0, 'K333'),
|
(19, 0, 'K333'),
|
||||||
(21, 0, 'K333'),
|
(21, 0, 'K333'),
|
||||||
(22, 0, 'K333'),
|
(22, 0, 'K333'),
|
||||||
|
(25, 0, 'K333'),
|
||||||
|
(27, 0, 'K333'),
|
||||||
|
(29, 0, 'K333'),
|
||||||
|
(30, 0, 'K333'),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ import functools
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslo.db import exception as db_exception
|
from oslo_db import exception as db_exception
|
||||||
from oslo.db import options
|
from oslo_db import options
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from sqlalchemy import exc
|
from sqlalchemy import exc
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
@ -29,7 +29,7 @@ WARNING::
|
|||||||
all data will be lost.
|
all data will be lost.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from oslo.db.sqlalchemy import utils
|
from oslo_db.sqlalchemy import utils
|
||||||
|
|
||||||
from keystone.contrib import endpoint_filter
|
from keystone.contrib import endpoint_filter
|
||||||
from keystone.contrib import endpoint_policy
|
from keystone.contrib import endpoint_policy
|
||||||
|
@ -34,9 +34,9 @@ import json
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from migrate.versioning import api as versioning_api
|
from migrate.versioning import api as versioning_api
|
||||||
from oslo.db import exception as db_exception
|
from oslo_db import exception as db_exception
|
||||||
from oslo.db.sqlalchemy import migration
|
from oslo_db.sqlalchemy import migration
|
||||||
from oslo.db.sqlalchemy import session as db_session
|
from oslo_db.sqlalchemy import session as db_session
|
||||||
import six
|
import six
|
||||||
from sqlalchemy.engine import reflection
|
from sqlalchemy.engine import reflection
|
||||||
import sqlalchemy.exc
|
import sqlalchemy.exc
|
||||||
@ -1234,11 +1234,11 @@ class SqlUpgradeTests(SqlMigrateBase):
|
|||||||
self.assertEqual(1, session.query(region_unique_table).count())
|
self.assertEqual(1, session.query(region_unique_table).count())
|
||||||
# verify the unique constraint is enforced
|
# verify the unique constraint is enforced
|
||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
# FIXME (I159): Since oslo.db wraps all the database exceptions
|
# FIXME (I159): Since oslo_db wraps all the database exceptions
|
||||||
# into more specific exception objects, we should catch both of
|
# into more specific exception objects, we should catch both of
|
||||||
# sqlalchemy and oslo.db exceptions. If an old oslo.db version
|
# sqlalchemy and oslo_db exceptions. If an old oslo_db version
|
||||||
# is installed, IntegrityError is raised. If >=0.4.0 version of
|
# is installed, IntegrityError is raised. If >=0.4.0 version of
|
||||||
# oslo.db is installed, DBError is raised.
|
# oslo_db is installed, DBError is raised.
|
||||||
# When the global requirements is updated with
|
# When the global requirements is updated with
|
||||||
# the version fixes exceptions wrapping, IntegrityError must be
|
# the version fixes exceptions wrapping, IntegrityError must be
|
||||||
# removed from the tuple.
|
# removed from the tuple.
|
||||||
|
@ -117,7 +117,7 @@ class Trust(trust.Driver):
|
|||||||
raise exception.TrustUseLimitReached(trust_id=trust_id)
|
raise exception.TrustUseLimitReached(trust_id=trust_id)
|
||||||
# NOTE(morganfainberg): Ensure we have a yield point for eventlet
|
# NOTE(morganfainberg): Ensure we have a yield point for eventlet
|
||||||
# here. This should cost us nothing otherwise. This can be removed
|
# here. This should cost us nothing otherwise. This can be removed
|
||||||
# if/when oslo.db cleanly handles yields on db calls.
|
# if/when oslo_db cleanly handles yields on db calls.
|
||||||
time.sleep(0)
|
time.sleep(0)
|
||||||
else:
|
else:
|
||||||
# NOTE(morganfainberg): In the case the for loop is not prematurely
|
# NOTE(morganfainberg): In the case the for loop is not prematurely
|
||||||
|
Loading…
Reference in New Issue
Block a user