Skip to content

Commit 35ddf1a

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "db: Use module-level imports for sqlalchemy (for real)"
2 parents 5ddaf36 + 43de242 commit 35ddf1a

File tree

15 files changed

+1131
-1101
lines changed

15 files changed

+1131
-1101
lines changed

nova/cmd/status.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from oslo_upgradecheck import common_checks
2626
from oslo_upgradecheck import upgradecheck
2727
import pkg_resources
28+
import sqlalchemy as sa
2829
from sqlalchemy import func as sqlfunc
29-
from sqlalchemy import MetaData, Table, select
3030

3131
from nova.cmd import common as cmd_common
3232
import nova.conf
@@ -86,10 +86,10 @@ def _count_compute_nodes(self, context=None):
8686
# table, or by only counting compute nodes with a service version of at
8787
# least 15 which was the highest service version when Newton was
8888
# released.
89-
meta = MetaData(bind=db_session.get_engine(context=context))
90-
compute_nodes = Table('compute_nodes', meta, autoload=True)
91-
return select([sqlfunc.count()]).select_from(compute_nodes).where(
92-
compute_nodes.c.deleted == 0).scalar()
89+
meta = sa.MetaData(bind=db_session.get_engine(context=context))
90+
compute_nodes = sa.Table('compute_nodes', meta, autoload=True)
91+
return sa.select([sqlfunc.count()]).select_from(compute_nodes).where(
92+
compute_nodes.c.deleted == 0).scalar()
9393

9494
def _check_cellsv2(self):
9595
"""Checks to see if cells v2 has been setup.
@@ -102,7 +102,7 @@ def _check_cellsv2(self):
102102
this on an initial install. This also has to be careful about checking
103103
for compute nodes if there are no host mappings on a fresh install.
104104
"""
105-
meta = MetaData()
105+
meta = sa.MetaData()
106106
meta.bind = db_session.get_api_engine()
107107

108108
cell_mappings = self._get_cell_mappings()
@@ -122,8 +122,9 @@ def _check_cellsv2(self):
122122
'retry.')
123123
return upgradecheck.Result(upgradecheck.Code.FAILURE, msg)
124124

125-
host_mappings = Table('host_mappings', meta, autoload=True)
126-
count = select([sqlfunc.count()]).select_from(host_mappings).scalar()
125+
host_mappings = sa.Table('host_mappings', meta, autoload=True)
126+
count = sa.select([sqlfunc.count()]).select_from(host_mappings)\
127+
.scalar()
127128
if count == 0:
128129
# This may be a fresh install in which case there may not be any
129130
# compute_nodes in the cell database if the nova-compute service

nova/db/sqlalchemy/api.py

Lines changed: 107 additions & 107 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)