From 6b91ba21df3f60e8362ef86b90de93e73e317b20 Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Tue, 10 Apr 2018 17:29:33 -0700 Subject: [PATCH] Resolve pep8 E402 errors and no longer ignore E402 Fix the pep8 E402 (Module level import not at top of file) errors. For the Alembic files move the definitions of 'revision' and 'down_revision' below the imports. This is now done in Alembic [1] For other files fix as needed by moving the imports or lines before the imports. In a few cases add a "# noqa E402" to whitelist the issue. [1] https://bitbucket.org/zzzeek/alembic/commits/dc2aae0374b76ccab8494be6e103d84089bc449b Change-Id: I48c96d5da0cb747b3ca3fceea9b4ffa85a9ebe22 --- api-ref/source/conf.py | 10 +++++----- ironic/cmd/__init__.py | 2 +- .../10b163d4481e_add_port_portgroup_internal_info.py | 6 +++--- .../versions/1a59178ebdf6_add_volume_targets_table.py | 6 +++--- ...1d6951876d68_add_storage_interface_db_field_and_.py | 6 +++--- .../1e1d5ace7dc6_add_inspection_started_at_and_.py | 6 +++--- .../versions/21b331f883ef_add_provision_updated_at.py | 6 +++--- ...895ecfae_add_conductor_hardware_interfaces_table.py | 6 +++--- .../242cc6a923b3_add_node_maintenance_reason.py | 6 +++--- .../alembic/versions/2581ebaf0cb2_initial_migration.py | 6 +++--- .../versions/2fb93ffd2af1_increase_node_name_length.py | 9 ++++----- .../versions/31baaf680d2b_add_node_instance_info.py | 6 +++--- .../alembic/versions/3ae36a5f5131_add_logical_name.py | 6 +++--- ...a56f25597_add_unique_constraint_to_instance_uuid.py | 4 ++-- .../versions/3cb628139ea4_nodes_add_console_enabled.py | 6 +++--- .../versions/3d86a077a3f2_add_port_physical_network.py | 6 +++--- .../405cfe08f18d_add_rescue_interface_to_node.py | 6 +++--- .../487deb87cc9d_add_conductor_affinity_and_online.py | 6 +++--- .../alembic/versions/48d6c242bb9b_add_node_tags.py | 6 +++--- .../493d8f27f235_add_portgroup_configuration_fields.py | 8 ++++---- .../versions/4f399b21ae71_add_node_clean_step.py | 6 +++--- .../516faf1bb9b1_resizing_column_nodes_driver.py | 6 +++--- .../5674c57409b9_replace_nostate_with_available.py | 8 ++++---- ...b0d310e_added_port_group_table_and_altered_ports.py | 6 +++--- .../60cf717201bc_add_standalone_ports_supported.py | 6 +++--- .../alembic/versions/789acc877671_add_raid_config.py | 6 +++--- .../868cb606a74a_add_version_field_in_base_class.py | 6 +++--- .../versions/b4130a7fc904_create_nodetraits_table.py | 6 +++--- .../bb59b63f55a_add_node_driver_internal_info.py | 6 +++--- .../bcdd431ba0bf_add_fields_for_all_interfaces.py | 6 +++--- .../c14cef6dfedf_populate_node_network_interface.py | 8 ++++---- .../daa1ba02d98_add_volume_connectors_table.py | 6 +++--- .../versions/dbefd6bdaa2c_add_default_column_to_.py | 6 +++--- .../dd34e1f1303b_add_resource_class_to_node.py | 6 +++--- .../e294876e8028_add_node_network_interface.py | 6 +++--- .../e918ff30eb42_resize_column_nodes_instance_info.py | 6 +++--- .../versions/f6fdb920c182_set_pxe_enabled_true.py | 8 ++++---- ironic/tests/base.py | 5 ++--- .../drivers/modules/ilo/test_firmware_processor.py | 10 +++------- .../tests/unit/drivers/modules/xclarity/test_power.py | 10 +++++----- tox.ini | 4 +--- 41 files changed, 126 insertions(+), 134 deletions(-) diff --git a/api-ref/source/conf.py b/api-ref/source/conf.py index befe4a869c..1c9af11e9e 100644 --- a/api-ref/source/conf.py +++ b/api-ref/source/conf.py @@ -30,6 +30,11 @@ import sys import openstackdocstheme +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +from ironic.version import version_info + html_theme = 'openstackdocs' html_theme_path = [openstackdocstheme.get_html_theme_path()] html_theme_options = { @@ -66,11 +71,6 @@ master_doc = 'index' project = u'Ironic API Reference' copyright = u'OpenStack Foundation' -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -from ironic.version import version_info # The full version, including alpha/beta/rc tags. release = version_info.release_string() # The short X.Y version. diff --git a/ironic/cmd/__init__.py b/ironic/cmd/__init__.py index 0447011e93..18e85ab186 100644 --- a/ironic/cmd/__init__.py +++ b/ironic/cmd/__init__.py @@ -19,7 +19,7 @@ # concurrency models can cause undefined behavior and potentially API timeouts. import os -os.environ['EVENTLET_NO_GREENDNS'] = 'yes' +os.environ['EVENTLET_NO_GREENDNS'] = 'yes' # noqa E402 import eventlet diff --git a/ironic/db/sqlalchemy/alembic/versions/10b163d4481e_add_port_portgroup_internal_info.py b/ironic/db/sqlalchemy/alembic/versions/10b163d4481e_add_port_portgroup_internal_info.py index 9dd7bfa2e2..2e91990492 100644 --- a/ironic/db/sqlalchemy/alembic/versions/10b163d4481e_add_port_portgroup_internal_info.py +++ b/ironic/db/sqlalchemy/alembic/versions/10b163d4481e_add_port_portgroup_internal_info.py @@ -18,13 +18,13 @@ Create Date: 2016-07-06 17:43:55.846837 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '10b163d4481e' down_revision = 'e294876e8028' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('ports', sa.Column('internal_info', diff --git a/ironic/db/sqlalchemy/alembic/versions/1a59178ebdf6_add_volume_targets_table.py b/ironic/db/sqlalchemy/alembic/versions/1a59178ebdf6_add_volume_targets_table.py index ba9c7ce42a..11258754a4 100644 --- a/ironic/db/sqlalchemy/alembic/versions/1a59178ebdf6_add_volume_targets_table.py +++ b/ironic/db/sqlalchemy/alembic/versions/1a59178ebdf6_add_volume_targets_table.py @@ -18,13 +18,13 @@ Create Date: 2016-02-25 11:25:29.836535 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '1a59178ebdf6' down_revision = 'daa1ba02d98' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.create_table('volume_targets', diff --git a/ironic/db/sqlalchemy/alembic/versions/1d6951876d68_add_storage_interface_db_field_and_.py b/ironic/db/sqlalchemy/alembic/versions/1d6951876d68_add_storage_interface_db_field_and_.py index 91ff2c548d..77a8c58741 100644 --- a/ironic/db/sqlalchemy/alembic/versions/1d6951876d68_add_storage_interface_db_field_and_.py +++ b/ironic/db/sqlalchemy/alembic/versions/1d6951876d68_add_storage_interface_db_field_and_.py @@ -18,13 +18,13 @@ Create Date: 2016-07-26 10:33:22.830739 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '1d6951876d68' down_revision = '493d8f27f235' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('storage_interface', diff --git a/ironic/db/sqlalchemy/alembic/versions/1e1d5ace7dc6_add_inspection_started_at_and_.py b/ironic/db/sqlalchemy/alembic/versions/1e1d5ace7dc6_add_inspection_started_at_and_.py index 1bf191246a..f6d7398a09 100644 --- a/ironic/db/sqlalchemy/alembic/versions/1e1d5ace7dc6_add_inspection_started_at_and_.py +++ b/ironic/db/sqlalchemy/alembic/versions/1e1d5ace7dc6_add_inspection_started_at_and_.py @@ -18,13 +18,13 @@ Create Date: 2015-02-26 10:46:46.861927 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '1e1d5ace7dc6' down_revision = '3ae36a5f5131' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('inspection_started_at', diff --git a/ironic/db/sqlalchemy/alembic/versions/21b331f883ef_add_provision_updated_at.py b/ironic/db/sqlalchemy/alembic/versions/21b331f883ef_add_provision_updated_at.py index 6074113d11..df5c1f8c35 100644 --- a/ironic/db/sqlalchemy/alembic/versions/21b331f883ef_add_provision_updated_at.py +++ b/ironic/db/sqlalchemy/alembic/versions/21b331f883ef_add_provision_updated_at.py @@ -18,13 +18,13 @@ Create Date: 2014-02-19 13:45:30.150632 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '21b331f883ef' down_revision = '2581ebaf0cb2' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('provision_updated_at', sa.DateTime(), diff --git a/ironic/db/sqlalchemy/alembic/versions/2353895ecfae_add_conductor_hardware_interfaces_table.py b/ironic/db/sqlalchemy/alembic/versions/2353895ecfae_add_conductor_hardware_interfaces_table.py index 8880401a2c..75170e6e03 100644 --- a/ironic/db/sqlalchemy/alembic/versions/2353895ecfae_add_conductor_hardware_interfaces_table.py +++ b/ironic/db/sqlalchemy/alembic/versions/2353895ecfae_add_conductor_hardware_interfaces_table.py @@ -18,13 +18,13 @@ Create Date: 2016-12-12 15:17:22.065056 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '2353895ecfae' down_revision = '1d6951876d68' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.create_table('conductor_hardware_interfaces', diff --git a/ironic/db/sqlalchemy/alembic/versions/242cc6a923b3_add_node_maintenance_reason.py b/ironic/db/sqlalchemy/alembic/versions/242cc6a923b3_add_node_maintenance_reason.py index 0d7b718221..ccb952fb3b 100644 --- a/ironic/db/sqlalchemy/alembic/versions/242cc6a923b3_add_node_maintenance_reason.py +++ b/ironic/db/sqlalchemy/alembic/versions/242cc6a923b3_add_node_maintenance_reason.py @@ -18,13 +18,13 @@ Create Date: 2014-10-15 23:00:43.164061 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '242cc6a923b3' down_revision = '487deb87cc9d' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('maintenance_reason', diff --git a/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py b/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py index 61cdb2f7d9..d47a3d131b 100644 --- a/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py +++ b/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py @@ -19,13 +19,13 @@ Create Date: 2014-01-17 12:14:07.754448 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '2581ebaf0cb2' down_revision = None -from alembic import op -import sqlalchemy as sa - def upgrade(): # commands auto generated by Alembic - please adjust! diff --git a/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py b/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py index f45b309c57..d2ce2c526f 100644 --- a/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py +++ b/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py @@ -18,15 +18,14 @@ Create Date: 2015-03-18 17:08:11.470791 """ -# revision identifiers, used by Alembic. -revision = '2fb93ffd2af1' -down_revision = '4f399b21ae71' - - from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import mysql +# revision identifiers, used by Alembic. +revision = '2fb93ffd2af1' +down_revision = '4f399b21ae71' + def upgrade(): op.alter_column('nodes', 'name', diff --git a/ironic/db/sqlalchemy/alembic/versions/31baaf680d2b_add_node_instance_info.py b/ironic/db/sqlalchemy/alembic/versions/31baaf680d2b_add_node_instance_info.py index 6dd869b0b1..647f9f7e20 100644 --- a/ironic/db/sqlalchemy/alembic/versions/31baaf680d2b_add_node_instance_info.py +++ b/ironic/db/sqlalchemy/alembic/versions/31baaf680d2b_add_node_instance_info.py @@ -18,13 +18,13 @@ Create Date: 2014-03-05 21:09:32.372463 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '31baaf680d2b' down_revision = '3cb628139ea4' -from alembic import op -import sqlalchemy as sa - def upgrade(): # commands auto generated by Alembic - please adjust diff --git a/ironic/db/sqlalchemy/alembic/versions/3ae36a5f5131_add_logical_name.py b/ironic/db/sqlalchemy/alembic/versions/3ae36a5f5131_add_logical_name.py index 456ab65c69..7e00e01b03 100644 --- a/ironic/db/sqlalchemy/alembic/versions/3ae36a5f5131_add_logical_name.py +++ b/ironic/db/sqlalchemy/alembic/versions/3ae36a5f5131_add_logical_name.py @@ -18,13 +18,13 @@ Create Date: 2014-12-10 14:27:26.323540 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '3ae36a5f5131' down_revision = 'bb59b63f55a' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('name', sa.String(length=63), diff --git a/ironic/db/sqlalchemy/alembic/versions/3bea56f25597_add_unique_constraint_to_instance_uuid.py b/ironic/db/sqlalchemy/alembic/versions/3bea56f25597_add_unique_constraint_to_instance_uuid.py index 48cb3a3b27..05f7011984 100644 --- a/ironic/db/sqlalchemy/alembic/versions/3bea56f25597_add_unique_constraint_to_instance_uuid.py +++ b/ironic/db/sqlalchemy/alembic/versions/3bea56f25597_add_unique_constraint_to_instance_uuid.py @@ -21,12 +21,12 @@ Create Date: 2014-06-05 11:45:07.046670 """ +from alembic import op + # revision identifiers, used by Alembic. revision = '3bea56f25597' down_revision = '31baaf680d2b' -from alembic import op - def upgrade(): op.create_unique_constraint("uniq_nodes0instance_uuid", "nodes", diff --git a/ironic/db/sqlalchemy/alembic/versions/3cb628139ea4_nodes_add_console_enabled.py b/ironic/db/sqlalchemy/alembic/versions/3cb628139ea4_nodes_add_console_enabled.py index 19f2ca8492..9e011a2cd5 100644 --- a/ironic/db/sqlalchemy/alembic/versions/3cb628139ea4_nodes_add_console_enabled.py +++ b/ironic/db/sqlalchemy/alembic/versions/3cb628139ea4_nodes_add_console_enabled.py @@ -18,13 +18,13 @@ Create Date: 2014-02-26 11:24:11.318023 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '3cb628139ea4' down_revision = '21b331f883ef' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('console_enabled', sa.Boolean)) diff --git a/ironic/db/sqlalchemy/alembic/versions/3d86a077a3f2_add_port_physical_network.py b/ironic/db/sqlalchemy/alembic/versions/3d86a077a3f2_add_port_physical_network.py index b23c7ab68b..9472518bfc 100644 --- a/ironic/db/sqlalchemy/alembic/versions/3d86a077a3f2_add_port_physical_network.py +++ b/ironic/db/sqlalchemy/alembic/versions/3d86a077a3f2_add_port_physical_network.py @@ -18,13 +18,13 @@ Create Date: 2017-04-30 17:11:49.384851 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '3d86a077a3f2' down_revision = 'dbefd6bdaa2c' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('ports', sa.Column('physical_network', diff --git a/ironic/db/sqlalchemy/alembic/versions/405cfe08f18d_add_rescue_interface_to_node.py b/ironic/db/sqlalchemy/alembic/versions/405cfe08f18d_add_rescue_interface_to_node.py index c0785e8229..9598d837c7 100644 --- a/ironic/db/sqlalchemy/alembic/versions/405cfe08f18d_add_rescue_interface_to_node.py +++ b/ironic/db/sqlalchemy/alembic/versions/405cfe08f18d_add_rescue_interface_to_node.py @@ -18,13 +18,13 @@ Create Date: 2017-02-01 16:32:32.098742 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '405cfe08f18d' down_revision = '868cb606a74a' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('rescue_interface', diff --git a/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py b/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py index f455300ade..26c7a724df 100644 --- a/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py +++ b/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py @@ -18,13 +18,13 @@ Create Date: 2014-09-26 16:16:30.988900 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '487deb87cc9d' down_revision = '3bea56f25597' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column( diff --git a/ironic/db/sqlalchemy/alembic/versions/48d6c242bb9b_add_node_tags.py b/ironic/db/sqlalchemy/alembic/versions/48d6c242bb9b_add_node_tags.py index 61c2ea31b3..641419f091 100644 --- a/ironic/db/sqlalchemy/alembic/versions/48d6c242bb9b_add_node_tags.py +++ b/ironic/db/sqlalchemy/alembic/versions/48d6c242bb9b_add_node_tags.py @@ -18,13 +18,13 @@ Create Date: 2015-10-08 10:07:33.779516 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '48d6c242bb9b' down_revision = '516faf1bb9b1' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.create_table( diff --git a/ironic/db/sqlalchemy/alembic/versions/493d8f27f235_add_portgroup_configuration_fields.py b/ironic/db/sqlalchemy/alembic/versions/493d8f27f235_add_portgroup_configuration_fields.py index 2d12ac2d35..4ec4f9bc41 100644 --- a/ironic/db/sqlalchemy/alembic/versions/493d8f27f235_add_portgroup_configuration_fields.py +++ b/ironic/db/sqlalchemy/alembic/versions/493d8f27f235_add_portgroup_configuration_fields.py @@ -18,16 +18,16 @@ Create Date: 2016-11-15 18:09:31.362613 """ -# revision identifiers, used by Alembic. -revision = '493d8f27f235' -down_revision = '1a59178ebdf6' - from alembic import op import sqlalchemy as sa from sqlalchemy import sql from ironic.conf import CONF +# revision identifiers, used by Alembic. +revision = '493d8f27f235' +down_revision = '1a59178ebdf6' + def upgrade(): op.add_column('portgroups', sa.Column('properties', sa.Text(), diff --git a/ironic/db/sqlalchemy/alembic/versions/4f399b21ae71_add_node_clean_step.py b/ironic/db/sqlalchemy/alembic/versions/4f399b21ae71_add_node_clean_step.py index f685e74301..efb8f234bb 100644 --- a/ironic/db/sqlalchemy/alembic/versions/4f399b21ae71_add_node_clean_step.py +++ b/ironic/db/sqlalchemy/alembic/versions/4f399b21ae71_add_node_clean_step.py @@ -18,13 +18,13 @@ Create Date: 2015-02-18 01:21:46.062311 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '4f399b21ae71' down_revision = '1e1d5ace7dc6' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('clean_step', sa.Text(), diff --git a/ironic/db/sqlalchemy/alembic/versions/516faf1bb9b1_resizing_column_nodes_driver.py b/ironic/db/sqlalchemy/alembic/versions/516faf1bb9b1_resizing_column_nodes_driver.py index 72260ca1f1..a534883134 100644 --- a/ironic/db/sqlalchemy/alembic/versions/516faf1bb9b1_resizing_column_nodes_driver.py +++ b/ironic/db/sqlalchemy/alembic/versions/516faf1bb9b1_resizing_column_nodes_driver.py @@ -18,13 +18,13 @@ Create Date: 2015-08-05 13:27:31.808919 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '516faf1bb9b1' down_revision = '789acc877671' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.alter_column('nodes', 'driver', 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 ab133c9008..00f73e3da3 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 @@ -18,14 +18,14 @@ Create Date: 2015-01-14 16:55:44.718196 """ -# revision identifiers, used by Alembic. -revision = '5674c57409b9' -down_revision = '242cc6a923b3' - from alembic import op from sqlalchemy import String from sqlalchemy.sql import table, column, null +# revision identifiers, used by Alembic. +revision = '5674c57409b9' +down_revision = '242cc6a923b3' + node = table('nodes', column('uuid', String(36)), column('provision_state', String(15))) diff --git a/ironic/db/sqlalchemy/alembic/versions/5ea1b0d310e_added_port_group_table_and_altered_ports.py b/ironic/db/sqlalchemy/alembic/versions/5ea1b0d310e_added_port_group_table_and_altered_ports.py index c2d71ff9ce..a799c1b1d7 100644 --- a/ironic/db/sqlalchemy/alembic/versions/5ea1b0d310e_added_port_group_table_and_altered_ports.py +++ b/ironic/db/sqlalchemy/alembic/versions/5ea1b0d310e_added_port_group_table_and_altered_ports.py @@ -18,13 +18,13 @@ Create Date: 2015-06-30 14:14:26.972368 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '5ea1b0d310e' down_revision = '48d6c242bb9b' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.create_table('portgroups', diff --git a/ironic/db/sqlalchemy/alembic/versions/60cf717201bc_add_standalone_ports_supported.py b/ironic/db/sqlalchemy/alembic/versions/60cf717201bc_add_standalone_ports_supported.py index 2e284a67e6..6da061797a 100644 --- a/ironic/db/sqlalchemy/alembic/versions/60cf717201bc_add_standalone_ports_supported.py +++ b/ironic/db/sqlalchemy/alembic/versions/60cf717201bc_add_standalone_ports_supported.py @@ -18,13 +18,13 @@ Create Date: 2016-08-25 07:00:56.662645 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '60cf717201bc' down_revision = 'c14cef6dfedf' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('portgroups', sa.Column('standalone_ports_supported', diff --git a/ironic/db/sqlalchemy/alembic/versions/789acc877671_add_raid_config.py b/ironic/db/sqlalchemy/alembic/versions/789acc877671_add_raid_config.py index ec751b0bd2..306041c043 100644 --- a/ironic/db/sqlalchemy/alembic/versions/789acc877671_add_raid_config.py +++ b/ironic/db/sqlalchemy/alembic/versions/789acc877671_add_raid_config.py @@ -18,13 +18,13 @@ Create Date: 2015-06-26 01:21:46.062311 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '789acc877671' down_revision = '2fb93ffd2af1' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('raid_config', sa.Text(), diff --git a/ironic/db/sqlalchemy/alembic/versions/868cb606a74a_add_version_field_in_base_class.py b/ironic/db/sqlalchemy/alembic/versions/868cb606a74a_add_version_field_in_base_class.py index d55f36c2a9..bf57b89cb7 100644 --- a/ironic/db/sqlalchemy/alembic/versions/868cb606a74a_add_version_field_in_base_class.py +++ b/ironic/db/sqlalchemy/alembic/versions/868cb606a74a_add_version_field_in_base_class.py @@ -18,13 +18,13 @@ Create Date: 2016-12-15 12:31:31.629237 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = '868cb606a74a' down_revision = '3d86a077a3f2' -from alembic import op -import sqlalchemy as sa - def upgrade(): # NOTE(rloo): In db.sqlalchemy.models, we added the 'version' column diff --git a/ironic/db/sqlalchemy/alembic/versions/b4130a7fc904_create_nodetraits_table.py b/ironic/db/sqlalchemy/alembic/versions/b4130a7fc904_create_nodetraits_table.py index 86e3f3c3d4..8cf30a2d94 100644 --- a/ironic/db/sqlalchemy/alembic/versions/b4130a7fc904_create_nodetraits_table.py +++ b/ironic/db/sqlalchemy/alembic/versions/b4130a7fc904_create_nodetraits_table.py @@ -18,13 +18,13 @@ Create Date: 2017-12-20 10:20:07.911788 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = 'b4130a7fc904' down_revision = '405cfe08f18d' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.create_table( diff --git a/ironic/db/sqlalchemy/alembic/versions/bb59b63f55a_add_node_driver_internal_info.py b/ironic/db/sqlalchemy/alembic/versions/bb59b63f55a_add_node_driver_internal_info.py index 2bcd11c9c8..dbbec49c32 100644 --- a/ironic/db/sqlalchemy/alembic/versions/bb59b63f55a_add_node_driver_internal_info.py +++ b/ironic/db/sqlalchemy/alembic/versions/bb59b63f55a_add_node_driver_internal_info.py @@ -18,13 +18,13 @@ Create Date: 2015-01-28 14:28:22.212790 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = 'bb59b63f55a' down_revision = '5674c57409b9' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('driver_internal_info', diff --git a/ironic/db/sqlalchemy/alembic/versions/bcdd431ba0bf_add_fields_for_all_interfaces.py b/ironic/db/sqlalchemy/alembic/versions/bcdd431ba0bf_add_fields_for_all_interfaces.py index 6c5db9224e..55206bd5da 100644 --- a/ironic/db/sqlalchemy/alembic/versions/bcdd431ba0bf_add_fields_for_all_interfaces.py +++ b/ironic/db/sqlalchemy/alembic/versions/bcdd431ba0bf_add_fields_for_all_interfaces.py @@ -18,13 +18,13 @@ Create Date: 2016-11-11 16:44:52.823881 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = 'bcdd431ba0bf' down_revision = '60cf717201bc' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('boot_interface', diff --git a/ironic/db/sqlalchemy/alembic/versions/c14cef6dfedf_populate_node_network_interface.py b/ironic/db/sqlalchemy/alembic/versions/c14cef6dfedf_populate_node_network_interface.py index ac49571f79..cf12e02aba 100644 --- a/ironic/db/sqlalchemy/alembic/versions/c14cef6dfedf_populate_node_network_interface.py +++ b/ironic/db/sqlalchemy/alembic/versions/c14cef6dfedf_populate_node_network_interface.py @@ -18,16 +18,16 @@ Create Date: 2016-08-01 14:05:24.197314 """ -# revision identifiers, used by Alembic. -revision = 'c14cef6dfedf' -down_revision = 'dd34e1f1303b' - from alembic import op from sqlalchemy import String from sqlalchemy.sql import table, column, null from ironic.conf import CONF +# revision identifiers, used by Alembic. +revision = 'c14cef6dfedf' +down_revision = 'dd34e1f1303b' + node = table('nodes', column('uuid', String(36)), diff --git a/ironic/db/sqlalchemy/alembic/versions/daa1ba02d98_add_volume_connectors_table.py b/ironic/db/sqlalchemy/alembic/versions/daa1ba02d98_add_volume_connectors_table.py index 90e1b01ace..c8afeb5303 100644 --- a/ironic/db/sqlalchemy/alembic/versions/daa1ba02d98_add_volume_connectors_table.py +++ b/ironic/db/sqlalchemy/alembic/versions/daa1ba02d98_add_volume_connectors_table.py @@ -18,13 +18,13 @@ Create Date: 2015-11-26 17:19:22.074989 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = 'daa1ba02d98' down_revision = 'bcdd431ba0bf' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.create_table('volume_connectors', diff --git a/ironic/db/sqlalchemy/alembic/versions/dbefd6bdaa2c_add_default_column_to_.py b/ironic/db/sqlalchemy/alembic/versions/dbefd6bdaa2c_add_default_column_to_.py index e5abdb07b7..2f769bde7b 100644 --- a/ironic/db/sqlalchemy/alembic/versions/dbefd6bdaa2c_add_default_column_to_.py +++ b/ironic/db/sqlalchemy/alembic/versions/dbefd6bdaa2c_add_default_column_to_.py @@ -20,13 +20,13 @@ Create Date: 2017-01-17 15:28:04.653738 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = 'dbefd6bdaa2c' down_revision = '2353895ecfae' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('conductor_hardware_interfaces', sa.Column('default', diff --git a/ironic/db/sqlalchemy/alembic/versions/dd34e1f1303b_add_resource_class_to_node.py b/ironic/db/sqlalchemy/alembic/versions/dd34e1f1303b_add_resource_class_to_node.py index 020b3277d7..51975c2fdc 100644 --- a/ironic/db/sqlalchemy/alembic/versions/dd34e1f1303b_add_resource_class_to_node.py +++ b/ironic/db/sqlalchemy/alembic/versions/dd34e1f1303b_add_resource_class_to_node.py @@ -20,13 +20,13 @@ Create Date: 2016-07-20 21:48:12.475320 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = 'dd34e1f1303b' down_revision = '10b163d4481e' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('resource_class', sa.String(80), diff --git a/ironic/db/sqlalchemy/alembic/versions/e294876e8028_add_node_network_interface.py b/ironic/db/sqlalchemy/alembic/versions/e294876e8028_add_node_network_interface.py index 8bc6aeedb2..3188a758aa 100644 --- a/ironic/db/sqlalchemy/alembic/versions/e294876e8028_add_node_network_interface.py +++ b/ironic/db/sqlalchemy/alembic/versions/e294876e8028_add_node_network_interface.py @@ -18,13 +18,13 @@ Create Date: 2016-03-02 14:30:54.402864 """ +from alembic import op +import sqlalchemy as sa + # revision identifiers, used by Alembic. revision = 'e294876e8028' down_revision = 'f6fdb920c182' -from alembic import op -import sqlalchemy as sa - def upgrade(): op.add_column('nodes', sa.Column('network_interface', sa.String(255), diff --git a/ironic/db/sqlalchemy/alembic/versions/e918ff30eb42_resize_column_nodes_instance_info.py b/ironic/db/sqlalchemy/alembic/versions/e918ff30eb42_resize_column_nodes_instance_info.py index cc03f3b3bc..473367c0f8 100644 --- a/ironic/db/sqlalchemy/alembic/versions/e918ff30eb42_resize_column_nodes_instance_info.py +++ b/ironic/db/sqlalchemy/alembic/versions/e918ff30eb42_resize_column_nodes_instance_info.py @@ -18,13 +18,13 @@ Create Date: 2016-06-28 13:30:19.396203 """ +from alembic import op +from oslo_db.sqlalchemy import types as db_types + # revision identifiers, used by Alembic. revision = 'e918ff30eb42' down_revision = 'b4130a7fc904' -from alembic import op -from oslo_db.sqlalchemy import types as db_types - def upgrade(): op.alter_column('nodes', 'instance_info', diff --git a/ironic/db/sqlalchemy/alembic/versions/f6fdb920c182_set_pxe_enabled_true.py b/ironic/db/sqlalchemy/alembic/versions/f6fdb920c182_set_pxe_enabled_true.py index 1dc5e28236..1b758e720d 100644 --- a/ironic/db/sqlalchemy/alembic/versions/f6fdb920c182_set_pxe_enabled_true.py +++ b/ironic/db/sqlalchemy/alembic/versions/f6fdb920c182_set_pxe_enabled_true.py @@ -18,14 +18,14 @@ Create Date: 2016-02-12 16:53:21.008580 """ -# revision identifiers, used by Alembic. -revision = 'f6fdb920c182' -down_revision = '5ea1b0d310e' - from alembic import op from sqlalchemy import Boolean, String from sqlalchemy.sql import table, column, null +# revision identifiers, used by Alembic. +revision = 'f6fdb920c182' +down_revision = '5ea1b0d310e' + port = table('ports', column('uuid', String(36)), column('pxe_enabled', Boolean())) diff --git a/ironic/tests/base.py b/ironic/tests/base.py index 5a3851bd01..61e5ad0695 100644 --- a/ironic/tests/base.py +++ b/ironic/tests/base.py @@ -28,9 +28,8 @@ import sys import tempfile import eventlet -eventlet.monkey_patch(os=False) - -import fixtures # noqa for I202 due to 'import eventlet' above +eventlet.monkey_patch(os=False) # noqa E402 +import fixtures from ironic_lib import utils from oslo_concurrency import processutils from oslo_config import fixture as config_fixture diff --git a/ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py b/ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py index 4b1e93f597..ea0b147901 100644 --- a/ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py +++ b/ironic/tests/unit/drivers/modules/ilo/test_firmware_processor.py @@ -13,17 +13,13 @@ # under the License. """Test class for Firmware Processor used by iLO management interface.""" +import io import mock from oslo_utils import importutils -import six from six.moves import builtins as __builtin__ import six.moves.urllib.parse as urlparse -if six.PY3: - import io - file = io.BytesIO - from ironic.common import exception from ironic.drivers.modules.ilo import common as ilo_common from ironic.drivers.modules.ilo import firmware_processor as ilo_fw_processor @@ -380,7 +376,7 @@ class FirmwareProcessorTestCase(base.TestCase): def test__download_file_based_fw_to_copies_file_to_target( self, file_image_service_mock, open_mock): # | GIVEN | - fd_mock = mock.MagicMock(spec=file) + fd_mock = mock.MagicMock(spec=io.BytesIO) open_mock.return_value = fd_mock fd_mock.__enter__.return_value = fd_mock any_file_based_firmware_file = 'file:///tmp/any_file_path' @@ -399,7 +395,7 @@ class FirmwareProcessorTestCase(base.TestCase): def test__download_http_based_fw_to_downloads_the_fw_file( self, image_service_mock, open_mock): # | GIVEN | - fd_mock = mock.MagicMock(spec=file) + fd_mock = mock.MagicMock(spec=io.BytesIO) open_mock.return_value = fd_mock fd_mock.__enter__.return_value = fd_mock any_http_based_firmware_file = 'http://netloc/path_to_firmware_file' diff --git a/ironic/tests/unit/drivers/modules/xclarity/test_power.py b/ironic/tests/unit/drivers/modules/xclarity/test_power.py index c459e34274..9d1cde2bf8 100644 --- a/ironic/tests/unit/drivers/modules/xclarity/test_power.py +++ b/ironic/tests/unit/drivers/modules/xclarity/test_power.py @@ -13,11 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -STATE_POWER_ON = "power on" -STATE_POWER_OFF = "power off" -STATE_POWERING_ON = "power on" -STATE_POWERING_OFF = "power on" - import sys import mock @@ -34,6 +29,11 @@ from ironic.tests.unit.db import base as db_base from ironic.tests.unit.db import utils as db_utils from ironic.tests.unit.objects import utils as obj_utils +STATE_POWER_ON = "power on" +STATE_POWER_OFF = "power off" +STATE_POWERING_ON = "power on" +STATE_POWERING_OFF = "power on" + xclarity_constants = importutils.try_import('xclarity_client.constants') xclarity_client_exceptions = importutils.try_import( 'xclarity_client.exceptions') diff --git a/tox.ini b/tox.ini index 589792f820..192a12bc22 100644 --- a/tox.ini +++ b/tox.ini @@ -101,10 +101,8 @@ setenv = PYTHONHASHSEED=0 commands = {posargs} [flake8] -# TODO(jlvillal): We should fix the E402 errors -# [E402] Module level import not at top of file # [W503] Line break before binary operator. -ignore = E129,E402,W503 +ignore = E129,W503 filename = *.py,app.wsgi exclude = .venv,.git,.tox,dist,doc,*lib/python*,*egg,build import-order-style = pep8