"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/common/sql/core.py" between
keystone-16.0.1.tar.gz and keystone-17.0.0.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Ussuri" series (latest release).

core.py  (keystone-16.0.1):core.py  (keystone-17.0.0)
skipping to change at line 34 skipping to change at line 34
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 enginefacade from oslo_db.sqlalchemy import enginefacade
from oslo_db.sqlalchemy import models from oslo_db.sqlalchemy import models
from oslo_log import log from oslo_log import log
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import timeutils from oslo_utils import timeutils
from osprofiler import opts as profiler from osprofiler import opts as profiler
import osprofiler.sqlalchemy import osprofiler.sqlalchemy
import six
import sqlalchemy as sql import sqlalchemy as sql
from sqlalchemy.ext import declarative from sqlalchemy.ext import declarative
from sqlalchemy.orm.attributes import flag_modified, InstrumentedAttribute from sqlalchemy.orm.attributes import flag_modified, InstrumentedAttribute
from sqlalchemy import types as sql_types from sqlalchemy import types as sql_types
from keystone.common import driver_hints from keystone.common import driver_hints
from keystone.common import utils from keystone.common import utils
import keystone.conf import keystone.conf
from keystone import exception from keystone import exception
from keystone.i18n import _ from keystone.i18n import _
skipping to change at line 102 skipping to change at line 101
""" """
def initialize(self, *args, **kwargs): def initialize(self, *args, **kwargs):
cls = type(self) cls = type(self)
for k, v in kwargs.items(): for k, v in kwargs.items():
if hasattr(cls, k): if hasattr(cls, k):
attr = getattr(cls, k) attr = getattr(cls, k)
if isinstance(attr, InstrumentedAttribute): if isinstance(attr, InstrumentedAttribute):
column = attr.property.columns[0] column = attr.property.columns[0]
if isinstance(column.type, String): if isinstance(column.type, String):
if not isinstance(v, six.text_type): if not isinstance(v, str):
v = six.text_type(v) v = str(v)
if column.type.length and column.type.length < len(v): if column.type.length and column.type.length < len(v):
raise exception.StringLengthExceeded( raise exception.StringLengthExceeded(
string=v, type=k, length=column.type.length) string=v, type=k, length=column.type.length)
init(self, *args, **kwargs) init(self, *args, **kwargs)
return initialize return initialize
ModelBase.__init__ = initialize_decorator(ModelBase.__init__) ModelBase.__init__ = initialize_decorator(ModelBase.__init__)
# Special Fields # Special Fields
skipping to change at line 500 skipping to change at line 499
def decorator(method): def decorator(method):
@functools.wraps(method) @functools.wraps(method)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
try: try:
return method(*args, **kwargs) return method(*args, **kwargs)
except db_exception.DBDuplicateEntry as e: except db_exception.DBDuplicateEntry as e:
# 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
# as it can contain raw SQL. # as it can contain raw SQL.
LOG.debug(_conflict_msg, {'conflict_type': conflict_type, LOG.debug(_conflict_msg, {'conflict_type': conflict_type,
'details': six.text_type(e)}) 'details': e})
name = None name = None
field = None field = None
domain_id = None domain_id = None
# First element is unnecessary for extracting name and causes # First element is unnecessary for extracting name and causes
# object not iterable error. Remove it. # object not iterable error. Remove it.
params = args[1:] params = args[1:]
# We want to store the duplicate objects name in the error # We want to store the duplicate objects name in the error
# message for the user. If name is not available we use the id. # message for the user. If name is not available we use the id.
for arg in params: for arg in params:
if isinstance(arg, dict): if isinstance(arg, dict):
skipping to change at line 539 skipping to change at line 538
raise exception.Conflict(type=conflict_type, raise exception.Conflict(type=conflict_type,
details=msg) details=msg)
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
# as it can contain raw SQL. # as it can contain raw SQL.
LOG.debug(_conflict_msg, {'conflict_type': conflict_type, LOG.debug(_conflict_msg, {'conflict_type': conflict_type,
'details': six.text_type(e)}) 'details': e})
# NOTE(morganfainberg): This is really a case where the SQL # NOTE(morganfainberg): This is really a case where the SQL
# failed to store the data. This is not something that the # failed to store the data. This is not something that the
# user has done wrong. Example would be a ForeignKey is # user has done wrong. Example would be a ForeignKey is
# missing; the code that is executed before reaching the # missing; the code that is executed before reaching the
# SQL writing to the DB should catch the issue. # SQL writing to the DB should catch the issue.
raise exception.UnexpectedError( raise exception.UnexpectedError(
_('An unexpected error occurred when trying to ' _('An unexpected error occurred when trying to '
'store %s') % conflict_type) 'store %s') % conflict_type)
raise raise
 End of changes. 4 change blocks. 
5 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)