diff --git a/nova/cmd/baremetal_manage.py b/nova/cmd/baremetal_manage.py index eaf4a8416e..dc31e145a2 100644 --- a/nova/cmd/baremetal_manage.py +++ b/nova/cmd/baremetal_manage.py @@ -105,8 +105,10 @@ CATEGORIES = { def methods_of(obj): - """Get all callable methods of an object that don't start with underscore - returns a list of tuples of the form (method_name, method)""" + """Get all callable methods of an object that don't start with underscore. + + Returns a list of tuples of the form (method_name, method) + """ result = [] for i in dir(obj): if callable(getattr(obj, i)) and not i.startswith('_'): diff --git a/nova/tests/baremetal/__init__.py b/nova/tests/baremetal/__init__.py index f15d84efc5..615e3d2824 100644 --- a/nova/tests/baremetal/__init__.py +++ b/nova/tests/baremetal/__init__.py @@ -1,6 +1,6 @@ # Copyright (c) 2012 NTT DOCOMO, INC. # All Rights Reserved. -# +# flake8: noqa # 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 diff --git a/nova/tests/baremetal/db/__init__.py b/nova/tests/baremetal/db/__init__.py index 543dfc1ae9..5bedee0a6b 100644 --- a/nova/tests/baremetal/db/__init__.py +++ b/nova/tests/baremetal/db/__init__.py @@ -1,5 +1,6 @@ # Copyright (c) 2012 NTT DOCOMO, INC. # All Rights Reserved. +# flake8: noqa # # 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 diff --git a/nova/tests/baremetal/test_pxe.py b/nova/tests/baremetal/test_pxe.py index 50fe167156..8b4995dad0 100644 --- a/nova/tests/baremetal/test_pxe.py +++ b/nova/tests/baremetal/test_pxe.py @@ -442,7 +442,7 @@ class PXEPublicMethodsTestCase(BareMetalPXETestCase): iqn = "iqn-%s" % self.instance['uuid'] pxe_config = 'this is a fake pxe config' pxe_path = pxe.get_pxe_config_file_path(self.instance) - image_path = pxe.get_image_file_path(self.instance) + pxe.get_image_file_path(self.instance) self.mox.StubOutWithMock(self.driver.virtapi, 'instance_type_get') self.mox.StubOutWithMock(pxe, 'get_tftp_image_info') diff --git a/nova/tests/baremetal/test_tilera.py b/nova/tests/baremetal/test_tilera.py index f92e9b2709..9127c9383c 100755 --- a/nova/tests/baremetal/test_tilera.py +++ b/nova/tests/baremetal/test_tilera.py @@ -304,11 +304,9 @@ class TileraPublicMethodsTestCase(BareMetalTileraTestCase): 'kernel': [None, 'cccc'], } self.instance['uuid'] = 'fake-uuid' - iqn = "iqn-%s" % self.instance['uuid'] - tilera_config = 'this is a fake tilera config' self.instance['uuid'] = 'fake-uuid' - tilera_path = tilera.get_tilera_nfs_path(self.instance) - image_path = tilera.get_image_file_path(self.instance) + tilera.get_tilera_nfs_path(self.instance) + tilera.get_image_file_path(self.instance) self.mox.StubOutWithMock(tilera, 'get_tftp_image_info') self.mox.StubOutWithMock(tilera, 'get_partition_sizes') @@ -325,8 +323,8 @@ class TileraPublicMethodsTestCase(BareMetalTileraTestCase): def test_activate_and_deactivate_bootloader(self): self._create_node() self.instance['uuid'] = 'fake-uuid' - tilera_path = tilera.get_tilera_nfs_path(self.instance) - image_path = tilera.get_image_file_path(self.instance) + tilera.get_tilera_nfs_path(self.instance) + tilera.get_image_file_path(self.instance) self.mox.ReplayAll() @@ -356,8 +354,6 @@ class TileraPublicMethodsTestCase(BareMetalTileraTestCase): self.mox.StubOutWithMock(tilera, 'get_tftp_image_info') self.mox.StubOutWithMock(self.driver, '_collect_mac_addresses') - tilera_path = tilera.get_tilera_nfs_path(self.node['id']) - tilera.get_tftp_image_info(self.instance).\ AndRaise(exception.NovaException) self.driver._collect_mac_addresses(self.context, self.node).\ diff --git a/nova/virt/baremetal/db/__init__.py b/nova/virt/baremetal/db/__init__.py index ad883f505c..a18c0ea5f1 100644 --- a/nova/virt/baremetal/db/__init__.py +++ b/nova/virt/baremetal/db/__init__.py @@ -1,6 +1,6 @@ # Copyright (c) 2012 NTT DOCOMO, INC. # All Rights Reserved. -# +# flake8: noqa # 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 diff --git a/nova/virt/baremetal/db/sqlalchemy/api.py b/nova/virt/baremetal/db/sqlalchemy/api.py index 88d44e3d30..ba9b5e32f1 100644 --- a/nova/virt/baremetal/db/sqlalchemy/api.py +++ b/nova/virt/baremetal/db/sqlalchemy/api.py @@ -92,7 +92,7 @@ def bm_node_get_all(context, service_host=None): @sqlalchemy_api.require_admin_context def bm_node_get_associated(context, service_host=None): query = model_query(context, models.BareMetalNode, read_deleted="no").\ - filter(models.BareMetalNode.instance_uuid != None) + filter(models.BareMetalNode.instance_uuid is not None) if service_host: query = query.filter_by(service_host=service_host) return query.all() @@ -101,7 +101,7 @@ def bm_node_get_associated(context, service_host=None): @sqlalchemy_api.require_admin_context def bm_node_get_unassociated(context, service_host=None): query = model_query(context, models.BareMetalNode, read_deleted="no").\ - filter(models.BareMetalNode.instance_uuid == None) + filter(models.BareMetalNode.instance_uuid is None) if service_host: query = query.filter_by(service_host=service_host) return query.all() @@ -111,7 +111,7 @@ def bm_node_get_unassociated(context, service_host=None): def bm_node_find_free(context, service_host=None, cpus=None, memory_mb=None, local_gb=None): query = model_query(context, models.BareMetalNode, read_deleted="no") - query = query.filter(models.BareMetalNode.instance_uuid == None) + query = query.filter(models.BareMetalNode.instance_uuid is None) if service_host: query = query.filter_by(service_host=service_host) if cpus is not None: diff --git a/nova/virt/baremetal/ipmi.py b/nova/virt/baremetal/ipmi.py index d4377e6fac..117dc342b4 100644 --- a/nova/virt/baremetal/ipmi.py +++ b/nova/virt/baremetal/ipmi.py @@ -105,16 +105,16 @@ class IPMI(base.PowerManager): self.password = node['pm_password'] self.port = node['terminal_port'] - if self.node_id == None: + if self.node_id is None: raise exception.InvalidParameterValue(_("Node id not supplied " "to IPMI")) - if self.address == None: + if self.address is None: raise exception.InvalidParameterValue(_("Address not supplied " "to IPMI")) - if self.user == None: + if self.user is None: raise exception.InvalidParameterValue(_("User not supplied " "to IPMI")) - if self.password == None: + if self.password is None: raise exception.InvalidParameterValue(_("Password not supplied " "to IPMI")) diff --git a/nova/virt/baremetal/pxe.py b/nova/virt/baremetal/pxe.py index 795099ebcf..be25446bb4 100644 --- a/nova/virt/baremetal/pxe.py +++ b/nova/virt/baremetal/pxe.py @@ -216,7 +216,7 @@ def get_tftp_image_info(instance, instance_type): image_info['ramdisk'][0] = str(instance['ramdisk_id']) image_info['deploy_kernel'][0] = get_deploy_aki_id(instance_type) image_info['deploy_ramdisk'][0] = get_deploy_ari_id(instance_type) - except KeyError as e: + except KeyError: pass missing_labels = [] @@ -462,7 +462,7 @@ class PXE(base.NodeDriver): status = row.get('task_state') if (status == baremetal_states.DEPLOYING - and locals['started'] == False): + and locals['started'] is False): LOG.info(_("PXE deploy started for instance %s") % instance['uuid']) locals['started'] = True diff --git a/nova/virt/baremetal/tilera.py b/nova/virt/baremetal/tilera.py index c926817cd8..698a2ac88f 100755 --- a/nova/virt/baremetal/tilera.py +++ b/nova/virt/baremetal/tilera.py @@ -128,8 +128,7 @@ def get_partition_sizes(instance): def get_tftp_image_info(instance): - """ - Generate the paths for tftp files for this instance. + """Generate the paths for tftp files for this instance. Raises NovaException if - instance does not contain kernel_id @@ -139,7 +138,7 @@ def get_tftp_image_info(instance): } try: image_info['kernel'][0] = str(instance['kernel_id']) - except KeyError as e: + except KeyError: pass missing_labels = [] @@ -287,7 +286,6 @@ class Tilera(base.NodeDriver): kernel ./fs_node_id/ """ - image_info = get_tftp_image_info(instance) (root_mb, swap_mb) = get_partition_sizes(instance) tilera_nfs_path = get_tilera_nfs_path(node['id']) image_file_path = get_image_file_path(instance) @@ -333,7 +331,7 @@ class Tilera(base.NodeDriver): bm_utils.unlink_without_raise(path) try: - macs = self._collect_mac_addresses(context, node) + self._collect_mac_addresses(context, node) except db_exc.DBError: pass @@ -343,8 +341,7 @@ class Tilera(base.NodeDriver): os.path.join(CONF.baremetal.tftp_root, instance['uuid'])) def _iptables_set(self, node_ip, user_data): - """ - Sets security setting (iptables:port) if needed. + """Sets security setting (iptables:port) if needed. iptables -A INPUT -p tcp ! -s $IP --dport $PORT -j DROP /tftpboot/iptables_rule script sets iptables rule on the given node. @@ -367,7 +364,7 @@ class Tilera(base.NodeDriver): status = row.get('task_state') if (status == baremetal_states.DEPLOYING and - locals['started'] == False): + locals['started'] is False): LOG.info(_('Tilera deploy started for instance %s') % instance['uuid']) locals['started'] = True @@ -380,7 +377,7 @@ class Tilera(base.NodeDriver): user_data = instance['user_data'] try: self._iptables_set(node_ip, user_data) - except Exception as ex: + except Exception: self.deactivate_bootloader(context, node, instance) raise exception.NovaException(_("Node is " "unknown error state.")) diff --git a/nova/virt/baremetal/tilera_pdu.py b/nova/virt/baremetal/tilera_pdu.py index 86e6086aef..3b35f2ce63 100755 --- a/nova/virt/baremetal/tilera_pdu.py +++ b/nova/virt/baremetal/tilera_pdu.py @@ -78,22 +78,21 @@ class Pdu(base.PowerManager): self.password = node['pm_password'] self.port = node['terminal_port'] - if self.node_id == None: + if self.node_id is None: raise exception.InvalidParameterValue(_("Node id not supplied " "to PDU")) - if self.address == None: + if self.address is None: raise exception.InvalidParameterValue(_("Address not supplied " "to PDU")) - if self.user == None: + if self.user is None: raise exception.InvalidParameterValue(_("User not supplied " "to PDU")) - if self.password == None: + if self.password is None: raise exception.InvalidParameterValue(_("Password not supplied " "to PDU")) def _exec_pdutool(self, mode): - """ - Changes power state of the given node. + """Changes power state of the given node. According to the mode (1-ON, 2-OFF, 3-REBOOT), power state can be changed. /tftpboot/pdu_mgr script handles power management of @@ -108,8 +107,8 @@ class Pdu(base.PowerManager): return CONF.baremetal.tile_pdu_off else: try: - out = utils.execute(CONF.baremetal.tile_pdu_mgr, - CONF.baremetal.tile_pdu_ip, mode) + utils.execute(CONF.baremetal.tile_pdu_mgr, + CONF.baremetal.tile_pdu_ip, mode) time.sleep(CONF.baremetal.tile_power_wait) return mode except exception.ProcessExecutionError: diff --git a/nova/virt/baremetal/volume_driver.py b/nova/virt/baremetal/volume_driver.py index cc23f90646..a6a07131af 100644 --- a/nova/virt/baremetal/volume_driver.py +++ b/nova/virt/baremetal/volume_driver.py @@ -262,7 +262,5 @@ class LibvirtVolumeDriver(VolumeDriver): mount_device) def get_all_block_devices(self): - """ - Return all block devices in use on this node. - """ + """Return all block devices in use on this node.""" return _list_backingstore_path() diff --git a/tox.ini b/tox.ini index 5e0e314d79..b69a791cf7 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,6 @@ commands = commands = {posargs} [flake8] -ignore = E12,E711,E721,E712,H302,H303,H403,H404,F +ignore = E12 builtins = _ exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build