Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import subprocess
- import os
- def main():
- clear_raids()
- clear_lvm()
- def clear_raids():
- raids = str(subprocess.check_output('cat /proc/mdstat', shell=True))
- cock = raids.find('md')
- my_raids = raids[cock:]
- new_raids = my_raids.split('[U' or '[_')
- for string in new_raids:
- md = re.findall(r'(md\d+)', string)
- os.system('mdadm -S /dev/' + ''.join(md))
- raid = re.findall(r'(\w+\[\d+\])', my_raids)
- names = re.findall(r'[a-zA-Z]+', ''.join(raid))
- for name in names:
- sname = ''.join(name)
- os.system('mdadm --zero-superblock /dev/' + sname)
- def clear_lvm():
- lvms = str(subprocess.check_output('pvdisplay', shell=True))
- new_lvms = lvms.split('--- Physical volume ---')
- for lvm in new_lvms:
- #pv_name = re.findall(r'/\w+/\w+',lvm)
- VG_name=lvm.find('VG Name')
- PV_size = lvm.find('PV Size')
- my_lvm = lvm[VG_name:PV_size]
- lvm_name=re.findall(r'(\w+\\n)', ''.join(my_lvm))
- slvm = ''.join(lvm_name).strip('\\n')
- os.system('lvremove '+slvm)
- os.system('vgremove '+slvm)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement