25
25
from oslo_upgradecheck import common_checks
26
26
from oslo_upgradecheck import upgradecheck
27
27
import pkg_resources
28
+ import sqlalchemy as sa
28
29
from sqlalchemy import func as sqlfunc
29
- from sqlalchemy import MetaData , Table , select
30
30
31
31
from nova .cmd import common as cmd_common
32
32
import nova .conf
@@ -86,10 +86,10 @@ def _count_compute_nodes(self, context=None):
86
86
# table, or by only counting compute nodes with a service version of at
87
87
# least 15 which was the highest service version when Newton was
88
88
# 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 ()
93
93
94
94
def _check_cellsv2 (self ):
95
95
"""Checks to see if cells v2 has been setup.
@@ -102,7 +102,7 @@ def _check_cellsv2(self):
102
102
this on an initial install. This also has to be careful about checking
103
103
for compute nodes if there are no host mappings on a fresh install.
104
104
"""
105
- meta = MetaData ()
105
+ meta = sa . MetaData ()
106
106
meta .bind = db_session .get_api_engine ()
107
107
108
108
cell_mappings = self ._get_cell_mappings ()
@@ -122,8 +122,9 @@ def _check_cellsv2(self):
122
122
'retry.' )
123
123
return upgradecheck .Result (upgradecheck .Code .FAILURE , msg )
124
124
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 ()
127
128
if count == 0 :
128
129
# This may be a fresh install in which case there may not be any
129
130
# compute_nodes in the cell database if the nova-compute service
0 commit comments