Skip to content

Commit 69bdeeb

Browse files
committed
increases the disk changes
1 parent b334273 commit 69bdeeb

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

getDiskInfo.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from glob import glob
2+
import subprocess
3+
import os
4+
import sys
5+
from os.path import basename, dirname
6+
7+
def physical_drives():
8+
drive_glob = '/sys/block/*/device'
9+
return [basename(dirname(d)) for d in glob(drive_glob)]
10+
11+
def partitions(disk):
12+
if disk.startswith('.') or '/' in disk:
13+
raise ValueError('Invalid disk name {0}'.format(disk))
14+
partition_glob = '/sys/block/{0}/*/start'.format(disk)
15+
return [basename(dirname(p)) for p in glob(partition_glob)]
16+
17+
disk = physical_drives()
18+
disk_part = partitions(disk[0])
19+
20+
conv_str = ' '.join(map(str, disk_part))
21+
main_device = "/dev/" + conv_str
22+
23+
# Fetching mount point from main_device
24+
25+
df = subprocess.Popen(["df", "-hT", main_device], stdout=subprocess.PIPE)
26+
output = df.communicate()[0]
27+
device, Type, size, used, available, percent, mountpoint = output.split("\n")[1].split()
28+
29+
if Type == 'xfs':
30+
os.system('sudo xfs_growfs -d '+mountpoint)
31+
print('file system has been extended')
32+
elif Type == 'ext3' or 'ext4':
33+
print('Need to work on ext file systems')
34+
35+
sys.exit(0)
36+

0 commit comments

Comments
 (0)