Skip to content
Snippets Groups Projects
Commit c06c6122 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Fixed RAID test (refs #25198).

parent 701fd2e8
No related branches found
No related tags found
No related merge requests found
...@@ -14,33 +14,43 @@ GREEN = '\033[92m' ...@@ -14,33 +14,43 @@ GREEN = '\033[92m'
RED = '\033[91m' RED = '\033[91m'
DEF = '\033[0m' DEF = '\033[0m'
def print_red(string): def print_red(string):
print(RED + string + DEF) print(RED + string + DEF)
def print_green(string): def print_green(string):
print(GREEN + string + DEF) print(GREEN + string + DEF)
def check_raid(dev): def check_raid(dev):
cmd = 'mdadm -D %s' % dev cmd = 'mdadm -D %s' % dev
status, output = subprocess.getstatusoutput(cmd) status, output = subprocess.getstatusoutput(cmd)
ok = status == 0 if status != 0:
print('%s status: %s' % (dev, ok)) print_red('The mdadm command on %s failed:' % dev)
return ok elif 'degraded' in output:
print_red('The %s RAID partition is degraded:' % dev)
else:
print_green('The %s RAID partition is ok.' % dev)
return True
print(cmd)
print(output)
return False
if os.path.isfile('/proc/mdstat'): if os.path.isfile('/proc/mdstat'):
all_ok = True all_ok = True
for r in glob.glob('/dev/md*'): for r in glob.glob('/dev/md*'):
# ignore /dev/md folder # ignore /dev/md folder
if os.path.isfile(r): if os.path.exists(r) and not os.path.isdir(r):
all_ok = min(check_raid(r), all_ok) all_ok = min(check_raid(r), all_ok)
if all_ok: if all_ok:
print_green('Everything fine') print_green('Everything fine')
else: else:
print_red('Some array is in bad shape') print_red('Some array is in bad shape')
with open('/proc/mdstat', 'r') as f: with open('/proc/mdstat', 'r') as fo:
d = f.read() print(fo.read())
print(d) sys.exit(int(not all_ok))
sys.exit(not all_ok)
else: else:
print('No software RAID array found, untestable') print('No software RAID array found, untestable')
sys.exit(2) sys.exit(2)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment