Browse Source

Fix py27 compatability for train

Train release of OpenStack is intended to support compatability
with python2.7 and we inadvertently broke it earlier.

Due to a broken gate, we created a change which removed the py27
jobs, bandit, and lower constraints checking due to multiple
gates failing all at once. Ide0f6c38a59ae6486fa33cfb19b383d022e57d5a

The removal of the py27 change was due to Bandit 1.7.0 which
dropped py2 support. We should have restricted Bandit in our
test-requirements.txt at that time.

As such, this commit addresses that, plus python3 only exception
names which slipped in on a backport breaking py27 compatability.

Change-Id: I4a441495d078b9c46b8ad443fc0e7862efd12bde
changes/49/795349/2
Julia Kreger 5 days ago
parent
commit
928db63156
4 changed files with 7 additions and 22 deletions
  1. +3
    -3
      ironic_python_agent/extensions/image.py
  2. +2
    -18
      ironic_python_agent/tests/unit/extensions/test_image.py
  3. +1
    -1
      test-requirements.txt
  4. +1
    -0
      zuul.d/project.yaml

+ 3
- 3
ironic_python_agent/extensions/image.py View File

@ -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.


+ 2
- 18
ironic_python_agent/tests/unit/extensions/test_image.py View File

@ -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',


+ 1
- 1
test-requirements.txt View File

@ -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


+ 1
- 0
zuul.d/project.yaml View File

@ -1,5 +1,6 @@
- project:
templates:
- openstack-python-jobs
- openstack-python3-train-jobs
- openstack-cover-jobs
- publish-openstack-docs-pti


Loading…
Cancel
Save