Enforce all flake8 rules except E129
Bring ironic-python-agent in line with the other ironic projects. Stop ignoring all E12* errors except E129 Stop ignoring E711 Change-Id: Icb9bc198473d1b5e807c20869eb2af7f4d7ac360
This commit is contained in:
parent
0144e79df5
commit
dcbba2b121
@ -144,7 +144,8 @@ def main():
|
||||
os.makedirs(output_dir)
|
||||
|
||||
output_kernel = os.path.join(output_dir, os.path.basename(kernel))
|
||||
output_cpio = os.path.join(output_dir,
|
||||
output_cpio = os.path.join(
|
||||
output_dir,
|
||||
os.path.basename(orig_cpio).replace('.cpio.gz', '-oem.cpio.gz'))
|
||||
inject_oem(orig_cpio, oem_dir, output_cpio)
|
||||
shutil.copy(kernel, output_kernel)
|
||||
|
@ -431,7 +431,8 @@ class GenericHardwareManager(HardwareManager):
|
||||
if hint_value != current_value:
|
||||
LOG.debug("Root device hint %(hint)s=%(value)s does not "
|
||||
"match the device %(device)s value of "
|
||||
"%(current)s", {'hint': hint,
|
||||
"%(current)s", {
|
||||
'hint': hint,
|
||||
'value': hint_value, 'device': device,
|
||||
'current': current_value})
|
||||
return False
|
||||
@ -465,7 +466,8 @@ class GenericHardwareManager(HardwareManager):
|
||||
return dev.name
|
||||
|
||||
else:
|
||||
raise errors.DeviceNotFound("No suitable device was found for "
|
||||
raise errors.DeviceNotFound(
|
||||
"No suitable device was found for "
|
||||
"deployment using these hints %s" % root_device_hints)
|
||||
|
||||
def erase_block_device(self, node, block_device):
|
||||
@ -552,12 +554,14 @@ class GenericHardwareManager(HardwareManager):
|
||||
return False
|
||||
|
||||
if 'enabled' in security_lines:
|
||||
raise errors.BlockDeviceEraseError(('Block device {0} already has '
|
||||
'a security password set').format(block_device.name))
|
||||
raise errors.BlockDeviceEraseError(
|
||||
('Block device {0} already has a security password set'
|
||||
).format(block_device.name))
|
||||
|
||||
if 'not frozen' not in security_lines:
|
||||
raise errors.BlockDeviceEraseError(('Block device {0} is frozen '
|
||||
'and cannot be erased').format(block_device.name))
|
||||
raise errors.BlockDeviceEraseError(
|
||||
('Block device {0} is frozen and cannot be erased'
|
||||
).format(block_device.name))
|
||||
|
||||
utils.execute('hdparm', '--user-master', 'u', '--security-set-pass',
|
||||
'NULL', block_device.name)
|
||||
@ -573,8 +577,9 @@ class GenericHardwareManager(HardwareManager):
|
||||
# Verify that security is now 'not enabled'
|
||||
security_lines = self._get_ata_security_lines(block_device)
|
||||
if 'not enabled' not in security_lines:
|
||||
raise errors.BlockDeviceEraseError(('An unknown error occurred '
|
||||
'erasing block device {0}').format(block_device.name))
|
||||
raise errors.BlockDeviceEraseError(
|
||||
('An unknown error occurred erasing block device {0}'
|
||||
).format(block_device.name))
|
||||
|
||||
return True
|
||||
|
||||
|
@ -33,9 +33,9 @@ class FunctionalBase(test_base.BaseTestCase):
|
||||
# Build a basic standalone agent using the config option defaults.
|
||||
# 127.0.0.1:6835 is the fake Ironic client.
|
||||
self.agent = agent.IronicPythonAgent(
|
||||
'http://127.0.0.1:6835', 'localhost', ('0.0.0.0',
|
||||
int(test_port)), 3, 10, None, 300, 1,
|
||||
'agent_ipmitool', True)
|
||||
'http://127.0.0.1:6835', 'localhost',
|
||||
('0.0.0.0', int(test_port)), 3, 10, None, 300, 1, 'agent_ipmitool',
|
||||
True)
|
||||
self.process = multiprocessing.Process(
|
||||
target=self.agent.run)
|
||||
self.process.start()
|
||||
@ -46,8 +46,8 @@ class FunctionalBase(test_base.BaseTestCase):
|
||||
max_tries = os.environ.get('IPA_WAIT_TIME', '2')
|
||||
while tries < int(max_tries):
|
||||
try:
|
||||
return requests.get('http://localhost:%s/v1/commands' %
|
||||
test_port)
|
||||
return requests.get(
|
||||
'http://localhost:%s/v1/commands' % test_port)
|
||||
except requests.ConnectionError:
|
||||
time.sleep(.1)
|
||||
tries += 1
|
||||
|
@ -20,7 +20,8 @@ from ironic_python_agent.tests.functional import base
|
||||
|
||||
class TestCommands(base.FunctionalBase):
|
||||
def test_empty_commands(self):
|
||||
commands = requests.get('http://localhost:%s/v1/commands' %
|
||||
os.environ.get('TEST_PORT', '9999'))
|
||||
commands = requests.get(
|
||||
'http://localhost:%s/v1/commands' % os.environ.get('TEST_PORT',
|
||||
'9999'))
|
||||
self.assertEqual(200, commands.status_code)
|
||||
self.assertEqual({'commands': []}, commands.json())
|
||||
|
@ -159,8 +159,8 @@ class TestImageExtension(test_base.BaseTestCase):
|
||||
@mock.patch.object(os, 'makedirs')
|
||||
@mock.patch.object(image, '_get_partition')
|
||||
def test__install_grub2_uefi_umount_fails(
|
||||
self, mock_get_part_uuid, mkdir_mock, environ_mock,
|
||||
mock_execute, mock_dispatch):
|
||||
self, mock_get_part_uuid, mkdir_mock, environ_mock, mock_execute,
|
||||
mock_dispatch):
|
||||
mock_get_part_uuid.side_effect = [self.fake_root_part,
|
||||
self.fake_efi_system_part]
|
||||
|
||||
@ -217,8 +217,7 @@ class TestImageExtension(test_base.BaseTestCase):
|
||||
KNAME="test2" UUID="%s" TYPE="part"''' % self.fake_root_uuid)
|
||||
mock_execute.side_effect = (None, None, [lsblk_output])
|
||||
|
||||
root_part = image._get_partition(self.fake_dev,
|
||||
self.fake_root_uuid)
|
||||
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
|
||||
self.assertEqual('/dev/test2', root_part)
|
||||
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
||||
delay_on_retry=True),
|
||||
|
@ -229,11 +229,14 @@ class TestHardwareManagerLoading(test_base.BaseTestCase):
|
||||
fake_ep = mock.Mock()
|
||||
fake_ep.module_name = 'fake'
|
||||
fake_ep.attrs = ['fake attrs']
|
||||
ext1 = extension.Extension('fake_generic0', fake_ep, None,
|
||||
ext1 = extension.Extension(
|
||||
'fake_generic0', fake_ep, None,
|
||||
FakeHardwareManager(hardware.HardwareSupport.GENERIC))
|
||||
ext2 = extension.Extension('fake_mainline0', fake_ep, None,
|
||||
ext2 = extension.Extension(
|
||||
'fake_mainline0', fake_ep, None,
|
||||
FakeHardwareManager(hardware.HardwareSupport.MAINLINE))
|
||||
ext3 = extension.Extension('fake_generic1', fake_ep, None,
|
||||
ext3 = extension.Extension(
|
||||
'fake_generic1', fake_ep, None,
|
||||
FakeHardwareManager(hardware.HardwareSupport.GENERIC))
|
||||
self.correct_hw_manager = ext2.obj
|
||||
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance([
|
||||
@ -670,8 +673,9 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
||||
True)
|
||||
res = self.hardware._shred_block_device(self.node, block_device)
|
||||
self.assertFalse(res)
|
||||
mocked_execute.assert_called_once_with('shred', '--force', '--zero',
|
||||
'--verbose', '--iterations', '1', '/dev/sda')
|
||||
mocked_execute.assert_called_once_with(
|
||||
'shred', '--force', '--zero', '--verbose', '--iterations', '1',
|
||||
'/dev/sda')
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_erase_block_device_shred_fail_processerror(self, mocked_execute):
|
||||
@ -680,8 +684,9 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
||||
True)
|
||||
res = self.hardware._shred_block_device(self.node, block_device)
|
||||
self.assertFalse(res)
|
||||
mocked_execute.assert_called_once_with('shred', '--force', '--zero',
|
||||
'--verbose', '--iterations', '1', '/dev/sda')
|
||||
mocked_execute.assert_called_once_with(
|
||||
'shred', '--force', '--zero', '--verbose', '--iterations', '1',
|
||||
'/dev/sda')
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_erase_block_device_ata_security_enabled(self, mocked_execute):
|
||||
@ -778,10 +783,10 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
||||
expected_option,
|
||||
'NULL', '/dev/sda')
|
||||
|
||||
test_security_erase_option(self,
|
||||
'\tsupported: enhanced erase', '--security-erase-enhanced')
|
||||
test_security_erase_option(self,
|
||||
'\tnot\tsupported: enhanced erase', '--security-erase')
|
||||
test_security_erase_option(
|
||||
self, '\tsupported: enhanced erase', '--security-erase-enhanced')
|
||||
test_security_erase_option(
|
||||
self, '\tnot\tsupported: enhanced erase', '--security-erase')
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_get_bmc_address(self, mocked_execute):
|
||||
|
@ -111,13 +111,12 @@ class TestMultipleHardwareManagerLoading(test_base.BaseTestCase):
|
||||
fake_ep = mock.Mock()
|
||||
fake_ep.module_name = 'fake'
|
||||
fake_ep.attrs = ['fake attrs']
|
||||
self.generic_hwm = extension.Extension('fake_generic', fake_ep, None,
|
||||
FakeGenericHardwareManager())
|
||||
self.mainline_hwm = extension.Extension('fake_mainline', fake_ep, None,
|
||||
FakeMainlineHardwareManager())
|
||||
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance([
|
||||
self.generic_hwm, self.mainline_hwm
|
||||
])
|
||||
self.generic_hwm = extension.Extension(
|
||||
'fake_generic', fake_ep, None, FakeGenericHardwareManager())
|
||||
self.mainline_hwm = extension.Extension(
|
||||
'fake_mainline', fake_ep, None, FakeMainlineHardwareManager())
|
||||
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance(
|
||||
[self.generic_hwm, self.mainline_hwm])
|
||||
|
||||
self.extension_mgr_patcher = mock.patch('stevedore.ExtensionManager')
|
||||
self.mocked_extension_mgr = self.extension_mgr_patcher.start()
|
||||
|
@ -80,9 +80,8 @@ exit 1
|
||||
fp = open(tmpfilename2, 'r')
|
||||
runs = fp.read()
|
||||
fp.close()
|
||||
self.assertNotEqual(runs.strip(), 'failure', 'stdin did not '
|
||||
'always get passed '
|
||||
'correctly')
|
||||
self.assertNotEqual(runs.strip(), 'failure',
|
||||
'stdin did not always get passed correctly')
|
||||
runs = int(runs.strip())
|
||||
self.assertEqual(10, runs,
|
||||
'Ran %d times instead of 10.' % (runs,))
|
||||
|
4
tox.ini
4
tox.ini
@ -56,9 +56,7 @@ commands =
|
||||
python setup.py build_sphinx
|
||||
|
||||
[flake8]
|
||||
# E711: ignored because it is normal to use "column == None" in sqlalchemy
|
||||
|
||||
ignore = E12,E711
|
||||
ignore = E129
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,*ironic/nova*,tools
|
||||
|
||||
[hacking]
|
||||
|
Loading…
x
Reference in New Issue
Block a user