Inband disk erase support for SSD disk drives

This commits fixed the inband disk erase issue while passing
SSD and HDD disk drives together and also implements support
for SSD disk drives.

Change-Id: I41858cb65df7a580b84e8d4528ef3398f9188a78
Bug-Id: 1815023
This commit is contained in:
paresh-sao 2019-02-11 10:34:08 +00:00
parent 7286d7019c
commit 1ec0028037
3 changed files with 61 additions and 21 deletions

View File

@ -21,6 +21,10 @@ from oslo_utils import strutils
from proliantutils import exception
from proliantutils.hpssa import constants
from proliantutils import log
LOG = log.get_logger(__name__)
def _get_indentation(string):
@ -447,26 +451,38 @@ class Controller(object):
def erase_devices(self, drives):
"""Perform Erase on all the drives in the controller.
This method erases all the drives in the controller by overwriting
the drives with the pattern. The drives will be unavailable until
after successful completion or failure. The possible erase pattern
available for sanitize erase are 'overwrite' and 'block' to perform
erase on HDD and SSD respectively.
This method erases all the hdd and ssd drives in the controller
by overwriting the drives with patterns for hdd and erasing storage
blocks for ssd drives. The drives would be unavailable until
successful completion or failure of erase operation.
If the sanitize erase is not supported on the controller it performs
the disk erase by overwritting with zeros.
If the sanitize erase is not supported on any disk it will try to
populate zeros on disk drives.
:param drives: A list of drive objects in the controller.
:raises: HPSSAOperationError, if sanitize erase is not supported.
"""
# TODO(aparnav): Add Sanitize erase support for SSD
drive = ','.join([x.id for x in drives])
cmd_args = self._get_erase_command(drive, 'erasepattern=overwrite')
for drive in drives:
pattern = 'overwrite' if (
drive.disk_type == constants.DISK_TYPE_HDD) else 'block'
cmd_args = self._get_erase_command(
drive.id, 'erasepattern=%s' % pattern)
stdout = self.execute_cmd(*cmd_args)
LOG.debug("Sanitize disk erase invoked with erase pattern as "
"'%(pattern)s' on disk type: %(disk_type)s."
% {'pattern': pattern, 'disk_type': drive.disk_type})
stdout = self.execute_cmd(*cmd_args)
if "not supported" in str(stdout):
cmd_args = self._get_erase_command(drive,
'erasepattern=zero')
self.execute_cmd(*cmd_args)
if "not supported" in str(stdout):
new_pattern = 'zero'
cmd_args = self._get_erase_command(drive.id,
'erasepattern=zero')
self.execute_cmd(*cmd_args)
LOG.debug("Sanitize disk erase invoked with erase pattern as "
"'%(pattern)s' is not supported on disk type: "
"%(disk_type)s. Now its invoked with erase pattern "
"as %(new_pattern)s."
% {'pattern': pattern, 'disk_type': drive.disk_type,
'new_pattern': new_pattern})
class RaidArray(object):

View File

@ -2391,6 +2391,27 @@ Smart Array P440 in Slot 2
Sanitize Estimated Max Erase Time: 0 hour(s)36 minute(s)
Unrestricted Sanitize Supported: False
Shingled Magnetic Recording Support: None
physicaldrive 6I:1:7
Port: 6I
Box: 1
Bay: 7
Status: OK
Drive Type: Unassigned Drive
Interface Type: Solid State SAS
Size: 200 GB
Native Block Size: 512
Rotational Speed: 15000
Firmware Revision: HPD6
Serial Number: 6SL7G54Q0000N4180W34
Model: HP EF0600FARNA
Current Temperature (C): 31
Maximum Temperature (C): 39
PHY Count: 2
PHY Transfer Rate: 6.0Gbps, Unknown
Drive Authentication Status: OK
Carrier Application Version: 11
Carrier Bootloader Version: 6
'''
SSA_ERASE_IN_PROGRESS = '''

View File

@ -344,13 +344,16 @@ class ControllerTest(testtools.TestCase):
get_all_details_mock):
get_all_details_mock.return_value = raid_constants.SSA_ERASE_DRIVE
server = objects.Server()
d = [x for x in server.controllers[0].unassigned_physical_drives]
drives = [x for x in server.controllers[0].unassigned_physical_drives]
controller = server.controllers[0]
controller.erase_devices(d)
execute_mock.assert_called_once_with('pd 1I:2:1', 'modify', 'erase',
'erasepattern=overwrite',
'unrestricted=off',
'forced')
execute_mock.return_value = ""
controller.erase_devices(drives)
calls = [mock.call('pd 6I:1:7', 'modify', 'erase',
'erasepattern=block', 'unrestricted=off', 'forced'),
mock.call('pd 1I:2:1', 'modify', 'erase',
'erasepattern=overwrite', 'unrestricted=off',
'forced')]
execute_mock.assert_has_calls(calls, any_order=True)
@mock.patch.object(objects.Controller, 'execute_cmd')
def test_erase_devices_sanitize_not_supported(self, execute_mock,