summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Fulbright <msf@redhat.com>2002-02-01 23:32:25 +0000
committerMike Fulbright <msf@redhat.com>2002-02-01 23:32:25 +0000
commit210d6a886e6b29bbdc910c1d01611b3c8edae781 (patch)
tree762e9ff2a04e3f10936a8b2b1e49907d00c784b9
parent577adda544f4447c2946c36b3fd3a4aec8ae5667 (diff)
downloadanaconda-210d6a886e6b29bbdc910c1d01611b3c8edae781.tar.gz
anaconda-210d6a886e6b29bbdc910c1d01611b3c8edae781.tar.xz
anaconda-210d6a886e6b29bbdc910c1d01611b3c8edae781.zip
lots of lvm ui fixes and sanity checking
-rw-r--r--autopart.py5
-rw-r--r--iw/partition_gui.py113
-rw-r--r--partitioning.py119
3 files changed, 205 insertions, 32 deletions
diff --git a/autopart.py b/autopart.py
index ad1ee206f..6364183af 100644
--- a/autopart.py
+++ b/autopart.py
@@ -717,14 +717,15 @@ def processPartitioning(diskset, requests, newParts):
if request.type == REQUEST_RAID and not request.device:
request.device = str(request.uniqueID)
if request.type == REQUEST_VG and not request.device:
- request.device = request.volumeGroupName
+ request.device = str(request.uniqueID)
# anything better we can use for the logical volume?
if request.type == REQUEST_LV and not request.device:
request.device = str(request.uniqueID)
if request.type == REQUEST_RAID:
request.size = get_raid_device_size(request, requests, diskset) / 1024 / 1024
-
+ elif request.type == REQUEST_VG:
+ request.size = get_lvm_volume_group_size(request, requests, diskset) / 1024 / 1024
if not request.device:
# return PARTITION_FAIL
raise PartitioningError, "Unsatisfied partition request\n%s" %(request)
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index af34f63a3..34e422755 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -2,6 +2,7 @@
# partition_gui.py: allows the user to choose how to partition their disks
#
# Matt Wilson <msw@redhat.com>
+# Michael Fulbright <msf@redhat.com>
#
# Copyright 2001 Red Hat, Inc.
#
@@ -824,14 +825,28 @@ class PartitionWindow(InstallWindow):
for vgname in lvmrequests.keys():
vgparent = self.tree.append(lvmparent)
self.tree[vgparent]['Device'] = _("LVM: %s") % (vgname,)
- vgrequest = self.partitions.getRequestByDeviceName(vgname)
- self.tree[vgparent]['PyObject'] = vgrequest.volumeGroupName
+ vgrequest = self.partitions.getRequestByVolumeGroupName(vgname)
+ rsize = requestSize(vgrequest, self.partitions, self.diskset)
+ print "volume group %s size is %s" % (vgname, rsize)
+ self.tree[vgparent]['Mount Point'] = ""
+ self.tree[vgparent]['Size (MB)'] = "%g" % (rsize,)
+ self.tree[vgparent]['Type'] = _("LVM Volume Group")
+ if lvmrequests[vgname]:
+ self.tree[vgparent]['IsLeaf'] = gtk.FALSE
+ else:
+ self.tree[vgparent]['IsLeaf'] = gtk.TRUE
+ self.tree[vgparent]['Start'] = ""
+ self.tree[vgparent]['End'] = ""
+# self.tree[vgparent]['PyObject'] = vgrequest.volumeGroupName
+ self.tree[vgparent]['PyObject'] = str(vgrequest.uniqueID)
for lvrequest in lvmrequests[vgname]:
iter = self.tree.append(vgparent)
self.tree[iter]['Device'] = lvrequest.logicalVolumeName
self.tree[iter]['Mount Point'] = lvrequest.mountpoint
- self.tree[iter]['Size (MB)'] = "%g" % (lvrequest.size)
- self.tree[iter]['PyObject'] = lvrequest.logicalVolumeName
+ self.tree[iter]['Size (MB)'] = "%g" % (lvrequest.size,)
+ print lvrequest.logicalVolumeName
+# self.tree[iter]['PyObject'] = lvrequest.logicalVolumeName
+ self.tree[iter]['PyObject'] = str(lvrequest.uniqueID)
ptype = lvrequest.fstype.getName()
self.tree[iter]['Format'] = gtk.TRUE
@@ -872,7 +887,7 @@ class PartitionWindow(InstallWindow):
# self.tree[iter]['Start'] = ""
# self.tree[iter]['End'] = ""
self.tree[iter]['Size (MB)'] = "%g" % (request.size)
- self.tree[iter]['PyObject'] = request.device
+ self.tree[iter]['PyObject'] = str(request.uniqueID)
raidcounter = raidcounter + 1
@@ -1423,9 +1438,9 @@ class PartitionWindow(InstallWindow):
if request.end <= request.start:
self.intf.messageWindow(_("Error With Request"),
- "The end cylinder must be "
+ _("The end cylinder must be "
"greater than the start "
- "cylinder.")
+ "cylinder."))
continue
@@ -1837,27 +1852,61 @@ class PartitionWindow(InstallWindow):
lvname = string.strip(lvnameEntry.get_text())
- print "|%s|" % (mntpt,)
err = sanityCheckMountPoint(mntpt, fsystem, REQUEST_LV)
if err:
self.intf.messageWindow(_("Bad mount point"), err)
continue
used = 0
- if isNew or logrequest is None or mntpt != logrequest.mountpoint:
+ if not logrequest or mntpt != logrequest.mountpoint:
+ # check in existing requests
curreq = self.partitions.getRequestByMountPoint(mntpt)
if curreq:
used = 1
+ # check in pending logical volume requests
+ if not used:
+ for lv in self.logvolreqs:
+ if logrequest and logrequest.mountpoint and lv.mountpoint == logrequest.mountpoint:
+ continue
+
+ if lv.mountpoint == mntpt:
+ used = 1
+ break
+
if used:
self.intf.messageWindow(_("Mount point in use"),
_("The mount point %s is in use, "
"please pick another.") % (mntpt,))
continue
- if len(lvname) < 1:
+ err = sanityCheckLogicalVolumeName(lvname)
+ if err:
self.intf.messageWindow(_("Illegal Logical Volume Name"),
- _("Please enter a logical volume name."))
+ err)
+ continue
+
+ # is it in use?
+ used = 0
+ if logrequest:
+ origlvname = logrequest.logicalVolumeName
+ else:
+ origlvname = None
+
+ if not used:
+ for lv in self.logvolreqs:
+ if logrequest and logrequest.mountpoint and lv.mountpoint == logrequest.mountpoint:
+ continue
+
+ if lv.logicalVolumeName == lvname:
+ used = 1
+ break
+
+ if used:
+ self.intf.messageWindow(_("Illegal logical volume name"),
+ _("The logical volume name %s is "
+ "already in use. Please pick "
+ "another.") % (lvname,))
continue
# everything ok
@@ -1881,6 +1930,9 @@ class PartitionWindow(InstallWindow):
def editCurrentLogicalVolume(self):
iter = self.getCurrentLogicalVolume()
+
+ if iter is None:
+ return
logvolname = self.logvolstore.get_value(iter, 0)
logrequest = None
@@ -2056,8 +2108,9 @@ class PartitionWindow(InstallWindow):
pv.append(id)
part = get_partition_by_name(self.diskset.disks, partname)
- availSpaceMB = availSpaceMB + getPartSizeMB(part)
-
+ availSpaceMB = availSpaceMB + requestSize(pvreq,
+ self.partitions,
+ self.diskset)
next = model.iter_next(iter)
print "Total size of volume group is %g MB" % (availSpaceMB,)
@@ -2079,11 +2132,30 @@ class PartitionWindow(InstallWindow):
# check volume name
volname = string.strip(volnameEntry.get_text())
- if len(volname) < 1:
- self.intf.messageWindow(_("Illegal Volume Group Name"),
- _("Please enter a volume group name"))
+ err = sanityCheckVolumeGroupName(volname)
+ if err:
+ self.intf.messageWindow(_("Invalid Volume Group Name"), err)
continue
+ if origvgrequest:
+ origvname = origvgrequest.volumeGroupName
+ else:
+ origname = None
+
+ if origvname != volname:
+ tmpreq = PartitionSpec(fileSystemTypeGet("volume group (LVM)"),
+ REQUEST_VG, physvolumes = pv,
+ vgname = volname)
+ if isVolumeGroupNameInUse(self.partitions, tmpreq):
+ self.intf.messageWindow(_("Name in use"),
+ _("The volume group name %s is "
+ "already in use. Please pick "
+ "another." % (volname,)))
+ del tmpreq
+ continue
+
+ del tmpreq
+
# everything ok
break
@@ -2114,9 +2186,12 @@ class PartitionWindow(InstallWindow):
# print req
# XXX - probably shouldn't do this here - trying to force refresh of ui
- self.diskStripeGraph.shutDown()
- self.tree.clear()
- self.populate()
+# self.diskStripeGraph.shutDown()
+# self.tree.clear()
+# self.populate()
+
+ # XXX should probably check if this fails, cant see how it could
+ self.refresh()
dialog.destroy()
return
diff --git a/partitioning.py b/partitioning.py
index 270f4e07f..f90d3c2d1 100644
--- a/partitioning.py
+++ b/partitioning.py
@@ -308,6 +308,18 @@ def get_available_lvm_partitions(diskset, requests, request):
rc.append((partname, getPartSizeMB(part), 1))
return rc
+def get_lvm_volume_group_size(request, requests, diskset):
+ # got to add up all of physical volumes to get total size
+ if request.physicalVolumes is None:
+ return 0
+ totalspace = 0
+ for physvolid in request.physicalVolumes:
+ pvreq = requests.getRequestByID(physvolid)
+ part = get_partition_by_name(diskset.disks, pvreq.device)
+ totalspace = totalspace + part.geom.length * part.geom.disk.dev.sector_size
+
+ return totalspace
+
# set of functions to determine if the given level is RAIDX or X
def isRaid5(raidlevel):
if raidlevel == "RAID5":
@@ -388,6 +400,35 @@ def get_raid_device_size(raidrequest, partitions, diskset):
else:
raise ValueError, "Invalid raidlevel in get_raid_device_size()"
+def sanityCheckVolumeGroupName(volname):
+ badNames = ['lvm']
+
+ if not volname:
+ return _("Please enter a volume group name.")
+
+ if volname in badNames:
+ return _("Error - the volume group name %s is not valid." % (volname,))
+
+ if string.find(volname, '/') != -1 or string.find(volname, ' ') != -1:
+ return _("Error - the volume group name contains illegal characters "
+ " or spaces.")
+ return None
+
+def sanityCheckLogicalVolumeName(logvolname):
+ badNames = ['group']
+
+ if not logvolname:
+ return _("Please enter a logical volume name.")
+
+ if logvolname in badNames:
+ return _("Error - the logical volume name %s is not valid." % (logvolname,))
+
+ if string.find(logvolname, '/') != -1 or string.find(logvolname, ' ') != -1:
+ return _("Error - the logical volume name contains illegal characters "
+ " or spaces.")
+ return None
+
+
# sanityCheckMountPoint
def sanityCheckMountPoint(mntpt, fstype, reqtype):
if mntpt:
@@ -413,6 +454,43 @@ def sanityCheckMountPoint(mntpt, fstype, reqtype):
# its an existing partition so don't force a mount point
return None
+def isVolumeGroupNameInUse(reqpartitions, req):
+ volname = req.volumeGroupName
+ if not volname:
+ return None
+
+ lvmrequests = reqpartitions.getLVMRequests()
+ if not lvmrequests:
+ return None
+
+ if volname in lvmrequests.keys():
+ return 1
+
+ return 0
+
+def isLogicalVolumeNameInUse(reqpartitions, req):
+ logvolname = req.logicalVolumeName
+ if not logvolname:
+ return None
+
+ lvmrequests = reqpartitions.getLVMRequests()
+ if not lvmrequests:
+ return None
+
+ for vgname in lvmrequests.keys():
+ vgrequest = reqpartitions.getRequestByDeviceName(vgname)
+ if not lvmrequests[vgname]:
+ continue
+ for lvrequest in lvmrequests[vgname]:
+ lvname = lvrequest.logicalVolumeName
+ if not lvname:
+ continue
+
+ if lvname == logvolname:
+ return 1
+
+ return 0
+
def isMountPointInUse(reqpartitions, newrequest):
mntpt = newrequest.mountpoint
if not mntpt:
@@ -590,7 +668,12 @@ def sanityCheckRaidRequest(reqpartitions, newraid, doPartitionCheck = 1):
return None
# return the actual size being used by the request in megabytes
-def requestSize(req, diskset):
+def requestSize(req, allrequests, diskset):
+ if req.type == REQUEST_VG:
+ if req.size != None:
+ thissize = req.size
+ else:
+ thissize = 0
if req.type == REQUEST_RAID:
# XXX duplicate the hack below.
if req.size != None:
@@ -626,12 +709,12 @@ def sanityCheckAllRequests(requests, diskset, baseChecks = 0):
if not slash:
errors.append(_("You have not defined a root partition (/), which is required for installation of Red Hat Linux to continue."))
- if slash and requestSize(slash, diskset) < 250:
+ if slash and requestSize(slash, requests, diskset) < 250:
warnings.append(_("Your root partition is less than 250 megabytes which is usually too small to install Red Hat Linux."))
if iutil.getArch() == "ia64":
bootreq = requests.getRequestByMountPoint("/boot/efi")
- if not bootreq or requestSize(bootreq, diskset) < 50:
+ if not bootreq or requestSize(bootreq, requests, diskset) < 50:
errors.append(_("You must create a /boot/efi partition of type "
"FAT and a size of 50 megabytes."))
@@ -639,7 +722,7 @@ def sanityCheckAllRequests(requests, diskset, baseChecks = 0):
req = requests.getRequestByMountPoint(mount)
if not req:
continue
- if requestSize(req, diskset) < size:
+ if requestSize(req, requests, diskset) < size:
warnings.append(_("Your %s partition is less than %s megabytes which is lower than recommended for a normal Red Hat Linux install.") %(mount, size))
foundSwap = 0
@@ -647,7 +730,7 @@ def sanityCheckAllRequests(requests, diskset, baseChecks = 0):
for request in requests.requests:
if request.fstype and request.fstype.getName() == "swap":
foundSwap = foundSwap + 1
- swapSize = swapSize + requestSize(request, diskset)
+ swapSize = swapSize + requestSize(request, requests, diskset)
if baseChecks:
rc = doPartitionSizeCheck(request)
if rc:
@@ -1031,7 +1114,6 @@ class Partitions:
part = disk.next_partition(part)
def addRequest (self, request):
-# print "adding %s" %(self.nextUniqueID)
if not request.uniqueID:
request.uniqueID = self.nextUniqueID
self.nextUniqueID = self.nextUniqueID + 1
@@ -1056,20 +1138,35 @@ class Partitions:
return None
def getRequestByDeviceName(self, device):
+ if device is None:
+ return None
+
for request in self.requests:
if request.device == device:
return request
+
+ def getRequestByVolumeGroupName(self, volname):
# now look for a Volume group or logical volume that matches
+ if volname is None:
+ return None
+
for request in self.requests:
- if request.type == REQUEST_VG and request.volumeGroupName == device:
+ if request.type == REQUEST_VG and request.volumeGroupName == volname:
return request
- elif request.type == REQUEST_LV and request.logicalVolumeName == device:
- return request
-
return None
+ def getRequestByLogicalVolumeName(self, lvname):
+ if lvname is None:
+ return None
+ for request in self.requests:
+ if request.type == REQUEST_LV and request.logicalVolumeName == lvname:
+ return request
+
+
def getRequestByID(self, id):
+ if type(id) == type("a string"):
+ id = int(id)
for request in self.requests:
if request.uniqueID == id:
return request
@@ -2014,7 +2111,7 @@ def doEditPartitionByRequest(intf, requestlist, part):
return (None, None)
if type(part) == type("RAID"):
- request = requestlist.getRequestByDeviceName(part)
+ request = requestlist.getRequestByID(int(part))
if request.type == REQUEST_RAID:
return ("RAID", request)