Merge "Increase version of hacking and pycodestyle"

This commit is contained in:
Zuul 2021-08-11 10:02:24 +00:00 committed by Gerrit Code Review
commit 71f54b7f98
9 changed files with 48 additions and 37 deletions

View File

@ -190,5 +190,8 @@ class ExampleBusinessLogicHardwareManager(hardware.HardwareManager):
# Make sure to provide default values for optional arguments.
def companyx_apply_something(self, node, ports, required_value,
optional_value=None):
LOG.info('apply_something called with required_value={} and '
'optional_value={}'.format(required_value, optional_value))
LOG.info('apply_something called with '
'required_value=%(required_value)s and '
'optional_value=%(optional_value)s',
{'required_value': required_value,
'optional_value': optional_value})

View File

@ -125,17 +125,16 @@ class IronicPythonAgentHeartbeater(threading.Thread):
self.heartbeat_forced = False
self.previous_heartbeat = _time()
except errors.HeartbeatConflictError:
LOG.warning('conflict error sending heartbeat to {}'.format(
self.agent.api_url))
LOG.warning('conflict error sending heartbeat to %s',
self.agent.api_url)
except Exception:
LOG.exception('error sending heartbeat to {}'.format(
self.agent.api_url))
LOG.exception('error sending heartbeat to %s', self.agent.api_url)
finally:
interval_multiplier = random.uniform(self.min_jitter_multiplier,
self.max_jitter_multiplier)
self.interval = self.agent.heartbeat_timeout * interval_multiplier
log_msg = 'sleeping before next heartbeat, interval: {0}'
LOG.info(log_msg.format(self.interval))
LOG.info('sleeping before next heartbeat, interval: %s',
self.interval)
def force_heartbeat(self):
self.heartbeat_forced = True

View File

