db: Remove dead code
Change I532c7918a8e2c887f29d2f0e1e33b80f2b3a7507 removed the 'nova.db.sqlalchemy.migration.db_null_instance_uuid_scan' function. It should have also removed the '_process_null_records' function from this module. Change I42b302afbb1cfede7a0f7b16485a596cd70baf17 removed the XenAPI virt driver and tests. These tests were the only users of the 'nova.tests.unit.db.fakes' module which should have been removed then. Remove both now. Change-Id: I4a94760cebef4bb62da64189477636cc1002ffbe Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
22830d78b9
commit
6df671fea7
@ -21,7 +21,6 @@ from migrate.versioning import api as versioning_api
|
||||
from migrate.versioning.repository import Repository
|
||||
from oslo_log import log as logging
|
||||
import sqlalchemy
|
||||
from sqlalchemy.sql import null
|
||||
|
||||
from nova.db.sqlalchemy import api as db_session
|
||||
from nova import exception
|
||||
@ -121,43 +120,6 @@ def db_initial_version(database='main'):
|
||||
return INIT_VERSION[database]
|
||||
|
||||
|
||||
def _process_null_records(table, col_name, check_fkeys, delete=False):
|
||||
"""Queries the database and optionally deletes the NULL records.
|
||||
|
||||
:param table: sqlalchemy.Table object.
|
||||
:param col_name: The name of the column to check in the table.
|
||||
:param check_fkeys: If True, check the table for foreign keys back to the
|
||||
instances table and if not found, return.
|
||||
:param delete: If true, run a delete operation on the table, else just
|
||||
query for number of records that match the NULL column.
|
||||
:returns: The number of records processed for the table and column.
|
||||
"""
|
||||
records = 0
|
||||
if col_name in table.columns:
|
||||
# NOTE(mriedem): filter out tables that don't have a foreign key back
|
||||
# to the instances table since they could have stale data even if
|
||||
# instances.uuid wasn't NULL.
|
||||
if check_fkeys:
|
||||
fkey_found = False
|
||||
fkeys = table.c[col_name].foreign_keys or []
|
||||
for fkey in fkeys:
|
||||
if fkey.column.table.name == 'instances':
|
||||
fkey_found = True
|
||||
|
||||
if not fkey_found:
|
||||
return 0
|
||||
|
||||
if delete:
|
||||
records = table.delete().where(
|
||||
table.c[col_name] == null()
|
||||
).execute().rowcount
|
||||
else:
|
||||
records = len(list(
|
||||
table.select().where(table.c[col_name] == null()).execute()
|
||||
))
|
||||
return records
|
||||
|
||||
|
||||
def db_version_control(version=None, database='main', context=None):
|
||||
repository = _find_migrate_repo(database)
|
||||
versioning_api.version_control(get_engine(database, context=context),
|
||||
|
@ -1,133 +0,0 @@
|
||||
# Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
|
||||
# Copyright 2010 OpenStack Foundation
|
||||
# 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.
|
||||
|
||||
"""Stubouts, mocks and fixtures for the test suite."""
|
||||
|
||||
import datetime
|
||||
|
||||
|
||||
def stub_out(test, funcs):
|
||||
"""Set the stubs in mapping in the db api."""
|
||||
for module, func in funcs.items():
|
||||
test.stub_out(module, func)
|
||||
|
||||
|
||||
def stub_out_db_instance_api(test, injected=True):
|
||||
"""Stubs out the db API for creating Instances."""
|
||||
|
||||
def _create_flavor(**updates):
|
||||
flavor = {'id': 2,
|
||||
'name': 'm1.tiny',
|
||||
'memory_mb': 512,
|
||||
'vcpus': 1,
|
||||
'vcpu_weight': None,
|
||||
'root_gb': 0,
|
||||
'ephemeral_gb': 10,
|
||||
'flavorid': 1,
|
||||
'rxtx_factor': 1.0,
|
||||
'swap': 0,
|
||||
'deleted_at': None,
|
||||
'created_at': datetime.datetime(2014, 8, 8, 0, 0, 0),
|
||||
'updated_at': None,
|
||||
'deleted': False,
|
||||
'disabled': False,
|
||||
'is_public': True,
|
||||
'extra_specs': {},
|
||||
'description': None
|
||||
}
|
||||
if updates:
|
||||
flavor.update(updates)
|
||||
return flavor
|
||||
|
||||
FLAVORS = {
|
||||
'm1.tiny': _create_flavor(
|
||||
id=2,
|
||||
name='m1.tiny',
|
||||
memory_mb=512,
|
||||
vcpus=1,
|
||||
vcpu_weight=None,
|
||||
root_gb=0,
|
||||
ephemeral_gb=10,
|
||||
flavorid=1,
|
||||
rxtx_factor=1.0,
|
||||
swap=0),
|
||||
'm1.small': _create_flavor(
|
||||
id=5,
|
||||
name='m1.small',
|
||||
memory_mb=2048,
|
||||
vcpus=1,
|
||||
vcpu_weight=None,
|
||||
root_gb=20,
|
||||
ephemeral_gb=0,
|
||||
flavorid=2,
|
||||
rxtx_factor=1.0,
|
||||
swap=1024),
|
||||
'm1.medium': _create_flavor(
|
||||
id=1,
|
||||
name='m1.medium',
|
||||
memory_mb=4096,
|
||||
vcpus=2,
|
||||
vcpu_weight=None,
|
||||
root_gb=40,
|
||||
ephemeral_gb=40,
|
||||
flavorid=3,
|
||||
rxtx_factor=1.0,
|
||||
swap=0),
|
||||
'm1.large': _create_flavor(
|
||||
id=3,
|
||||
name='m1.large',
|
||||
memory_mb=8192,
|
||||
vcpus=4,
|
||||
vcpu_weight=10,
|
||||
root_gb=80,
|
||||
ephemeral_gb=80,
|
||||
flavorid=4,
|
||||
rxtx_factor=1.0,
|
||||
swap=0),
|
||||
'm1.xlarge': _create_flavor(
|
||||
id=4,
|
||||
name='m1.xlarge',
|
||||
memory_mb=16384,
|
||||
vcpus=8,
|
||||
vcpu_weight=None,
|
||||
root_gb=160,
|
||||
ephemeral_gb=160,
|
||||
flavorid=5,
|
||||
rxtx_factor=1.0,
|
||||
swap=0)}
|
||||
|
||||
def fake_flavor_get_all(*a, **k):
|
||||
return FLAVORS.values()
|
||||
|
||||
@classmethod
|
||||
def fake_flavor_get_by_name(cls, context, name):
|
||||
return FLAVORS[name]
|
||||
|
||||
@classmethod
|
||||
def fake_flavor_get(cls, context, id):
|
||||
for flavor in FLAVORS.values():
|
||||
if str(flavor['id']) == str(id):
|
||||
return flavor
|
||||
return None
|
||||
|
||||
funcs = {
|
||||
'nova.objects.flavor._flavor_get_all_from_db': (
|
||||
fake_flavor_get_all),
|
||||
'nova.objects.Flavor._flavor_get_by_name_from_db': (
|
||||
fake_flavor_get_by_name),
|
||||
'nova.objects.Flavor._flavor_get_from_db': fake_flavor_get,
|
||||
}
|
||||
stub_out(test, funcs)
|
Loading…
Reference in New Issue
Block a user