-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubprocess-filesystemtype
28 lines (24 loc) · 1.03 KB
/
subprocess-filesystemtype
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
from subprocess import Popen, PIPE
'''
Capturing the df -Ph output information in filesysteminfo
'''
filesysteminfo = Popen(['df','-Ph'], stdout=PIPE)
filesysteminfo.wait()
if filesysteminfo.returncode is 0:
'''
filtering the actual filesystems from the df output skipping the temporary filesystem. Actual filesystems always
starts with "/" and then splitting the collected lines, splitting the first element [0] with "/"
and calculating the length of it.
'''
for eachrow in iter(filesysteminfo.stdout.readline, b''):
if eachrow.startswith('/'):
splitting = eachrow.split()
if (len(splitting[0].split('/')) >= 4):
print "Filesystem {} is created on VG-LV setup".format(splitting[0])
else:
print "Filesystem {} is not created on VG-LV setup".format(splitting[0])
Output :
Filesystem /dev/mapper/RHEL7CSB-Root is created on VG-LV setup
Filesystem /dev/mapper/RHEL7CSB-Home is created on VG-LV setup
Filesystem /dev/sda1 is not created on VG-LV setup