Remove unused get_not_versions from dbapi
The get_not_version method was put in, but never used, the underlying upgrade check code just explicitly passes the appropriate query arguments and doesn't use the helper. Why now? Because it used model_query. Change-Id: I697f13486c2e11cd04b4f381f3066eeb154ea2a3
This commit is contained in:
parent
ea68a4a79a
commit
eaf26c7c68
@ -967,16 +967,6 @@ class Connection(object, metaclass=abc.ABCMeta):
|
||||
ident does not exist.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_not_versions(self, model_name, versions):
|
||||
"""Returns objects with versions that are not the specified versions.
|
||||
|
||||
:param model_name: the name of the model (class) of desired objects
|
||||
:param versions: list of versions of objects not to be returned
|
||||
:returns: list of the DB objects
|
||||
:raises: IronicException if there is no class associated with the name
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def check_versions(self, ignore_models=()):
|
||||
"""Checks the whole database for incompatible objects.
|
||||
|
@ -1736,31 +1736,6 @@ class Connection(api.Connection):
|
||||
if count == 0:
|
||||
raise exception.VolumeTargetNotFound(target=ident)
|
||||
|
||||
def get_not_versions(self, model_name, versions):
|
||||
"""Returns objects with versions that are not the specified versions.
|
||||
|
||||
This returns objects with versions that are not the specified versions.
|
||||
Objects with null versions (there shouldn't be any) are also returned.
|
||||
|
||||
:param model_name: the name of the model (class) of desired objects
|
||||
:param versions: list of versions of objects not to be returned
|
||||
:returns: list of the DB objects
|
||||
:raises: IronicException if there is no class associated with the name
|
||||
"""
|
||||
if not versions:
|
||||
return []
|
||||
|
||||
if model_name == 'Node':
|
||||
model_name = 'NodeBase'
|
||||
model = models.get_class(model_name)
|
||||
|
||||
# NOTE(rloo): .notin_ does not handle null:
|
||||
# http://docs.sqlalchemy.org/en/latest/core/sqlelement.html#sqlalchemy.sql.operators.ColumnOperators.notin_
|
||||
query = model_query(model).filter(
|
||||
sql.or_(model.version == sql.null(),
|
||||
model.version.notin_(versions)))
|
||||
return query.all()
|
||||
|
||||
def check_versions(self, ignore_models=(), permit_initial_version=False):
|
||||
"""Checks the whole database for incompatible objects.
|
||||
|
||||
|
@ -16,7 +16,6 @@ from unittest import mock
|
||||
from oslo_db.sqlalchemy import utils as db_utils
|
||||
from oslo_utils import uuidutils
|
||||
import sqlalchemy as sa
|
||||
from testtools import matchers
|
||||
|
||||
from ironic.common import context
|
||||
from ironic.common import exception
|
||||
@ -105,45 +104,6 @@ class UpgradingTestCase(base.DbTestCase):
|
||||
self.assertFalse(self.dbapi.check_versions())
|
||||
|
||||
|
||||
class GetNotVersionsTestCase(base.DbTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(GetNotVersionsTestCase, self).setUp()
|
||||
self.dbapi = db_api.get_instance()
|
||||
|
||||
def test_get_not_versions(self):
|
||||
versions = ['1.1', '1.2', '1.3']
|
||||
node_uuids = []
|
||||
for v in versions:
|
||||
node = utils.create_test_node(uuid=uuidutils.generate_uuid(),
|
||||
version=v)
|
||||
node_uuids.append(node.uuid)
|
||||
self.assertEqual([], self.dbapi.get_not_versions('Node', versions))
|
||||
|
||||
res = self.dbapi.get_not_versions('Node', ['2.0'])
|
||||
self.assertThat(res, matchers.HasLength(len(node_uuids)))
|
||||
res_uuids = [n.uuid for n in res]
|
||||
self.assertEqual(node_uuids, res_uuids)
|
||||
|
||||
res = self.dbapi.get_not_versions('Node', versions[1:])
|
||||
self.assertThat(res, matchers.HasLength(1))
|
||||
self.assertEqual(node_uuids[0], res[0].uuid)
|
||||
|
||||
def test_get_not_versions_null(self):
|
||||
node = utils.create_test_node(uuid=uuidutils.generate_uuid(),
|
||||
version=None)
|
||||
node = self.dbapi.get_node_by_id(node.id)
|
||||
self.assertIsNone(node.version)
|
||||
res = self.dbapi.get_not_versions('Node', ['1.6'])
|
||||
self.assertThat(res, matchers.HasLength(1))
|
||||
self.assertEqual(node.uuid, res[0].uuid)
|
||||
|
||||
def test_get_not_versions_no_model(self):
|
||||
utils.create_test_node(uuid=uuidutils.generate_uuid(), version='1.4')
|
||||
self.assertRaises(exception.IronicException,
|
||||
self.dbapi.get_not_versions, 'NotExist', ['1.6'])
|
||||
|
||||
|
||||
class UpdateToLatestVersionsTestCase(base.DbTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user