disk inventory fix and hp improvement #259

Merged
cyrinux merged 3 commits from fix/cle/hp-inventory-fix-wait into master 2022-12-13 17:28:58 +01:00
Showing only changes of commit cedb6818a3 - Show all commits

View file

@ -18,20 +18,20 @@ def ssacli(sub_command):
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT stderr=subprocess.STDOUT
) )
p.wait() stdout, stderr = p.communicate()
stdout = p.stdout.read().decode("utf-8") stdout = stdout.decode("utf-8")
if p.returncode != 0 and 'does not have any physical' not in stdout: if p.returncode != 0:
mesg = "Failed to execute command '{}':\n{}".format( mesg = "Failed to execute command '{}':\n{}".format(
" ".join(command), stdout " ".join(command), stdout
) )
raise HPRaidControllerError(mesg) raise HPRaidControllerError(mesg)
if 'does not have any physical' in stdout:
return list()
else: else:
if 'does not have any physical' in stdout: lines = stdout.split('\n')
return list() lines = list(filter(None, lines))
else: return lines
lines = stdout.split('\n')
lines = list(filter(None, lines))
return lines
def _test_if_valid_line(line): def _test_if_valid_line(line):
ignore_patterns = ['Note:', 'Error:', 'is not loaded', 'README', ' failure', ' cache'] ignore_patterns = ['Note:', 'Error:', 'is not loaded', 'README', ' failure', ' cache']