From a332a19a571568d7fd5ac6ce978c140f4d362771 Mon Sep 17 00:00:00 2001 From: Riccardo Pittau Date: Mon, 30 Mar 2020 12:55:46 +0200 Subject: [PATCH] Bump hacking to 3.0.0 Change-Id: I1032ea6a2e9d79aeaecb1458c319cbeb15ac1fff --- ironic_python_agent/agent.py | 19 +++++++++---------- ironic_python_agent/extensions/image.py | 4 ++-- ironic_python_agent/extensions/standby.py | 8 ++++---- ironic_python_agent/hardware.py | 22 +++++++++++----------- ironic_python_agent/utils.py | 4 ++-- lower-constraints.txt | 2 +- test-requirements.txt | 2 +- 7 files changed, 30 insertions(+), 31 deletions(-) diff --git a/ironic_python_agent/agent.py b/ironic_python_agent/agent.py index 93a1c86e4..eb567be3e 100644 --- a/ironic_python_agent/agent.py +++ b/ironic_python_agent/agent.py @@ -236,16 +236,15 @@ class IronicPythonAgent(base.ExecuteCommandMixin): # we've previously seen a token, which is # a mid-cluster upgrade case with long-running ramdisks. if (not token and self.agent_token - and not self.agent_token_required): - # TODO(TheJulia): Rip this out during or after the V - # cycle. - LOG.warning('Agent token for requests are not required ' - 'by the conductor, yet we received a token. ' - 'Cluster may be mid-upgrade. Support to ' - 'not fail in this condition will be removed in ' - 'the Victoria development cycle.') - # Tell the API everything is okay. - return True + and not self.agent_token_required): + # TODO(TheJulia): Rip this out during or after the V cycle. + LOG.warning('Agent token for requests are not required ' + 'by the conductor, yet we received a token. ' + 'Cluster may be mid-upgrade. Support to ' + 'not fail in this condition will be removed in ' + 'the Victoria development cycle.') + # Tell the API everything is okay. + return True if self.agent_token is not None: return self.agent_token == token diff --git a/ironic_python_agent/extensions/image.py b/ironic_python_agent/extensions/image.py index 67497170f..0ab0b66b3 100644 --- a/ironic_python_agent/extensions/image.py +++ b/ironic_python_agent/extensions/image.py @@ -111,8 +111,8 @@ def _get_partition(device, uuid): # device has a partition (which we assume to contain the root fs). if hardware.is_md_device(device): md_partition = device + 'p1' - if (os.path.exists(md_partition) and - stat.S_ISBLK(os.stat(md_partition).st_mode)): + if (os.path.exists(md_partition) + and stat.S_ISBLK(os.stat(md_partition).st_mode)): LOG.debug("Found md device with partition %s", md_partition) return md_partition diff --git a/ironic_python_agent/extensions/standby.py b/ironic_python_agent/extensions/standby.py index 53316bf34..289e1cc00 100644 --- a/ironic_python_agent/extensions/standby.py +++ b/ironic_python_agent/extensions/standby.py @@ -416,12 +416,12 @@ def _validate_image_info(ext, image_info=None, **kwargs): os_hash_algo = image_info.get('os_hash_algo') os_hash_value = image_info.get('os_hash_value') if os_hash_algo or os_hash_value: - if (not isinstance(os_hash_algo, str) or - not os_hash_algo): + if (not isinstance(os_hash_algo, str) + or not os_hash_algo): raise errors.InvalidCommandParamsError( 'Image \'os_hash_algo\' must be a non-empty string.') - if (not isinstance(os_hash_value, str) or - not os_hash_value): + if (not isinstance(os_hash_value, str) + or not os_hash_value): raise errors.InvalidCommandParamsError( 'Image \'os_hash_value\' must be a non-empty string.') os_hash_checksum_avail = True diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 04570c599..09ccb30fe 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -339,9 +339,9 @@ def list_all_block_devices(block_type='disk', # Other possible type values, which we skip recording: # lvm, part, rom, loop if devtype != block_type: - if (devtype is not None and - any(x in devtype for x in ['raid', 'md']) and - not ignore_raid): + if (devtype is not None + and any(x in devtype for x in ['raid', 'md']) + and not ignore_raid): LOG.debug( "TYPE detected to contain 'raid' or 'md', signifying a " "RAID volume. Found: {!r}".format(line)) @@ -930,8 +930,8 @@ class GenericHardwareManager(HardwareManager): if sys_child['id'] == 'core': for core_child in sys_child['children']: if _MEMORY_ID_RE.match(core_child['id']): - if (not core_child.get("children") and - core_child.get('size')): + if (not core_child.get("children") + and core_child.get('size')): value = ("%(size)s %(units)s" % core_child) physical += int(UNIT_CONVERTER(value).to ('MB').magnitude) @@ -1400,7 +1400,7 @@ class GenericHardwareManager(HardwareManager): cmd = "ipmitool lan6 print {} {}_addr".format( channel, 'dynamic' if dynamic else 'static') try: - out, e = utils.execute(cmd, shell=True) + out, exc = utils.execute(cmd, shell=True) except processutils.ProcessExecutionError: return @@ -1409,9 +1409,9 @@ class GenericHardwareManager(HardwareManager): # dynamic_addr and static_addr commands is a valid yaml. try: out = yaml.safe_load(out.strip()) - except yaml.YAMLError as e: + except yaml.YAMLError as excpt: LOG.warning('Cannot process output of "%(cmd)s" ' - 'command: %(e)s', {'cmd': cmd, 'e': e}) + 'command: %(e)s', {'cmd': cmd, 'e': excpt}) return for addr_dict in out.values(): @@ -1446,9 +1446,9 @@ class GenericHardwareManager(HardwareManager): except ValueError as exc: LOG.warning('Invalid IP address %s: %s', address, exc) continue - except (processutils.ProcessExecutionError, OSError) as e: + except (processutils.ProcessExecutionError, OSError) as exc: # Not error, because it's normal in virtual environment - LOG.warning("Cannot get BMC v6 address: %s", e) + LOG.warning("Cannot get BMC v6 address: %s", exc) return return '::/0' @@ -1759,7 +1759,7 @@ class GenericHardwareManager(HardwareManager): LOG.debug('Removing partitions on %s', holder_disk) try: utils.execute('wipefs', '-af', holder_disk) - except processutils.ProcessExecutionError as e: + except processutils.ProcessExecutionError: LOG.warning('Failed to remove partitions on %s', holder_disk) diff --git a/ironic_python_agent/utils.py b/ironic_python_agent/utils.py index ccbc42f77..c8e7777e3 100644 --- a/ironic_python_agent/utils.py +++ b/ironic_python_agent/utils.py @@ -181,12 +181,12 @@ def _get_vmedia_params(): try: stdout, stderr = execute("umount", vmedia_mount_point) - except processutils.ProcessExecutionError as e: + except processutils.ProcessExecutionError: pass finally: try: shutil.rmtree(vmedia_mount_point) - except Exception as e: + except Exception: pass return params diff --git a/lower-constraints.txt b/lower-constraints.txt index 530867035..d94af5c20 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -22,7 +22,7 @@ flake8-import-order==0.13 flake8==2.5.5 future==0.16.0 greenlet==0.4.13 -hacking==1.0.0 +hacking==3.0.0 idna==2.6 imagesize==1.0.0 ironic-lib==2.17.0 diff --git a/test-requirements.txt b/test-requirements.txt index ad691711c..923b68b05 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,7 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.0.0,<1.1.0 # Apache-2.0 +hacking>=3.0.0,<3.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 mock>=2.0.0 # BSD testtools>=2.2.0 # MIT