diff --git a/ironic/db/sqlalchemy/alembic/versions/5674c57409b9_replace_nostate_with_available.py b/ironic/db/sqlalchemy/alembic/versions/5674c57409b9_replace_nostate_with_available.py index bdae6788ea..38c2343e23 100644 --- a/ironic/db/sqlalchemy/alembic/versions/5674c57409b9_replace_nostate_with_available.py +++ b/ironic/db/sqlalchemy/alembic/versions/5674c57409b9_replace_nostate_with_available.py @@ -24,7 +24,7 @@ down_revision = '242cc6a923b3' from alembic import op from sqlalchemy import String -from sqlalchemy.sql import table, column +from sqlalchemy.sql import table, column, null node = table('nodes', column('uuid', String(36)), @@ -41,7 +41,7 @@ AVAILABLE = 'available' def upgrade(): op.execute( node.update().where( - node.c.provision_state == None).values( + node.c.provision_state == null()).values( {'provision_state': op.inline_literal(AVAILABLE)})) diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py index 76c51f3cee..12fb55edf8 100644 --- a/ironic/db/sqlalchemy/api.py +++ b/ironic/db/sqlalchemy/api.py @@ -29,6 +29,7 @@ from oslo_utils import strutils from oslo_utils import timeutils from oslo_utils import uuidutils from sqlalchemy.orm.exc import NoResultFound +from sqlalchemy import sql from ironic.common import exception from ironic.common.i18n import _ @@ -159,14 +160,14 @@ class Connection(api.Connection): query = query.filter_by(chassis_id=chassis_obj.id) if 'associated' in filters: if filters['associated']: - query = query.filter(models.Node.instance_uuid != None) + query = query.filter(models.Node.instance_uuid != sql.null()) else: - query = query.filter(models.Node.instance_uuid == None) + query = query.filter(models.Node.instance_uuid == sql.null()) if 'reserved' in filters: if filters['reserved']: - query = query.filter(models.Node.reservation != None) + query = query.filter(models.Node.reservation != sql.null()) else: - query = query.filter(models.Node.reservation == None) + query = query.filter(models.Node.reservation == sql.null()) if 'maintenance' in filters: query = query.filter_by(maintenance=filters['maintenance']) if 'driver' in filters: diff --git a/tox.ini b/tox.ini index b942a46791..933901ab5b 100644 --- a/tox.ini +++ b/tox.ini @@ -59,8 +59,7 @@ setenv = PYTHONHASHSEED=0 commands = {posargs} [flake8] -# E711: ignored because it is normal to use "column == None" in sqlalchemy -ignore = E129,E711 +ignore = E129 exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,tools max-complexity=17