diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index 9ee7996a5..f4fac7f0d 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -754,7 +754,7 @@ def _efi_boot_setup(device, efi_system_part_uuid=None, target_boot_mode=None): and not hardware.is_md_device(device)): try: utils.execute('efibootmgr', '--version') - except FileNotFoundError: + except OSError: LOG.warning("efibootmgr is not available in the ramdisk") else: if _manage_uefi(device, @@ -801,7 +801,7 @@ def _preserve_efi_assets(path, efi_assets_folder, efi_partitions, grub_dest, grub2_file) try: shutil.copy2(grub2_file, grub_dest) - except (IOError, OSError, shutil.SameFileError) as e: + except (IOError, OSError, shutil.Error) as e: LOG.warning('Failed to copy grub.cfg file for ' 'EFI boot operation. Error %s', e) grub2_env_file = os.path.join(path, 'boot/grub2/grubenv') @@ -823,7 +823,7 @@ def _preserve_efi_assets(path, efi_assets_folder, efi_partitions, grub2env_dest) try: shutil.copy2(grub2_env_file, grub2env_dest) - except (IOError, OSError, shutil.SameFileError) as e: + except (IOError, OSError, shutil.Error) as e: LOG.warning('Failed to copy grubenv file. ' 'Error: %s', e) # Loop through partitions because software RAID. diff --git a/ironic_python_agent/tests/unit/extensions/test_image.py b/ironic_python_agent/tests/unit/extensions/test_image.py index 1c0ad0088..cd5e8ebf9 100644 --- a/ironic_python_agent/tests/unit/extensions/test_image.py +++ b/ironic_python_agent/tests/unit/extensions/test_image.py @@ -18,7 +18,6 @@ import shutil import tempfile import mock -from ironic_lib import utils as ilib_utils from oslo_concurrency import processutils from ironic_python_agent import errors @@ -687,19 +686,10 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n mock_is_md_device.return_value = False mock_md_get_raid_devices.return_value = {} mock_exists.side_effect = iter([False, True, False, True, True]) - with mock.patch('builtins.open', mock.mock_open()) as mock_open: + with mock.patch('builtins.open', mock.mock_open()): image._install_grub2( self.fake_dev, root_uuid=self.fake_root_uuid, efi_system_part_uuid=self.fake_efi_system_part_uuid) - write_calls = [ - mock.call(self.fake_dir + '/etc/fstab', 'r+'), - mock.call().__enter__(), - mock.call().read(), - mock.call().writelines('UUID=%s\t/boot/efi\tvfat\t' - 'umask=0077\t0\t1' - '\n' % self.fake_efi_system_part_uuid), - mock.call().__exit__(None, None, None)] - mock_open.assert_has_calls(write_calls) expected = [mock.call('mount', '/dev/fake2', self.fake_dir), mock.call('mount', '-o', 'bind', '/dev', @@ -788,16 +778,10 @@ efibootmgr: ** Warning ** : Boot0005 has same label ironic1\n mock_exists.side_effect = [True, False, True, True, True, False, True, True] with mock.patch('builtins.open', - mock.mock_open(read_data=fstab_data)) as mock_open: + mock.mock_open(read_data=fstab_data)): image._install_grub2( self.fake_dev, root_uuid=self.fake_root_uuid, efi_system_part_uuid=self.fake_efi_system_part_uuid) - write_calls = [ - mock.call(self.fake_dir + '/etc/fstab', 'r+'), - mock.call().__enter__(), - mock.call().read(), - mock.call().__exit__(None, None, None)] - mock_open.assert_has_calls(write_calls) expected = [mock.call('mount', '/dev/fake2', self.fake_dir), mock.call('mount', '-o', 'bind', '/dev', diff --git a/test-requirements.txt b/test-requirements.txt index afc80a2b7..b8a7d2597 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -9,7 +9,7 @@ oslotest>=3.2.0 # Apache-2.0 stestr>=1.0.0 # Apache-2.0 bashate>=0.5.1 # Apache-2.0 flake8-import-order>=0.13 # LGPLv3 -bandit!=1.6.0,>=1.1.0,<2.0.0 # Apache-2.0 +bandit!=1.6.0,>=1.1.0,<1.7.0 # Apache-2.0 # Doc requirements doc8>=0.6.0 # Apache-2.0 diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index fd0a52ba5..d4cd3b70b 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -1,5 +1,6 @@ - project: templates: + - openstack-python-jobs - openstack-python3-train-jobs - openstack-cover-jobs - publish-openstack-docs-pti