From 2224fe326439a5089cd177eb92257d34f82dd013 Mon Sep 17 00:00:00 2001 From: chenke Date: Tue, 19 Mar 2019 10:41:20 +0800 Subject: [PATCH] Add the params default value for method _paginate_query() Aslo modify the error "H306: imports not in alphabetical order" Change-Id: I6682c0de0bc5513d73aa0204ff6e66f747c005cf --- cyborg/db/sqlalchemy/api.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cyborg/db/sqlalchemy/api.py b/cyborg/db/sqlalchemy/api.py index 4d9ca0d8..c81f83a2 100644 --- a/cyborg/db/sqlalchemy/api.py +++ b/cyborg/db/sqlalchemy/api.py @@ -15,8 +15,8 @@ """SQLAlchemy storage backend.""" -import threading import copy +import threading import uuid from oslo_db import api as oslo_db_api @@ -27,17 +27,16 @@ from oslo_log import log from oslo_utils import strutils from oslo_utils import timeutils from oslo_utils import uuidutils -from sqlalchemy.orm import load_only from sqlalchemy.orm.exc import NoResultFound -from sqlalchemy.sql import func +from sqlalchemy.orm import load_only from cyborg.common import exception from cyborg.common.i18n import _ from cyborg.db import api from cyborg.db.sqlalchemy import models -from sqlalchemy import or_ from sqlalchemy import and_ +from sqlalchemy import or_ _CONTEXT = threading.local() LOG = log.getLogger(__name__) @@ -106,7 +105,8 @@ def add_identity_filter(query, value): raise exception.InvalidIdentity(identity=value) -def _paginate_query(context, model, limit, marker, sort_key, sort_dir, query): +def _paginate_query(context, model, limit=None, marker=None, sort_key=None, + sort_dir=None, query=None): sort_keys = ['id'] if sort_key and sort_key not in sort_keys: sort_keys.insert(0, sort_key) @@ -225,7 +225,7 @@ class Connection(api.Connection): def attach_handle_list(self, context): query = model_query(context, models.AttachHandle) - return _paginate_query(context, models.AttachHandle) + return _paginate_query(context, models.AttachHandle, query=query) def attach_handle_update(self, context, uuid, values): if 'uuid' in values: @@ -305,7 +305,7 @@ class Connection(api.Connection): def control_path_list(self, context): query = model_query(context, models.ControlpathID) - return _paginate_query(context, models.ControlpathID) + return _paginate_query(context, models.ControlpathID, query=query) def control_path_update(self, context, uuid, values): if 'uuid' in values: @@ -383,7 +383,7 @@ class Connection(api.Connection): def device_list(self, context): query = model_query(context, models.Device) - return _paginate_query(context, models.Device) + return _paginate_query(context, models.Device, query=query) def device_update(self, context, uuid, values): if 'uuid' in values: @@ -472,7 +472,7 @@ class Connection(api.Connection): def device_profile_list(self, context): query = model_query(context, models.DeviceProfile) - return _paginate_query(context, models.DeviceProfile) + return _paginate_query(context, models.DeviceProfile, query=query) def device_profile_update(self, context, uuid, values): if 'uuid' in values: @@ -886,7 +886,7 @@ class Connection(api.Connection): def quota_reserve(self, context, resources, deltas, expire, until_refresh, max_age, project_id=None, is_allocated_reserve=False): - """ Create reservation record in DB according to params""" + """Create reservation record in DB according to params""" with _session_for_write() as session: if project_id is None: project_id = context.project_id