Added disable_test() to Disk class
This commit is contained in:
parent
41c9a4d23f
commit
0c0f8e8950
1 changed files with 26 additions and 18 deletions
|
|
@ -237,12 +237,18 @@ class DiskObj():
|
||||||
if HW_OVERRIDES_FORCED or ask('Run tests on this device anyway?'):
|
if HW_OVERRIDES_FORCED or ask('Run tests on this device anyway?'):
|
||||||
self.disk_ok = True
|
self.disk_ok = True
|
||||||
if 'NVMe / SMART' in self.tests:
|
if 'NVMe / SMART' in self.tests:
|
||||||
self.tests['NVMe / SMART'].update_status('OVERRIDE')
|
self.disable_test('NVMe / SMART', 'OVERRIDE')
|
||||||
if self.nvme_attributes or not self.smart_attributes:
|
if not self.nvme_attributes and self.smart_attributes:
|
||||||
# i.e. only leave enabled for SMART short-tests
|
# Re-enable for SMART short-tests
|
||||||
self.tests['NVMe / SMART'].disabled = True
|
self.tests['NVMe / SMART'].disabled = False
|
||||||
print_standard(' ')
|
print_standard(' ')
|
||||||
|
|
||||||
|
def disable_test(self, name, status):
|
||||||
|
"""Disable test by name and update status."""
|
||||||
|
if name in self.tests:
|
||||||
|
self.tests[name].update_status(status)
|
||||||
|
self.tests[name].disabled = True
|
||||||
|
|
||||||
def generate_attribute_report(
|
def generate_attribute_report(
|
||||||
self, description=False, short_test=False, timestamp=False):
|
self, description=False, short_test=False, timestamp=False):
|
||||||
"""Generate NVMe / SMART report, returns list."""
|
"""Generate NVMe / SMART report, returns list."""
|
||||||
|
|
@ -427,23 +433,26 @@ class DiskObj():
|
||||||
# Check if a self-test is currently running
|
# Check if a self-test is currently running
|
||||||
if 'remaining_percent' in self.smart_self_test['status']:
|
if 'remaining_percent' in self.smart_self_test['status']:
|
||||||
_msg = 'SMART self-test in progress, all tests disabled'
|
_msg = 'SMART self-test in progress, all tests disabled'
|
||||||
|
|
||||||
|
# Ask to abort
|
||||||
if not silent:
|
if not silent:
|
||||||
print_warning('WARNING: {}'.format(_msg))
|
print_warning('WARNING: {}'.format(_msg))
|
||||||
print_standard(' ')
|
print_standard(' ')
|
||||||
if ask('Abort HW Diagnostics?'):
|
if ask('Abort HW Diagnostics?'):
|
||||||
exit_script()
|
exit_script()
|
||||||
|
|
||||||
|
# Add warning to report
|
||||||
if 'NVMe / SMART' in self.tests:
|
if 'NVMe / SMART' in self.tests:
|
||||||
self.tests['NVMe / SMART'].report = self.generate_attribute_report()
|
self.tests['NVMe / SMART'].report = self.generate_attribute_report()
|
||||||
self.tests['NVMe / SMART'].report.append(
|
self.tests['NVMe / SMART'].report.append(
|
||||||
'{YELLOW}WARNING: {msg}{CLEAR}'.format(msg=_msg, **COLORS))
|
'{YELLOW}WARNING: {msg}{CLEAR}'.format(msg=_msg, **COLORS))
|
||||||
for t in self.tests.values():
|
|
||||||
t.update_status('Denied')
|
# Disable all tests for this disk
|
||||||
t.disabled = True
|
for t in self.tests.keys():
|
||||||
|
self.disable_test(k, 'Denied')
|
||||||
else:
|
else:
|
||||||
# No NVMe/SMART details
|
# No NVMe/SMART details
|
||||||
if 'NVMe / SMART' in self.tests:
|
self.disable_test('NVMe / SMART', 'N/A')
|
||||||
self.tests['NVMe / SMART'].update_status('N/A')
|
|
||||||
self.tests['NVMe / SMART'].disabled = True
|
|
||||||
if silent:
|
if silent:
|
||||||
self.disk_ok = HW_OVERRIDES_FORCED
|
self.disk_ok = HW_OVERRIDES_FORCED
|
||||||
else:
|
else:
|
||||||
|
|
@ -457,14 +466,11 @@ class DiskObj():
|
||||||
if not self.disk_ok:
|
if not self.disk_ok:
|
||||||
if 'NVMe / SMART' in self.tests:
|
if 'NVMe / SMART' in self.tests:
|
||||||
# NOTE: This will not overwrite the existing status if set
|
# NOTE: This will not overwrite the existing status if set
|
||||||
|
self.disable_test('NVMe / SMART', 'NS')
|
||||||
if not self.tests['NVMe / SMART'].report:
|
if not self.tests['NVMe / SMART'].report:
|
||||||
self.tests['NVMe / SMART'].report = self.generate_attribute_report()
|
self.tests['NVMe / SMART'].report = self.generate_attribute_report()
|
||||||
self.tests['NVMe / SMART'].update_status('NS')
|
|
||||||
self.tests['NVMe / SMART'].disabled = True
|
|
||||||
for t in ['badblocks', 'I/O Benchmark']:
|
for t in ['badblocks', 'I/O Benchmark']:
|
||||||
if t in self.tests:
|
self.disable_test(t, 'Denied')
|
||||||
self.tests[t].update_status('Denied')
|
|
||||||
self.tests[t].disabled = True
|
|
||||||
|
|
||||||
class State():
|
class State():
|
||||||
"""Object to track device objects and overall state."""
|
"""Object to track device objects and overall state."""
|
||||||
|
|
@ -863,6 +869,10 @@ def run_badblocks_test(state, test):
|
||||||
test.update_status('Aborted')
|
test.update_status('Aborted')
|
||||||
raise GenericAbort('Aborted')
|
raise GenericAbort('Aborted')
|
||||||
|
|
||||||
|
# Disable other drive tests if necessary
|
||||||
|
if not test.passed:
|
||||||
|
test.dev.disable_test('I/O Benchmark', 'Denied')
|
||||||
|
|
||||||
# Update status
|
# Update status
|
||||||
if test.failed:
|
if test.failed:
|
||||||
test.update_status('NS')
|
test.update_status('NS')
|
||||||
|
|
@ -1426,9 +1436,7 @@ def run_nvme_smart_tests(state, test):
|
||||||
# Disable other drive tests if necessary
|
# Disable other drive tests if necessary
|
||||||
if not test.passed:
|
if not test.passed:
|
||||||
for t in ['badblocks', 'I/O Benchmark']:
|
for t in ['badblocks', 'I/O Benchmark']:
|
||||||
if t in test.dev.tests:
|
test.dev.disable_test(t, 'Denied')
|
||||||
test.dev.tests[t].update_status('Denied')
|
|
||||||
test.dev.tests[t].disabled = True
|
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
tmux_kill_pane(state.panes['smart'])
|
tmux_kill_pane(state.panes['smart'])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue