Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import re
- RAID_HW = 0
- RAID_SW = 1
- MDSTAT_PATH = "/Users/jgabriel/Documents/Python/files_res/mdstat"
- def get_soft_raid_map():
- saida = []
- deviceinfo = []
- raid_device = raid_type = raid_status = None
- for line in open(MDSTAT_PATH, "r"):
- line = line.strip()
- if len(line) == 0:
- continue
- parts = line.split()
- if re.search('blocks',line):
- raid_status = parts[-1]
- deviceinfo.append(raid_status)
- continue
- if re.search('active',line):
- raid_device = "/dev/" + parts[0]
- raid_type = parts[3]
- deviceinfo.append(raid_device)
- deviceinfo.append(raid_type)
- saida.append(deviceinfo)
- deviceinfo = []
- return saida
- def qual_eh_o_raid():
- for jao in open(MDSTAT_PATH, "r"):
- jao = jao.strip()
- if len(jao) == 0:
- continue
- if re.search('raid', jao):
- return RAID_SW
- else:
- return RAID_HW
- if __name__ == '__main__':
- print get_soft_raid_map()
- # raid_type = qual_eh_o_raid()
- # if raid_type == RAID_HW:
- # print "hardware raid detected."
- # else:
- # print "software raid detected."
- # for device, tipo, status in get_soft_raid_map():
- # print "device=(%s), tipo=(%s), status(%s)" % (device, tipo, status)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement