Skip to content

Commit f44e3bf

Browse files
subprocess changed to os, test-run success except 5, more bugs to clear
1 parent 07123b3 commit f44e3bf

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

frontend.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
elif (uc == 4):
4444
lvm.introHeader()
4545
no = int(input("How many Physical Volume to add: "))
46-
for i in range(n)
46+
for i in range(no):
4747
vol = input("Enter volume you want to add: ")
4848
lvm.extendVolumeGroup(vol)
4949
continue
@@ -53,23 +53,18 @@
5353
b=True
5454
while b == True:
5555
choose = int(input("Select one you want the details:\n 1.Physical Volume\n \
56-
2.Volume Group\n 3. Logical Volume\n 4.exit\n Your selection: ")
56+
2.Volume Group\n 3. Logical Volume\n 4.exit\n Your selection: ")
5757
if (choose == 1):
5858
lvm.detailsPhysicalVolume()
59-
continue
6059
elif (choose == 2):
6160
lvm.detailsVolumeGroup()
62-
continue
6361
elif (choose == 3):
6462
lvm.detailsLogicalVolume()
65-
continue
6663
elif (choose = 4):
6764
b= False
68-
continue
6965
else:
7066
print("No option Like that available, please select \
7167
between 1 to 4")
72-
continue
7368
continue
7469
elif (uc == 6):
7570
a = False

lvm_backend.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import subprocess
2-
2+
import os
33
def checkAvailableDisks():
44
print(subprocess.run("lsblk"))
55

@@ -15,17 +15,17 @@ def VolList():
1515

1616
def createPhysicalVolume(VolumeList):
1717
for i in VolumeList:
18-
subprocess.run(f"pvcreate {i}")
18+
os.system(f"pvcreate {i}")
1919
print(f"{i} Drive is converted to Physical Volume")
2020
print("All the drives are converted to Physical Volume")
2121

2222
def extendVolumeGroup(Volume):
23-
subprocess.run(f"vgextend {Volume}")
23+
os.system(f"vgextend {Volume}")
2424
print(f"{Volume} is added to Volume Group")
2525

2626
def createVolumeGroup(VolumeList):
2727
volGrpName = input("Enter the name you want to give to your Volume Group: ")
28-
subprocess.run(f"vgcreate {volGrpName} {VolumeList[0]}")
28+
os.system(f"vgcreate {volGrpName} {VolumeList[0]}")
2929
for i in range(1,len(VolumeList)):
3030
extendVolumeGroup(VolumeList[i])
3131
print("Volume Group created with the name {}!".format(volGrpName))
@@ -34,53 +34,54 @@ def createVolumeGroup(VolumeList):
3434
def createLogicalVolume(volGrpName):
3535
logVolName = input("Enter the name you want to give to your Logical Volume: ")
3636
logVolsize= input("Enter the size of Logical Volume you want to create(in G): ")
37-
subprocess.run(f"lvcreate --size {logVolsize}G --name {logVolName}")
37+
os.system(f"lvcreate --size {logVolsize}G --name {logVolName}")
3838
print(f"Logical Volume of size {logVolsize}GB is created with the name {logVolName}")
3939
return logVolName
4040

4141
def extendLogicalVolume(volGrpName,logVolName):
4242
volGrpName = input("Enter the name of your Volume Group: ")
4343
logVolName = input("Enter the name of your Logical volume: ")
4444
addvol=input(f"How much you want to add extra in {logVolName}(in GB): ")
45-
subprocess.run(f"lvextend --size +{addvol}G /dev/{volGrpName}/{logVolName}")
45+
os.system(f"lvextend --size +{addvol}G /dev/{volGrpName}/{logVolName}")
4646
print(f"Logical Volume size increased by {addvol}")
4747

4848
def decreaseLogicalVolume(volGrpName,logVolName):
4949
print("WARNING THIS CAN DESTROY YOUR DATA AND NOT SUPPORTED IN GFS2 AND XFS FORMATS\n"*3)
5050
decvol = input(f"Enter the size by which you want to decrease in {logVolName}(in GB): ")
51-
subprocess.run(f"lvreduce --resizefs -L -{decvol} /dev/{volGrpName}/{logVolName}")
51+
os.system(f"lvreduce --resizefs -L -{decvol} /dev/{volGrpName}/{logVolName}")
5252
print(f"Logical Volume size reduced by {decvol}")
5353

5454
def firstFormat(logVolName,volGrpName):
5555
print("Performing EXT4 formating for first time")
56-
subprocess.run(f"mkfs.ext4 /dev/{volGrpName}/{logVolName}")
56+
os.system(f"mkfs.ext4 /dev/{volGrpName}/{logVolName}")
5757
print("Format complete, disk is ready for mounting!")
5858

5959
def extendedFormat(logVolName,volGrpName):
60-
subprocess.run(f"resize2fs /dev/{volGrpName}/{logVolName}")
60+
os.system(f"resize2fs /dev/{volGrpName}/{logVolName}")
6161
print("Formated extended Volume!")
6262

6363
def mount(logVolName,volGrpName):
6464
des= input("Do you have existing dir on which you have to mount?:(Y/N) ")
65+
dirname = ''
6566
if(des == 'Y'):
6667
dirName = input("Add dir path you want to mount: ")
6768
else:
6869
dirname = input("Give name to dir where you want to mount: ")
69-
subprocess.run(f"mkdir /{dirName}")
70-
subprocess.run(f"mount /dev/{volGrpName}/{logVolName}")
70+
os.system(f"mkdir /{dirName}")
71+
os.system(f"mount /dev/{volGrpName}/{logVolName}")
7172

7273
def detailsPhysicalVolume():
7374
pv = input("Enter the Physical Volume which you want to see details: ")
74-
print(subprocess.run(f"pvdisplay {pv}"))
75+
print(os.system(f"pvdisplay {pv}"))
7576

7677
def detailsVolumeGroup(volGrpName):
7778
vg = input("Enter the Volume Group which you want to see details: ")
78-
print(subprocess.run(f"vgdisplay {vg}"))
79+
print(os.system(f"vgdisplay {vg}"))
7980

8081
def detailsLogicalVolume():
8182
vg = input("Enter the Volume Group where the Logical Volume is located: ")
8283
lv = input("Enter the logical Volume which you want to see details: ")
83-
print(subprocess.run(f"lvdisplay {vg}/{lv}"))
84+
print(os.system(f"lvdisplay {vg}/{lv}"))
8485

8586
def introHeader():
8687
print("""

0 commit comments

Comments
 (0)