diff options
| author | Julia Kreger <juliaashleykreger@gmail.com> | 2016-01-21 11:26:44 -0500 |
|---|---|---|
| committer | Dmitry Tantsur <divius.inside@gmail.com> | 2016-06-01 08:23:03 +0000 |
| commit | b6bdaf040f6cde7f069ea355b7b4b12aea60fbd7 (patch) | |
| tree | 439c4ada22166ebb343fe7e5985ff10d5a58c67e /ironic_python_agent/hardware.py | |
| parent | 2ec82a4dcf278c6f7fd94a41998d877a82f76579 (diff) | |
| download | ironic-python-agent-1.2.2.tar.gz | |
Provide fallback from ATA erase to shredding1.2.2
Presently should the ATA erasure operation fails, IPA halts the
cleaning process and the node goes to CLEANFAIL state as a result.
This failure could be the result of a previous cleaning failure
that left drive security enabled, for which code has been added
in an attempt to address this case by attempting to unlock the
the drive.
In the event that an operator wishes to automatically fallback to
disk scrubbing operations, the capability has been added through
a driver_internal_info field "agent_continue_if_ata_erase_failed"
that can be set to True, however defaults to False keeping the
same behavior that IPA presently exhibits in the event of ATA
erase operations failing.
Partial-Bug: #1536695
Change-Id: I88edd9477f4f05aa55b2fe8efa4bbff1c5573bb1
(cherry picked from commit ed74a062c19a63a2c05a506c4ed8d3aa4ecfa09e)
Diffstat (limited to 'ironic_python_agent/hardware.py')
| -rw-r--r-- | ironic_python_agent/hardware.py | 56 |
1 files changed, 50 insertions, 6 deletions
diff --git a/ironic_python_agent/hardware.py b/ironic_python_agent/hardware.py index 3efb7671..9ea72582 100644 --- a/ironic_python_agent/hardware.py +++ b/ironic_python_agent/hardware.py @@ -605,8 +605,25 @@ class GenericHardwareManager(HardwareManager): block_device.name) return - if self._ata_erase(block_device): - return + # Note(TheJulia) Use try/except to capture and log the failure + # and then revert to attempting to shred the volume if enabled. + try: + if self._ata_erase(block_device): + return + except errors.BlockDeviceEraseError as e: + info = node.get('driver_internal_info', {}) + execute_shred = info.get( + 'agent_continue_if_ata_erase_failed', False) + if execute_shred: + LOG.warning('Failed to invoke ata_erase, ' + 'falling back to shred: %(err)s' + % {'err': e}) + else: + msg = ('Failed to invoke ata_erase, ' + 'fallback to shred is not enabled: %(err)s' + % {'err': e}) + LOG.error(msg) + raise errors.IncompatibleHardwareMethodError(msg) if self._shred_block_device(node, block_device): return @@ -681,6 +698,20 @@ class GenericHardwareManager(HardwareManager): return False if 'enabled' in security_lines: + # Attempt to unlock the drive in the event it has already been + # locked by a previous failed attempt. + try: + utils.execute('hdparm', '--user-master', 'u', + '--security-unlock', 'NULL', block_device.name) + security_lines = self._get_ata_security_lines(block_device) + except processutils.ProcessExecutionError as e: + raise errors.BlockDeviceEraseError('Security password set ' + 'failed for device ' + '%(name)s: %(err)s' % + {'name': block_device.name, + 'err': e}) + + if 'enabled' in security_lines: raise errors.BlockDeviceEraseError( ('Block device {0} already has a security password set' ).format(block_device.name)) @@ -690,16 +721,29 @@ class GenericHardwareManager(HardwareManager): ('Block device {0} is frozen and cannot be erased' ).format(block_device.name)) - utils.execute('hdparm', '--user-master', 'u', '--security-set-pass', - 'NULL', block_device.name) + try: + utils.execute('hdparm', '--user-master', 'u', + '--security-set-pass', 'NULL', block_device.name) + except processutils.ProcessExecutionError as e: + raise errors.BlockDeviceEraseError('Security password set ' + 'failed for device ' + '%(name)s: %(err)s' % + {'name': block_device.name, + 'err': e}) # Use the 'enhanced' security erase option if it's supported. erase_option = '--security-erase' if 'not supported: enhanced erase' not in security_lines: erase_option += '-enhanced' - utils.execute('hdparm', '--user-master', 'u', erase_option, - 'NULL', block_device.name) + try: + utils.execute('hdparm', '--user-master', 'u', erase_option, + 'NULL', block_device.name) + except processutils.ProcessExecutionError as e: + raise errors.BlockDeviceEraseError('Erase failed for device ' + '%(name)s: %(err)s' % + {'name': block_device.name, + 'err': e}) # Verify that security is now 'not enabled' security_lines = self._get_ata_security_lines(block_device) |
