Skip to content

Commit 4573d89

Browse files
Backend Functions created, Testing pending
1 parent 74ed34f commit 4573d89

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lvm_backend.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,30 @@ def createPhysicalVolume(VolumeList):
1919
print(f"{i} Drive is converted to Physical Volume")
2020
print("All the drives are converted to Physical Volume")
2121

22-
def extendVolumeGroup(Volume):
23-
os.system(f"vgextend {Volume}")
22+
def extendVolumeGroup(Volume, vgname):
23+
os.system(f"vgextend {vgname} {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: ")
2828
os.system(f"vgcreate {volGrpName} {VolumeList[0]}")
2929
for i in range(1,len(VolumeList)):
30-
extendVolumeGroup(VolumeList[i])
30+
extendVolumeGroup(VolumeList[i],volGrpName)
3131
print("Volume Group created with the name {}!".format(volGrpName))
3232
return volGrpName
3333

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-
os.system(f"lvcreate --size {logVolsize}G --name {logVolName}")
37+
os.system(f"lvcreate --size {logVolsize}G --name {logVolName} {volGrpName}")
3838
print(f"Logical Volume of size {logVolsize}GB is created with the name {logVolName}")
3939
return logVolName
4040

4141
def extendLogicalVolume(volGrpName,logVolName):
42-
volGrpName = input("Enter the name of your Volume Group: ")
43-
logVolName = input("Enter the name of your Logical volume: ")
4442
addvol=input(f"How much you want to add extra in {logVolName}(in GB): ")
4543
os.system(f"lvextend --size +{addvol}G /dev/{volGrpName}/{logVolName}")
4644
print(f"Logical Volume size increased by {addvol}")
45+
os.system("df -h")
4746

4847
def decreaseLogicalVolume(volGrpName,logVolName):
4948
print("WARNING THIS CAN DESTROY YOUR DATA AND NOT SUPPORTED IN GFS2 AND XFS FORMATS\n"*3)
@@ -58,17 +57,19 @@ def firstFormat(logVolName,volGrpName):
5857

5958
def extendedFormat(logVolName,volGrpName):
6059
os.system(f"resize2fs /dev/{volGrpName}/{logVolName}")
61-
print("Formated extended Volume!")
60+
print("Formated the extended Volume!")
6261

6362
def mount(logVolName,volGrpName):
6463
des= input("Do you have existing dir on which you have to mount?:(Y/N) ")
6564
dirname = ''
6665
if(des == 'Y'):
6766
dirName = input("Add dir path you want to mount: ")
6867
else:
69-
dirname = input("Give name to dir where you want to mount: ")
68+
dirName = input("Give name to dir where you want to mount: ")
7069
os.system(f"mkdir /{dirName}")
71-
os.system(f"mount /dev/{volGrpName}/{logVolName}")
70+
os.system(f"mount /dev/{volGrpName}/{logVolName} /{dirName}")
71+
os.system("df -h")
72+
print(f"Disk has mounted over the /{dirName}")
7273

7374
def detailsPhysicalVolume():
7475
pv = input("Enter the Physical Volume which you want to see details: ")

0 commit comments

Comments
 (0)