From 3623ec3c5859973443db454a3b0f45c1f3ae2c10 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Mon, 14 Mar 2016 12:54:58 +0100 Subject: [PATCH] Remove circular import to fix config generation Patch https://review.openstack.org/278354 created a circular import when added an "import cinder.db" line to cinder/api/common.py since cinder/db/api.py imports cinder.api.common back, which breaks genconfig. Change-Id: Ic60866822e74687101a3885f6000f89d901bb17a Closes-Bug: #1556889 --- cinder/api/common.py | 4 ++-- cinder/common/constants.py | 18 ++++++++++++++++++ cinder/db/api.py | 3 ++- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 cinder/common/constants.py diff --git a/cinder/api/common.py b/cinder/api/common.py index b19e12242..1efb6ae76 100644 --- a/cinder/api/common.py +++ b/cinder/api/common.py @@ -25,7 +25,7 @@ import webob from cinder.api.openstack import wsgi from cinder.api import xmlutil -import cinder.db +from cinder.common import constants from cinder import exception from cinder.i18n import _ import cinder.policy @@ -139,7 +139,7 @@ def _get_marker_param(params): def _get_offset_param(params): """Extract offset id from request's dictionary (defaults to 0) or fail.""" offset = params.pop('offset', 0) - return utils.validate_integer(offset, 'offset', 0, cinder.db.MAX_INT) + return utils.validate_integer(offset, 'offset', 0, constants.DB_MAX_INT) def limited(items, request, max_limit=None): diff --git a/cinder/common/constants.py b/cinder/common/constants.py new file mode 100644 index 000000000..fa0858965 --- /dev/null +++ b/cinder/common/constants.py @@ -0,0 +1,18 @@ +# Copyright 2016 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +# The maximum value a signed INT type may have +DB_MAX_INT = 0x7FFFFFFF diff --git a/cinder/db/api.py b/cinder/db/api.py index 680bf8674..357603321 100644 --- a/cinder/db/api.py +++ b/cinder/db/api.py @@ -41,6 +41,7 @@ from oslo_db import concurrency as db_concurrency from oslo_db import options as db_options from cinder.api import common +from cinder.common import constants from cinder.i18n import _ db_opts = [ @@ -69,7 +70,7 @@ _BACKEND_MAPPING = {'sqlalchemy': 'cinder.db.sqlalchemy.api'} IMPL = db_concurrency.TpoolDbapiWrapper(CONF, _BACKEND_MAPPING) # The maximum value a signed INT type may have -MAX_INT = 0x7FFFFFFF +MAX_INT = constants.DB_MAX_INT ################### -- 2.45.2