@ -489,8 +489,9 @@ def _prepare_boot_partitions_for_softraid(device, holders, efi_part,
# RAID the ESPs, metadata=1.0 is mandatory to be able to boot
md_device = '/dev/md/esp'
LOG.debug("Creating md device {} for the ESPs on {}".format(
md_device, efi_partitions))
LOG.debug("Creating md device %(md_device)s for the ESPs "
"on %(efi_partitions)s",
{'md_device': md_device, 'efi_partitions': efi_partitions})
utils.execute('mdadm', '--create', md_device, '--force',
'--run', '--metadata=1.0', '--level', '1',
'--raid-devices', len(efi_partitions),

View File

@ -202,7 +202,7 @@ def _write_whole_disk_image(image, image_info, device):
command = ['qemu-img', 'convert',
'-t', 'directsync', '-O', 'host_device', '-W',
image, device]
LOG.info('Writing image with command: {}'.format(' '.join(command)))
LOG.info('Writing image with command: %s', ' '.join(command))
try:
disk_utils.convert_image(image, device, out_format='host_device',
cache='directsync', out_of_order=True)
@ -232,8 +232,9 @@ def _write_image(image_info, device, configdrive=None):
else:
_write_whole_disk_image(image, image_info, device)
totaltime = time.time() - starttime
LOG.info('Image {} written to device {} in {} seconds'.format(
image, device, totaltime))
LOG.info('Image %(image)s written to device %(device)s in %(totaltime)s '
'seconds', {'image': image, 'device': device,
'totaltime': totaltime})
try:
disk_utils.fix_gpt_partition(device, node_uuid=None)
except exception.InstanceDeployFailure:
@ -329,7 +330,7 @@ class ImageDownload(object):
details = []
for url in image_info['urls']:
try:
LOG.info("Attempting to download image from {}".format(url))
LOG.info("Attempting to download image from %s", url)
self._request = _download_with_proxy(image_info, url,
image_info['id'])
except errors.ImageDownloadError as e:
@ -386,12 +387,16 @@ class ImageDownload(object):
not match the checksum as reported by glance in image_info.
"""
checksum = self._hash_algo.hexdigest()
LOG.debug('Verifying image at {} against {} checksum '
'{}'.format(image_location, self._hash_algo.name, checksum))
LOG.debug('Verifying image at %(image_location)s against '
'%(algo_name)s checksum %(checksum)s',
{'image_location': image_location,
'algo_name': self._hash_algo.name,
'checksum': checksum})
if checksum != self._expected_hash_value:
LOG.error(errors.ImageChecksumError.details_str.format(
error_msg = errors.ImageChecksumError.details_str.format(
image_location, self._image_info['id'],
self._expected_hash_value, checksum))
self._expected_hash_value, checksum)
LOG.error(error_msg)
raise errors.ImageChecksumError(image_location,
self._image_info['id'],
self._expected_hash_value,
@ -434,8 +439,10 @@ def _download_image(image_info):
break
totaltime = time.time() - starttime
LOG.info("Image downloaded from {} in {} seconds".format(image_location,
totaltime))
LOG.info("Image downloaded from %(image_location)s "
"in %(totaltime)s seconds",
{'image_location': image_location,
'totaltime': totaltime})
image_download.verify_image(image_location)
@ -597,8 +604,8 @@ class StandbyExtension(base.BaseAgentExtension):
break
totaltime = time.time() - starttime
LOG.info("Image streamed onto device {} in {} "
"seconds".format(device, totaltime))
LOG.info("Image streamed onto device %(device)s in %(totaltime)s "
"seconds", {'device': device, 'totaltime': totaltime})
# Verify if the checksum of the streamed image is correct
image_download.verify_image(device)
# Fix any gpt partition
@ -609,7 +616,8 @@ class StandbyExtension(base.BaseAgentExtension):
pass
# Fix the root partition UUID
root_uuid = disk_utils.block_uuid(device)
LOG.info("{} UUID is now {}".format(device, root_uuid))
LOG.info("%(device)s UUID is now %(root_uuid)s",
{'device': device, 'root_uuid': root_uuid})
self.partition_uuids['root uuid'] = root_uuid
def _fix_up_partition_uuids(self, image_info, device):

View File

@ -445,13 +445,13 @@ def list_all_block_devices(block_type='disk',
# lvm, part, rom, loop
if devtype != block_type:
if devtype is None or ignore_raid:
LOG.debug("Skipping: {!r}".format(line))
LOG.debug("Skipping: %s", line)
continue
elif ('raid' in devtype
and block_type in ['raid', 'disk']):
LOG.debug(
"TYPE detected to contain 'raid', signifying a "
"RAID volume. Found: {!r}".format(line))
"RAID volume. Found: %s", line)
elif (devtype == 'md'
and (block_type == 'part'
or block_type == 'md')):
@ -461,11 +461,11 @@ def list_all_block_devices(block_type='disk',
# more detail.
LOG.debug(
"TYPE detected to contain 'md', signifying a "
"RAID partition. Found: {!r}".format(line))
"RAID partition. Found: %s", line)
else:
LOG.debug(
"TYPE did not match. Wanted: {!r} but found: {!r}".format(
block_type, line))
"TYPE did not match. Wanted: %(block_type)s but found: "
"%(line)s", {'block_type': block_type, 'line': line})
continue
# Ensure all required columns are at least present, even if blank

View File

@ -64,9 +64,10 @@ def _disable_embedded_lldp_agent_in_cna_card():
failed_dirs.append(inner_dir)
continue
if failed_dirs:
LOG.warning('Failed to disable the embedded LLDP on Intel CNA network '
'card. Addresses of failed pci devices: {}'
.format(str(failed_dirs).strip('[]')))
warning_msg = ('Failed to disable the embedded LLDP on Intel '
'CNA network card. Addresses of failed pci '
'devices: %s', str(failed_dirs).strip('[]'))
LOG.warning(warning_msg)
class IntelCnaHardwareManager(hardware.HardwareManager):

View File

@ -112,8 +112,8 @@ class TestIntelCnaHardwareManager(base.IronicAgentTest):
cna._disable_embedded_lldp_agent_in_cna_card()
expected_log_message = ('Failed to disable the embedded LLDP on '
'Intel CNA network card. Addresses of '
'failed pci devices: {}'
.format(str(listdir_dict).strip('[]')))
'failed pci devices: %s',
str(listdir_dict).strip('[]'))
mock_log.warning.assert_called_once_with(expected_log_message)
@mock.patch.object(cna, 'LOG', autospec=True)

View File

@ -865,8 +865,7 @@ def create_partition_table(dev_name, partition_table_type):
:raises: CommandExecutionError if an error is encountered while
attempting to create the partition table.
"""
LOG.info("Creating partition table on {}".format(
dev_name))
LOG.info("Creating partition table on %s", dev_name)
try:
execute('parted', dev_name, '-s', '--',
'mklabel', partition_table_type)

View File

@ -35,10 +35,10 @@ commands = stestr run {posargs}
[testenv:pep8]
usedevelop = False
deps=
hacking>=3.1.0,<4.0.0 # Apache-2.0
hacking>=4.1.0,<5.0.0 # Apache-2.0
bashate>=0.5.1 # Apache-2.0
flake8-import-order>=0.17.1 # LGPLv3
pycodestyle>=2.0.0,<2.7.0 # MIT
pycodestyle>=2.0.0,<3.0.0 # MIT
doc8>=0.8.1 # Apache-2.0
allowlist_externals = bash
commands =