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)
|
os.makedirs(output_dir)
|
||||||
|
|
||||||
output_kernel = os.path.join(output_dir, os.path.basename(kernel))
|
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'))
|
os.path.basename(orig_cpio).replace('.cpio.gz', '-oem.cpio.gz'))
|
||||||
inject_oem(orig_cpio, oem_dir, output_cpio)
|
inject_oem(orig_cpio, oem_dir, output_cpio)
|
||||||
shutil.copy(kernel, output_kernel)
|
shutil.copy(kernel, output_kernel)
|
||||||
|
@ -223,7 +223,7 @@ class IronicPythonAgent(base.ExecuteCommandMixin):
|
|||||||
be found.
|
be found.
|
||||||
"""
|
"""
|
||||||
iface_list = [iface.serialize()['name'] for iface in
|
iface_list = [iface.serialize()['name'] for iface in
|
||||||
hardware.dispatch_to_managers('list_network_interfaces')]
|
hardware.dispatch_to_managers('list_network_interfaces')]
|
||||||
iface_list = [name for name in iface_list if 'lo' not in name]
|
iface_list = [name for name in iface_list if 'lo' not in name]
|
||||||
|
|
||||||
if len(iface_list) == 0:
|
if len(iface_list) == 0:
|
||||||
@ -287,7 +287,7 @@ class IronicPythonAgent(base.ExecuteCommandMixin):
|
|||||||
|
|
||||||
content = self.api_client.lookup_node(
|
content = self.api_client.lookup_node(
|
||||||
hardware_info=hardware.dispatch_to_managers(
|
hardware_info=hardware.dispatch_to_managers(
|
||||||
'list_hardware_info'),
|
'list_hardware_info'),
|
||||||
timeout=self.lookup_timeout,
|
timeout=self.lookup_timeout,
|
||||||
starting_interval=self.lookup_interval,
|
starting_interval=self.lookup_interval,
|
||||||
node_uuid=uuid)
|
node_uuid=uuid)
|
||||||
|
@ -28,14 +28,14 @@ APARAMS = utils.get_agent_params()
|
|||||||
|
|
||||||
cli_opts = [
|
cli_opts = [
|
||||||
cfg.StrOpt('api_url',
|
cfg.StrOpt('api_url',
|
||||||
default=APARAMS.get('ipa-api-url', 'http://127.0.0.1:6385'),
|
default=APARAMS.get('ipa-api-url', 'http://127.0.0.1:6385'),
|
||||||
deprecated_name='api-url',
|
deprecated_name='api-url',
|
||||||
help='URL of the Ironic API'),
|
help='URL of the Ironic API'),
|
||||||
|
|
||||||
cfg.StrOpt('listen_host',
|
cfg.StrOpt('listen_host',
|
||||||
default=APARAMS.get('ipa-listen-host', '0.0.0.0'),
|
default=APARAMS.get('ipa-listen-host', '0.0.0.0'),
|
||||||
deprecated_name='listen-host',
|
deprecated_name='listen-host',
|
||||||
help='The IP address to listen on.'),
|
help='The IP address to listen on.'),
|
||||||
|
|
||||||
cfg.IntOpt('listen_port',
|
cfg.IntOpt('listen_port',
|
||||||
default=int(APARAMS.get('ipa-listen-port', 9999)),
|
default=int(APARAMS.get('ipa-listen-port', 9999)),
|
||||||
@ -43,10 +43,10 @@ cli_opts = [
|
|||||||
help='The port to listen on'),
|
help='The port to listen on'),
|
||||||
|
|
||||||
cfg.StrOpt('advertise_host',
|
cfg.StrOpt('advertise_host',
|
||||||
default=APARAMS.get('ipa-advertise-host', None),
|
default=APARAMS.get('ipa-advertise-host', None),
|
||||||
deprecated_name='advertise_host',
|
deprecated_name='advertise_host',
|
||||||
help='The host to tell Ironic to reply and send '
|
help='The host to tell Ironic to reply and send '
|
||||||
'commands to.'),
|
'commands to.'),
|
||||||
|
|
||||||
cfg.IntOpt('advertise_port',
|
cfg.IntOpt('advertise_port',
|
||||||
default=int(APARAMS.get('ipa-advertise-port', 9999)),
|
default=int(APARAMS.get('ipa-advertise-port', 9999)),
|
||||||
@ -88,9 +88,9 @@ cli_opts = [
|
|||||||
'exceeded.'),
|
'exceeded.'),
|
||||||
|
|
||||||
cfg.StrOpt('driver_name',
|
cfg.StrOpt('driver_name',
|
||||||
default=APARAMS.get('ipa-driver-name', 'agent_ipmitool'),
|
default=APARAMS.get('ipa-driver-name', 'agent_ipmitool'),
|
||||||
deprecated_name='driver-name',
|
deprecated_name='driver-name',
|
||||||
help='The Ironic driver in use for this node'),
|
help='The Ironic driver in use for this node'),
|
||||||
|
|
||||||
cfg.FloatOpt('lldp_timeout',
|
cfg.FloatOpt('lldp_timeout',
|
||||||
default=APARAMS.get('lldp-timeout', 30.0),
|
default=APARAMS.get('lldp-timeout', 30.0),
|
||||||
|
@ -150,7 +150,7 @@ def _download_image(image_info):
|
|||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = 'Unable to write image to {0}. Error: {1}'.format(
|
msg = 'Unable to write image to {0}. Error: {1}'.format(
|
||||||
image_location, str(e))
|
image_location, str(e))
|
||||||
raise errors.ImageDownloadError(image_info['id'], msg)
|
raise errors.ImageDownloadError(image_info['id'], msg)
|
||||||
|
|
||||||
totaltime = time.time() - starttime
|
totaltime = time.time() - starttime
|
||||||
|
@ -358,7 +358,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
|
|
||||||
def _is_device(self, interface_name):
|
def _is_device(self, interface_name):
|
||||||
device_path = '{0}/class/net/{1}/device'.format(self.sys_path,
|
device_path = '{0}/class/net/{1}/device'.format(self.sys_path,
|
||||||
interface_name)
|
interface_name)
|
||||||
return os.path.exists(device_path)
|
return os.path.exists(device_path)
|
||||||
|
|
||||||
def list_network_interfaces(self):
|
def list_network_interfaces(self):
|
||||||
@ -431,9 +431,10 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
if hint_value != current_value:
|
if hint_value != current_value:
|
||||||
LOG.debug("Root device hint %(hint)s=%(value)s does not "
|
LOG.debug("Root device hint %(hint)s=%(value)s does not "
|
||||||
"match the device %(device)s value of "
|
"match the device %(device)s value of "
|
||||||
"%(current)s", {'hint': hint,
|
"%(current)s", {
|
||||||
'value': hint_value, 'device': device,
|
'hint': hint,
|
||||||
'current': current_value})
|
'value': hint_value, 'device': device,
|
||||||
|
'current': current_value})
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -465,7 +466,8 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
return dev.name
|
return dev.name
|
||||||
|
|
||||||
else:
|
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)
|
"deployment using these hints %s" % root_device_hints)
|
||||||
|
|
||||||
def erase_block_device(self, node, block_device):
|
def erase_block_device(self, node, block_device):
|
||||||
@ -483,7 +485,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
return
|
return
|
||||||
|
|
||||||
msg = ('Unable to erase block device {0}: device is unsupported.'
|
msg = ('Unable to erase block device {0}: device is unsupported.'
|
||||||
).format(block_device.name)
|
).format(block_device.name)
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise errors.IncompatibleHardwareMethodError(msg)
|
raise errors.IncompatibleHardwareMethodError(msg)
|
||||||
|
|
||||||
@ -501,7 +503,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
'--iterations', str(npasses), block_device.name)
|
'--iterations', str(npasses), block_device.name)
|
||||||
except (processutils.ProcessExecutionError, OSError) as e:
|
except (processutils.ProcessExecutionError, OSError) as e:
|
||||||
msg = ("Erasing block device %(dev)s failed with error %(err)s ",
|
msg = ("Erasing block device %(dev)s failed with error %(err)s ",
|
||||||
{'dev': block_device.name, 'err': e})
|
{'dev': block_device.name, 'err': e})
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -517,7 +519,7 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
if os.path.exists(vm_device_label):
|
if os.path.exists(vm_device_label):
|
||||||
link = os.readlink(vm_device_label)
|
link = os.readlink(vm_device_label)
|
||||||
device = os.path.normpath(os.path.join(os.path.dirname(
|
device = os.path.normpath(os.path.join(os.path.dirname(
|
||||||
vm_device_label), link))
|
vm_device_label), link))
|
||||||
if block_device.name == device:
|
if block_device.name == device:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -552,12 +554,14 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if 'enabled' in security_lines:
|
if 'enabled' in security_lines:
|
||||||
raise errors.BlockDeviceEraseError(('Block device {0} already has '
|
raise errors.BlockDeviceEraseError(
|
||||||
'a security password set').format(block_device.name))
|
('Block device {0} already has a security password set'
|
||||||
|
).format(block_device.name))
|
||||||
|
|
||||||
if 'not frozen' not in security_lines:
|
if 'not frozen' not in security_lines:
|
||||||
raise errors.BlockDeviceEraseError(('Block device {0} is frozen '
|
raise errors.BlockDeviceEraseError(
|
||||||
'and cannot be erased').format(block_device.name))
|
('Block device {0} is frozen and cannot be erased'
|
||||||
|
).format(block_device.name))
|
||||||
|
|
||||||
utils.execute('hdparm', '--user-master', 'u', '--security-set-pass',
|
utils.execute('hdparm', '--user-master', 'u', '--security-set-pass',
|
||||||
'NULL', block_device.name)
|
'NULL', block_device.name)
|
||||||
@ -573,8 +577,9 @@ class GenericHardwareManager(HardwareManager):
|
|||||||
# Verify that security is now 'not enabled'
|
# Verify that security is now 'not enabled'
|
||||||
security_lines = self._get_ata_security_lines(block_device)
|
security_lines = self._get_ata_security_lines(block_device)
|
||||||
if 'not enabled' not in security_lines:
|
if 'not enabled' not in security_lines:
|
||||||
raise errors.BlockDeviceEraseError(('An unknown error occurred '
|
raise errors.BlockDeviceEraseError(
|
||||||
'erasing block device {0}').format(block_device.name))
|
('An unknown error occurred erasing block device {0}'
|
||||||
|
).format(block_device.name))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -625,7 +630,7 @@ def _get_managers():
|
|||||||
extensions = sorted(extension_manager, _compare_extensions)
|
extensions = sorted(extension_manager, _compare_extensions)
|
||||||
else:
|
else:
|
||||||
extensions = sorted(extension_manager,
|
extensions = sorted(extension_manager,
|
||||||
key=functools.cmp_to_key(_compare_extensions))
|
key=functools.cmp_to_key(_compare_extensions))
|
||||||
|
|
||||||
preferred_managers = []
|
preferred_managers = []
|
||||||
|
|
||||||
@ -712,7 +717,7 @@ def dispatch_to_managers(method, *args, **kwargs):
|
|||||||
return getattr(manager, method)(*args, **kwargs)
|
return getattr(manager, method)(*args, **kwargs)
|
||||||
except(errors.IncompatibleHardwareMethodError):
|
except(errors.IncompatibleHardwareMethodError):
|
||||||
LOG.debug('HardwareManager {0} does not support {1}'
|
LOG.debug('HardwareManager {0} does not support {1}'
|
||||||
.format(manager, method))
|
.format(manager, method))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.exception('Unexpected error dispatching %(method)s to '
|
LOG.exception('Unexpected error dispatching %(method)s to '
|
||||||
'manager %(manager)s: %(e)s',
|
'manager %(manager)s: %(e)s',
|
||||||
|
@ -33,9 +33,9 @@ class FunctionalBase(test_base.BaseTestCase):
|
|||||||
# Build a basic standalone agent using the config option defaults.
|
# Build a basic standalone agent using the config option defaults.
|
||||||
# 127.0.0.1:6835 is the fake Ironic client.
|
# 127.0.0.1:6835 is the fake Ironic client.
|
||||||
self.agent = agent.IronicPythonAgent(
|
self.agent = agent.IronicPythonAgent(
|
||||||
'http://127.0.0.1:6835', 'localhost', ('0.0.0.0',
|
'http://127.0.0.1:6835', 'localhost',
|
||||||
int(test_port)), 3, 10, None, 300, 1,
|
('0.0.0.0', int(test_port)), 3, 10, None, 300, 1, 'agent_ipmitool',
|
||||||
'agent_ipmitool', True)
|
True)
|
||||||
self.process = multiprocessing.Process(
|
self.process = multiprocessing.Process(
|
||||||
target=self.agent.run)
|
target=self.agent.run)
|
||||||
self.process.start()
|
self.process.start()
|
||||||
@ -46,8 +46,8 @@ class FunctionalBase(test_base.BaseTestCase):
|
|||||||
max_tries = os.environ.get('IPA_WAIT_TIME', '2')
|
max_tries = os.environ.get('IPA_WAIT_TIME', '2')
|
||||||
while tries < int(max_tries):
|
while tries < int(max_tries):
|
||||||
try:
|
try:
|
||||||
return requests.get('http://localhost:%s/v1/commands' %
|
return requests.get(
|
||||||
test_port)
|
'http://localhost:%s/v1/commands' % test_port)
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
time.sleep(.1)
|
time.sleep(.1)
|
||||||
tries += 1
|
tries += 1
|
||||||
|
@ -20,7 +20,8 @@ from ironic_python_agent.tests.functional import base
|
|||||||
|
|
||||||
class TestCommands(base.FunctionalBase):
|
class TestCommands(base.FunctionalBase):
|
||||||
def test_empty_commands(self):
|
def test_empty_commands(self):
|
||||||
commands = requests.get('http://localhost:%s/v1/commands' %
|
commands = requests.get(
|
||||||
os.environ.get('TEST_PORT', '9999'))
|
'http://localhost:%s/v1/commands' % os.environ.get('TEST_PORT',
|
||||||
|
'9999'))
|
||||||
self.assertEqual(200, commands.status_code)
|
self.assertEqual(200, commands.status_code)
|
||||||
self.assertEqual({'commands': []}, commands.json())
|
self.assertEqual({'commands': []}, commands.json())
|
||||||
|
@ -134,7 +134,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
|
|||||||
result.command_status)
|
result.command_status)
|
||||||
self.assertEqual(None, result.command_error)
|
self.assertEqual(None, result.command_error)
|
||||||
self.assertEqual({'result': 'fake_async_command: v1'},
|
self.assertEqual({'result': 'fake_async_command: v1'},
|
||||||
result.command_result)
|
result.command_result)
|
||||||
self.agent.force_heartbeat.assert_called_once_with()
|
self.agent.force_heartbeat.assert_called_once_with()
|
||||||
|
|
||||||
def test_async_command_success_without_agent(self):
|
def test_async_command_success_without_agent(self):
|
||||||
@ -148,7 +148,7 @@ class TestExtensionDecorators(test_base.BaseTestCase):
|
|||||||
result.command_status)
|
result.command_status)
|
||||||
self.assertEqual(None, result.command_error)
|
self.assertEqual(None, result.command_error)
|
||||||
self.assertEqual({'result': 'fake_async_command: v1'},
|
self.assertEqual({'result': 'fake_async_command: v1'},
|
||||||
result.command_result)
|
result.command_result)
|
||||||
|
|
||||||
def test_async_command_validation_failure(self):
|
def test_async_command_validation_failure(self):
|
||||||
self.assertRaises(errors.InvalidCommandParamsError,
|
self.assertRaises(errors.InvalidCommandParamsError,
|
||||||
|
@ -85,7 +85,7 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
self.fake_dir + '/proc'),
|
self.fake_dir + '/proc'),
|
||||||
mock.call(('chroot %s /bin/bash -c '
|
mock.call(('chroot %s /bin/bash -c '
|
||||||
'"/usr/sbin/grub-install %s"' %
|
'"/usr/sbin/grub-install %s"' %
|
||||||
(self.fake_dir, self.fake_dev)), shell=True,
|
(self.fake_dir, self.fake_dev)), shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin'}),
|
||||||
mock.call(('chroot %s /bin/bash -c '
|
mock.call(('chroot %s /bin/bash -c '
|
||||||
'"/usr/sbin/grub-mkconfig -o '
|
'"/usr/sbin/grub-mkconfig -o '
|
||||||
@ -130,7 +130,7 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
self.fake_dir + '/boot/efi'),
|
self.fake_dir + '/boot/efi'),
|
||||||
mock.call(('chroot %s /bin/bash -c '
|
mock.call(('chroot %s /bin/bash -c '
|
||||||
'"/usr/sbin/grub-install %s"' %
|
'"/usr/sbin/grub-install %s"' %
|
||||||
(self.fake_dir, self.fake_dev)), shell=True,
|
(self.fake_dir, self.fake_dev)), shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin'}),
|
||||||
mock.call(('chroot %s /bin/bash -c '
|
mock.call(('chroot %s /bin/bash -c '
|
||||||
'"/usr/sbin/grub-mkconfig -o '
|
'"/usr/sbin/grub-mkconfig -o '
|
||||||
@ -159,8 +159,8 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
@mock.patch.object(os, 'makedirs')
|
@mock.patch.object(os, 'makedirs')
|
||||||
@mock.patch.object(image, '_get_partition')
|
@mock.patch.object(image, '_get_partition')
|
||||||
def test__install_grub2_uefi_umount_fails(
|
def test__install_grub2_uefi_umount_fails(
|
||||||
self, mock_get_part_uuid, mkdir_mock, environ_mock,
|
self, mock_get_part_uuid, mkdir_mock, environ_mock, mock_execute,
|
||||||
mock_execute, mock_dispatch):
|
mock_dispatch):
|
||||||
mock_get_part_uuid.side_effect = [self.fake_root_part,
|
mock_get_part_uuid.side_effect = [self.fake_root_part,
|
||||||
self.fake_efi_system_part]
|
self.fake_efi_system_part]
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
self.fake_dir + '/boot/efi'),
|
self.fake_dir + '/boot/efi'),
|
||||||
mock.call(('chroot %s /bin/bash -c '
|
mock.call(('chroot %s /bin/bash -c '
|
||||||
'"/usr/sbin/grub-install %s"' %
|
'"/usr/sbin/grub-install %s"' %
|
||||||
(self.fake_dir, self.fake_dev)), shell=True,
|
(self.fake_dir, self.fake_dev)), shell=True,
|
||||||
env_variables={'PATH': '/sbin:/bin'}),
|
env_variables={'PATH': '/sbin:/bin'}),
|
||||||
mock.call(('chroot %s /bin/bash -c '
|
mock.call(('chroot %s /bin/bash -c '
|
||||||
'"/usr/sbin/grub-mkconfig -o '
|
'"/usr/sbin/grub-mkconfig -o '
|
||||||
@ -217,8 +217,7 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
KNAME="test2" UUID="%s" TYPE="part"''' % self.fake_root_uuid)
|
KNAME="test2" UUID="%s" TYPE="part"''' % self.fake_root_uuid)
|
||||||
mock_execute.side_effect = (None, None, [lsblk_output])
|
mock_execute.side_effect = (None, None, [lsblk_output])
|
||||||
|
|
||||||
root_part = image._get_partition(self.fake_dev,
|
root_part = image._get_partition(self.fake_dev, self.fake_root_uuid)
|
||||||
self.fake_root_uuid)
|
|
||||||
self.assertEqual('/dev/test2', root_part)
|
self.assertEqual('/dev/test2', root_part)
|
||||||
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
expected = [mock.call('partx', '-u', self.fake_dev, attempts=3,
|
||||||
delay_on_retry=True),
|
delay_on_retry=True),
|
||||||
@ -228,7 +227,7 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
self.assertFalse(mock_dispatch.called)
|
self.assertFalse(mock_dispatch.called)
|
||||||
|
|
||||||
def test__get_partition_no_device_found(self, mock_execute,
|
def test__get_partition_no_device_found(self, mock_execute,
|
||||||
mock_dispatch):
|
mock_dispatch):
|
||||||
lsblk_output = ('''KNAME="test" UUID="" TYPE="disk"
|
lsblk_output = ('''KNAME="test" UUID="" TYPE="disk"
|
||||||
KNAME="test1" UUID="256a39e3-ca3c-4fb8-9cc2-b32eec441f47" TYPE="part"
|
KNAME="test1" UUID="256a39e3-ca3c-4fb8-9cc2-b32eec441f47" TYPE="part"
|
||||||
KNAME="test2" UUID="" TYPE="part"''')
|
KNAME="test2" UUID="" TYPE="part"''')
|
||||||
@ -245,7 +244,7 @@ class TestImageExtension(test_base.BaseTestCase):
|
|||||||
self.assertFalse(mock_dispatch.called)
|
self.assertFalse(mock_dispatch.called)
|
||||||
|
|
||||||
def test__get_partition_command_fail(self, mock_execute,
|
def test__get_partition_command_fail(self, mock_execute,
|
||||||
mock_dispatch):
|
mock_dispatch):
|
||||||
mock_execute.side_effect = (None, None,
|
mock_execute.side_effect = (None, None,
|
||||||
processutils.ProcessExecutionError('boom'))
|
processutils.ProcessExecutionError('boom'))
|
||||||
self.assertRaises(errors.CommandExecutionError,
|
self.assertRaises(errors.CommandExecutionError,
|
||||||
|
@ -63,7 +63,7 @@ class TestISCSIExtension(test_base.BaseTestCase):
|
|||||||
mock_dispatch.assert_called_once_with('get_os_install_device')
|
mock_dispatch.assert_called_once_with('get_os_install_device')
|
||||||
mock_wait_iscsi.assert_called_once_with()
|
mock_wait_iscsi.assert_called_once_with()
|
||||||
self.assertEqual({'iscsi_target_iqn': self.fake_iqn},
|
self.assertEqual({'iscsi_target_iqn': self.fake_iqn},
|
||||||
result.command_result)
|
result.command_result)
|
||||||
|
|
||||||
@mock.patch.object(os.path, 'exists', lambda x: False)
|
@mock.patch.object(os.path, 'exists', lambda x: False)
|
||||||
def test_start_iscsi_target_fail_wait_daemon(self, mock_execute,
|
def test_start_iscsi_target_fail_wait_daemon(self, mock_execute,
|
||||||
|
@ -131,7 +131,7 @@ class TestErrors(test_base.BaseTestCase):
|
|||||||
(errors.IncompatibleHardwareMethodError(), DEFAULT_DETAILS),
|
(errors.IncompatibleHardwareMethodError(), DEFAULT_DETAILS),
|
||||||
(errors.IncompatibleHardwareMethodError(DETAILS),
|
(errors.IncompatibleHardwareMethodError(DETAILS),
|
||||||
SAME_DETAILS),
|
SAME_DETAILS),
|
||||||
]
|
]
|
||||||
for (obj, check_details) in cases:
|
for (obj, check_details) in cases:
|
||||||
self._test_class(obj, check_details)
|
self._test_class(obj, check_details)
|
||||||
|
|
||||||
|
@ -142,16 +142,16 @@ BLK_DEVICE_TEMPLATE_SMALL = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
SHRED_OUTPUT = (
|
SHRED_OUTPUT = (
|
||||||
'shred: /dev/sda: pass 1/2 (random)...\n'
|
'shred: /dev/sda: pass 1/2 (random)...\n'
|
||||||
'shred: /dev/sda: pass 1/2 (random)...4.9GiB/29GiB 17%\n'
|
'shred: /dev/sda: pass 1/2 (random)...4.9GiB/29GiB 17%\n'
|
||||||
'shred: /dev/sda: pass 1/2 (random)...15GiB/29GiB 51%\n'
|
'shred: /dev/sda: pass 1/2 (random)...15GiB/29GiB 51%\n'
|
||||||
'shred: /dev/sda: pass 1/2 (random)...20GiB/29GiB 69%\n'
|
'shred: /dev/sda: pass 1/2 (random)...20GiB/29GiB 69%\n'
|
||||||
'shred: /dev/sda: pass 1/2 (random)...29GiB/29GiB 100%\n'
|
'shred: /dev/sda: pass 1/2 (random)...29GiB/29GiB 100%\n'
|
||||||
'shred: /dev/sda: pass 2/2 (000000)...\n'
|
'shred: /dev/sda: pass 2/2 (000000)...\n'
|
||||||
'shred: /dev/sda: pass 2/2 (000000)...4.9GiB/29GiB 17%\n'
|
'shred: /dev/sda: pass 2/2 (000000)...4.9GiB/29GiB 17%\n'
|
||||||
'shred: /dev/sda: pass 2/2 (000000)...15GiB/29GiB 51%\n'
|
'shred: /dev/sda: pass 2/2 (000000)...15GiB/29GiB 51%\n'
|
||||||
'shred: /dev/sda: pass 2/2 (000000)...20GiB/29GiB 69%\n'
|
'shred: /dev/sda: pass 2/2 (000000)...20GiB/29GiB 69%\n'
|
||||||
'shred: /dev/sda: pass 2/2 (000000)...29GiB/29GiB 100%\n'
|
'shred: /dev/sda: pass 2/2 (000000)...29GiB/29GiB 100%\n'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -229,11 +229,14 @@ class TestHardwareManagerLoading(test_base.BaseTestCase):
|
|||||||
fake_ep = mock.Mock()
|
fake_ep = mock.Mock()
|
||||||
fake_ep.module_name = 'fake'
|
fake_ep.module_name = 'fake'
|
||||||
fake_ep.attrs = ['fake attrs']
|
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))
|
FakeHardwareManager(hardware.HardwareSupport.GENERIC))
|
||||||
ext2 = extension.Extension('fake_mainline0', fake_ep, None,
|
ext2 = extension.Extension(
|
||||||
|
'fake_mainline0', fake_ep, None,
|
||||||
FakeHardwareManager(hardware.HardwareSupport.MAINLINE))
|
FakeHardwareManager(hardware.HardwareSupport.MAINLINE))
|
||||||
ext3 = extension.Extension('fake_generic1', fake_ep, None,
|
ext3 = extension.Extension(
|
||||||
|
'fake_generic1', fake_ep, None,
|
||||||
FakeHardwareManager(hardware.HardwareSupport.GENERIC))
|
FakeHardwareManager(hardware.HardwareSupport.GENERIC))
|
||||||
self.correct_hw_manager = ext2.obj
|
self.correct_hw_manager = ext2.obj
|
||||||
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance([
|
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance([
|
||||||
@ -596,10 +599,10 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
|||||||
@mock.patch.object(utils, 'execute')
|
@mock.patch.object(utils, 'execute')
|
||||||
def test_erase_block_device_notsupported_shred(self, mocked_execute):
|
def test_erase_block_device_notsupported_shred(self, mocked_execute):
|
||||||
hdparm_output = HDPARM_INFO_TEMPLATE % {
|
hdparm_output = HDPARM_INFO_TEMPLATE % {
|
||||||
'supported': 'not\tsupported',
|
'supported': 'not\tsupported',
|
||||||
'enabled': 'not\tenabled',
|
'enabled': 'not\tenabled',
|
||||||
'frozen': 'not\tfrozen',
|
'frozen': 'not\tfrozen',
|
||||||
'enhanced_erase': 'not\tsupported: enhanced erase',
|
'enhanced_erase': 'not\tsupported: enhanced erase',
|
||||||
}
|
}
|
||||||
|
|
||||||
mocked_execute.side_effect = [
|
mocked_execute.side_effect = [
|
||||||
@ -654,7 +657,7 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
|||||||
@mock.patch.object(os, 'readlink', autospec=True)
|
@mock.patch.object(os, 'readlink', autospec=True)
|
||||||
@mock.patch.object(os.path, 'exists', autospec=True)
|
@mock.patch.object(os.path, 'exists', autospec=True)
|
||||||
def test__is_virtual_media_device_path_doesnt_exist(self, mocked_exists,
|
def test__is_virtual_media_device_path_doesnt_exist(self, mocked_exists,
|
||||||
mocked_link):
|
mocked_link):
|
||||||
mocked_exists.return_value = False
|
mocked_exists.return_value = False
|
||||||
block_device = hardware.BlockDevice('/dev/sda', 'big', 1073741824,
|
block_device = hardware.BlockDevice('/dev/sda', 'big', 1073741824,
|
||||||
True)
|
True)
|
||||||
@ -670,8 +673,9 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
|||||||
True)
|
True)
|
||||||
res = self.hardware._shred_block_device(self.node, block_device)
|
res = self.hardware._shred_block_device(self.node, block_device)
|
||||||
self.assertFalse(res)
|
self.assertFalse(res)
|
||||||
mocked_execute.assert_called_once_with('shred', '--force', '--zero',
|
mocked_execute.assert_called_once_with(
|
||||||
'--verbose', '--iterations', '1', '/dev/sda')
|
'shred', '--force', '--zero', '--verbose', '--iterations', '1',
|
||||||
|
'/dev/sda')
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute')
|
@mock.patch.object(utils, 'execute')
|
||||||
def test_erase_block_device_shred_fail_processerror(self, mocked_execute):
|
def test_erase_block_device_shred_fail_processerror(self, mocked_execute):
|
||||||
@ -680,8 +684,9 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
|||||||
True)
|
True)
|
||||||
res = self.hardware._shred_block_device(self.node, block_device)
|
res = self.hardware._shred_block_device(self.node, block_device)
|
||||||
self.assertFalse(res)
|
self.assertFalse(res)
|
||||||
mocked_execute.assert_called_once_with('shred', '--force', '--zero',
|
mocked_execute.assert_called_once_with(
|
||||||
'--verbose', '--iterations', '1', '/dev/sda')
|
'shred', '--force', '--zero', '--verbose', '--iterations', '1',
|
||||||
|
'/dev/sda')
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute')
|
@mock.patch.object(utils, 'execute')
|
||||||
def test_erase_block_device_ata_security_enabled(self, mocked_execute):
|
def test_erase_block_device_ata_security_enabled(self, mocked_execute):
|
||||||
@ -778,10 +783,10 @@ class TestGenericHardwareManager(test_base.BaseTestCase):
|
|||||||
expected_option,
|
expected_option,
|
||||||
'NULL', '/dev/sda')
|
'NULL', '/dev/sda')
|
||||||
|
|
||||||
test_security_erase_option(self,
|
test_security_erase_option(
|
||||||
'\tsupported: enhanced erase', '--security-erase-enhanced')
|
self, '\tsupported: enhanced erase', '--security-erase-enhanced')
|
||||||
test_security_erase_option(self,
|
test_security_erase_option(
|
||||||
'\tnot\tsupported: enhanced erase', '--security-erase')
|
self, '\tnot\tsupported: enhanced erase', '--security-erase')
|
||||||
|
|
||||||
@mock.patch.object(utils, 'execute')
|
@mock.patch.object(utils, 'execute')
|
||||||
def test_get_bmc_address(self, mocked_execute):
|
def test_get_bmc_address(self, mocked_execute):
|
||||||
|
@ -135,7 +135,7 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
|
|||||||
node_uuid=None)
|
node_uuid=None)
|
||||||
|
|
||||||
url = '{api_url}v1/drivers/{driver}/vendor_passthru/lookup'.format(
|
url = '{api_url}v1/drivers/{driver}/vendor_passthru/lookup'.format(
|
||||||
api_url=API_URL, driver=DRIVER)
|
api_url=API_URL, driver=DRIVER)
|
||||||
request_args = self.api_client.session.request.call_args[0]
|
request_args = self.api_client.session.request.call_args[0]
|
||||||
self.assertEqual(request_args[0], 'POST')
|
self.assertEqual(request_args[0], 'POST')
|
||||||
self.assertEqual(request_args[1], url)
|
self.assertEqual(request_args[1], url)
|
||||||
@ -266,7 +266,7 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
|
|||||||
node_uuid='uuid')
|
node_uuid='uuid')
|
||||||
|
|
||||||
url = '{api_url}v1/drivers/{driver}/vendor_passthru/lookup'.format(
|
url = '{api_url}v1/drivers/{driver}/vendor_passthru/lookup'.format(
|
||||||
api_url=API_URL, driver=DRIVER)
|
api_url=API_URL, driver=DRIVER)
|
||||||
request_args = self.api_client.session.request.call_args[0]
|
request_args = self.api_client.session.request.call_args[0]
|
||||||
self.assertEqual(request_args[0], 'POST')
|
self.assertEqual(request_args[0], 'POST')
|
||||||
self.assertEqual(request_args[1], url)
|
self.assertEqual(request_args[1], url)
|
||||||
|
@ -111,13 +111,12 @@ class TestMultipleHardwareManagerLoading(test_base.BaseTestCase):
|
|||||||
fake_ep = mock.Mock()
|
fake_ep = mock.Mock()
|
||||||
fake_ep.module_name = 'fake'
|
fake_ep.module_name = 'fake'
|
||||||
fake_ep.attrs = ['fake attrs']
|
fake_ep.attrs = ['fake attrs']
|
||||||
self.generic_hwm = extension.Extension('fake_generic', fake_ep, None,
|
self.generic_hwm = extension.Extension(
|
||||||
FakeGenericHardwareManager())
|
'fake_generic', fake_ep, None, FakeGenericHardwareManager())
|
||||||
self.mainline_hwm = extension.Extension('fake_mainline', fake_ep, None,
|
self.mainline_hwm = extension.Extension(
|
||||||
FakeMainlineHardwareManager())
|
'fake_mainline', fake_ep, None, FakeMainlineHardwareManager())
|
||||||
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance([
|
self.fake_ext_mgr = extension.ExtensionManager.make_test_instance(
|
||||||
self.generic_hwm, self.mainline_hwm
|
[self.generic_hwm, self.mainline_hwm])
|
||||||
])
|
|
||||||
|
|
||||||
self.extension_mgr_patcher = mock.patch('stevedore.ExtensionManager')
|
self.extension_mgr_patcher = mock.patch('stevedore.ExtensionManager')
|
||||||
self.mocked_extension_mgr = self.extension_mgr_patcher.start()
|
self.mocked_extension_mgr = self.extension_mgr_patcher.start()
|
||||||
|
@ -80,12 +80,11 @@ exit 1
|
|||||||
fp = open(tmpfilename2, 'r')
|
fp = open(tmpfilename2, 'r')
|
||||||
runs = fp.read()
|
runs = fp.read()
|
||||||
fp.close()
|
fp.close()
|
||||||
self.assertNotEqual(runs.strip(), 'failure', 'stdin did not '
|
self.assertNotEqual(runs.strip(), 'failure',
|
||||||
'always get passed '
|
'stdin did not always get passed correctly')
|
||||||
'correctly')
|
|
||||||
runs = int(runs.strip())
|
runs = int(runs.strip())
|
||||||
self.assertEqual(10, runs,
|
self.assertEqual(10, runs,
|
||||||
'Ran %d times instead of 10.' % (runs,))
|
'Ran %d times instead of 10.' % (runs,))
|
||||||
finally:
|
finally:
|
||||||
os.unlink(tmpfilename)
|
os.unlink(tmpfilename)
|
||||||
os.unlink(tmpfilename2)
|
os.unlink(tmpfilename2)
|
||||||
|
@ -220,8 +220,8 @@ def parse_root_device_hints():
|
|||||||
error_msg = ('No device can be found because the following hints: '
|
error_msg = ('No device can be found because the following hints: '
|
||||||
'"%(not_supported)s" are not supported by this version '
|
'"%(not_supported)s" are not supported by this version '
|
||||||
'of IPA. Supported hints are: "%(supported)s"',
|
'of IPA. Supported hints are: "%(supported)s"',
|
||||||
{'not_supported': ', '.join(not_supported),
|
{'not_supported': ', '.join(not_supported),
|
||||||
'supported': ', '.join(SUPPORTED_ROOT_DEVICE_HINTS)})
|
'supported': ', '.join(SUPPORTED_ROOT_DEVICE_HINTS)})
|
||||||
raise errors.DeviceNotFound(error_msg)
|
raise errors.DeviceNotFound(error_msg)
|
||||||
|
|
||||||
# Normalise the values
|
# Normalise the values
|
||||||
|
4
tox.ini
4
tox.ini
@ -56,9 +56,7 @@ commands =
|
|||||||
python setup.py build_sphinx
|
python setup.py build_sphinx
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# E711: ignored because it is normal to use "column == None" in sqlalchemy
|
ignore = E129
|
||||||
|
|
||||||
ignore = E12,E711
|
|
||||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,*ironic/nova*,tools
|
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build,*ironic/nova*,tools
|
||||||
|
|
||||||
[hacking]
|
[hacking]
|
||||||
|
Loading…
Reference in New Issue
Block a user