summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2002-01-25 08:16:30 +0000
committerJeremy Katz <katzj@redhat.com>2002-01-25 08:16:30 +0000
commitbe5b687ba39eb7e8e8650384850e541df73c6cf0 (patch)
treeba08f1f6a88f9712db6ca18d035ca52091693c38
parent1f43e5e7b546fe7cafca8163f62f51e504e07eb7 (diff)
downloadanaconda-be5b687ba39eb7e8e8650384850e541df73c6cf0.tar.gz
anaconda-be5b687ba39eb7e8e8650384850e541df73c6cf0.tar.xz
anaconda-be5b687ba39eb7e8e8650384850e541df73c6cf0.zip
we can actually create logical volumes now
-rw-r--r--autopart.py5
-rw-r--r--fsset.py134
-rw-r--r--iw/partition_gui.py14
-rw-r--r--packages.py1
-rw-r--r--partitioning.py37
5 files changed, 175 insertions, 16 deletions
diff --git a/autopart.py b/autopart.py
index d1f36732e..56c063721 100644
--- a/autopart.py
+++ b/autopart.py
@@ -619,6 +619,11 @@ def setPreexistParts(diskset, requests, newParts):
else:
part.set_flag(parted.PARTITION_RAID, 0)
+ if request.fstype.getName() == "physical volume (LVM)":
+ part.set_flag(parted.PARTITION_LVM, 1)
+ else:
+ part.set_flag(parted.PARTITION_LVM, 0)
+
set_partition_file_system_type(part, request.fstype)
break
diff --git a/fsset.py b/fsset.py
index 2e18a9131..1e4f78f9e 100644
--- a/fsset.py
+++ b/fsset.py
@@ -69,7 +69,8 @@ def getUsableLinuxFs():
# make sure the default is first in the list, kind of ugly
default = fileSystemTypeGetDefault()
if default in rc:
- rc = [ default ] + rc.remove(default)
+ del rc[rc.index(default)]
+ rc = [ default ] + rc
return rc
def mountCompare(a, b):
@@ -504,11 +505,11 @@ class lvmPhysicalVolumeDummyFileSystem(FileSystemType):
def isMountable(self):
return 0
-
+
def formatDevice(self, entry, progress, chroot='/'):
- # pvcreate did all we need to format this partition...
+ # already done by the pvcreate during volume creation
pass
-
+
fileSystemTypeRegister(lvmPhysicalVolumeDummyFileSystem())
class lvmVolumeGroupDummyFileSystem(FileSystemType):
@@ -526,7 +527,7 @@ class lvmVolumeGroupDummyFileSystem(FileSystemType):
return 0
def formatDevice(self, entry, progress, chroot='/'):
- # vgcreate does this
+ # the vgcreate already did this
pass
fileSystemTypeRegister(lvmVolumeGroupDummyFileSystem())
@@ -964,6 +965,22 @@ class FileSystemSet:
% (entry.device.getDevice(),))
sys.exit(0)
+ def createLogicalVolumes (self, chroot='/'):
+ # first set up the volume groups
+ for entry in self.entries:
+ print entry.fsystem.name
+ if entry.fsystem.name == "volume group (LVM)":
+ print "setting up volume group"
+ entry.device.setupDevice(chroot)
+
+ # then set up the logical volumes
+ for entry in self.entries:
+ print type(entry.device)
+ if type(entry.device) == type(LogicalVolumeDevice):
+ print "setting up a logical volume"
+ entry.device.setupDevice(chroot)
+
+
def makeFilesystems (self, chroot='/'):
formatted = []
for entry in self.entries:
@@ -1345,9 +1362,112 @@ class RAIDDevice(Device):
ext2 = fileSystemTypeGet("ext2")
ext2.registerDeviceArgumentFunction(RAIDDevice, RAIDDevice.ext2Args)
-class LVMDevice(Device):
- def __init__(self):
+class VolumeGroupDevice(Device):
+ def __init__(self, name, physvols, existing = 0):
Device.__init__(self)
+ self.physicalVolumes = physvols
+ self.isSetup = existing
+ self.name = name
+ self.device = name
+
+ # these are attributes we might want to expose. or maybe not
+ # self.physicalextentsize = 4 * 1024 * 1024
+
+ def setupDevice (self, chroot, devPrefix='/tmp'):
+ # XXX cheap hack
+ import _isys
+ for drive in [ "hda", "hdb", "hdc", "hdd", "sda", "sdb", "sdd" ]:
+ _isys.mkdevinode(drive, "/dev/%s" % (drive,))
+ for part in range(1, 16):
+ dev = "%s%d" % (drive, part)
+ path = "/dev/%s" % (dev,)
+ _isys.mkdevinode(dev, path)
+
+ if not self.isSetup:
+ rc = iutil.execWithRedirect("/usr/sbin/vgscan",
+ ["vgscan", "-v"],
+ stdout = "/tmp/lvmout",
+ stderr = "/tmp/lvmout",
+ searchPath = 1)
+ if rc:
+ raise SystemError
+
+ nodes = []
+ for volume in self.physicalVolumes:
+ # XXX the lvm tools are broken and will only work for /dev
+## node = PartitionDevice(volume).setupDevice(chroot,
+## devPrefix="/dev")
+ node = "/dev/%s" % (volume,)
+
+ # now make the device into a real physical volume
+ # XXX I don't really belong here. should
+ # there be a PhysicalVolumeDevice(PartitionDevice) ?
+ rc = iutil.execWithRedirect("/usr/sbin/pvcreate",
+ ["pvcreate", "-ff", "-y",
+ "-v", node],
+ stdout = "/tmp/lvmout",
+ stderr = "/tmp/lvmout",
+ searchPath = 1)
+ if rc:
+ raise SystemError
+
+ nodes.append(node)
+
+
+ args = [ "/usr/sbin/vgcreate", "-v", self.name ]
+ args.extend(nodes)
+ print "running ", args
+ rc = iutil.execWithRedirect(args[0], args,
+ stdout = "/tmp/lvmout",
+ stderr = "/tmp/lvmout",
+ searchPath = 1)
+
+ self.isSetup = 1
+
+ return "/dev/%s" % (self.name,)
+
+ def solidify(self):
+ return
+
+class LogicalVolumeDevice(Device):
+ # note that size is in megabytes!
+ def __init__(self, volumegroup, size, vgname, existing = 0):
+ Device.__init__(self)
+ self.volumeGroup = volumegroup
+ self.size = size
+ self.name = vgname
+ self.isSetup = 0
+
+ # these are attributes we might want to expose. or maybe not.
+ # self.chunksize
+ # self.stripes
+ # self.stripesize
+ # self.extents
+ # self.readaheadsectors
+
+ def setupDevice(self, chroot, devPrefix='/tmp'):
+ if not self.isSetup:
+ rc = iutil.execWithRedirect("/usr/sbin/lvcreate",
+ ["lvcreate", "-L",
+ "%dM" % (self.size,),
+ "-n", self.name,
+ self.volumeGroup],
+ stdout = "/tmp/lvmout",
+ stderr = "/tmp/lvmout",
+ searchPath = 1)
+ if rc:
+ raise SystemError
+
+ self.isSetup = 1
+
+ return self.getDevice()
+
+ def getDevice(self, asBoot = 0):
+ return "/dev/%s/%s" % (self.volumeGroup, self.name)
+
+ def solidify(self):
+ return
+
class PartitionDevice(Device):
def __init__(self, partition):
diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index bb6664186..3b8bb4f02 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -1681,6 +1681,12 @@ class PartitionWindow(InstallWindow):
maintable.attach(createAlignedLabel(_("Size")), 0, 1, row, row + 1)
sizeEntry = gtk.Entry(16)
maintable.attach(sizeEntry, 1, 2, row, row + 1)
+ row = row + 1
+
+ maintable.attach(createAlignedLabel(_("Logical Volume Name")), 0, 1, row, row + 1)
+ lvnameEntry = gtk.Entry(16)
+ maintable.attach(lvnameEntry, 1, 2, row, row + 1)
+ row = row + 1
dialog.vbox.pack_start(maintable)
dialog.show_all()
@@ -1695,9 +1701,10 @@ class PartitionWindow(InstallWindow):
fsystem = fileSystemTypeGetDefault()
mntpt = mountpointEntry.get_text()
size = int(sizeEntry.get_text())
+ lvname = lvnameEntry.get_text()
request = PartitionSpec(fsystem, REQUEST_LV, mountpoint = mntpt,
- size = size)
+ volname = lvname, size = size)
self.logvolreqs.append(request)
self.logvollist.append((mntpt,))
@@ -1761,7 +1768,9 @@ class PartitionWindow(InstallWindow):
# first add the volume group
request = PartitionSpec(fileSystemTypeGet("volume group (LVM)"),
- REQUEST_VG, physvolumes = pv)
+ REQUEST_VG, physvolumes = pv,
+ vgname = volnameEntry.get_text())
+
self.partitions.addRequest(request)
# this is an evil hack for now. should addRequest return the id?
@@ -1771,6 +1780,7 @@ class PartitionWindow(InstallWindow):
# now add the logical volumes
for lv in self.logvolreqs:
lv.volumeGroup = vgID
+ lv.format = 1
self.partitions.addRequest(lv)
for req in self.partitions.requests:
diff --git a/packages.py b/packages.py
index a5d86328b..0c527f2bf 100644
--- a/packages.py
+++ b/packages.py
@@ -330,6 +330,7 @@ def turnOnFilesystems(dir, thefsset, diskset, upgrade, instPath):
if not thefsset.isActive():
diskset.savePartitions ()
thefsset.checkBadblocks(instPath)
+ thefsset.createLogicalVolumes(instPath)
thefsset.formatSwap(instPath)
thefsset.turnOnSwap(instPath)
thefsset.makeFilesystems (instPath)
diff --git a/partitioning.py b/partitioning.py
index a4510a566..645614da3 100644
--- a/partitioning.py
+++ b/partitioning.py
@@ -772,7 +772,8 @@ class PartitionSpec:
constraint = None, migrate = None,
raidmembers = None, raidlevel = None,
raidspares = None, badblocks = None, fslabel = None,
- physvolumes = None, vgname = None, volgroup = None):
+ physvolumes = None, vgname = None,
+ volgroup = None, volname = None):
#
# requesttype: REQUEST_PREEXIST or REQUEST_NEW or REQUEST_RAID
#
@@ -815,7 +816,8 @@ class PartitionSpec:
self.volumeGroupName = vgname
# logical volume specific. volgroup is the uniqueID of the VG
- self.volumeGroup = volgroup
+ self.volumeGroup = volgroup
+ self.logicalVolumeName = volname
# fs label (if pre-existing, otherwise None)
self.fslabel = fslabel
@@ -854,7 +856,10 @@ class PartitionSpec:
" raidspares: %s" % (self.raidspares)+\
" raidmembers: %s\n" % (raidmem)+\
" vgname: %s" % (self.volumeGroupName)+\
- " physical volumes: %s" % (self.physicalVolumes)
+ " physical volumes: %s\n" % (self.physicalVolumes)+\
+ " parent volume group: %s" % (self.volumeGroup)+\
+ " logical volume name: %s" % (self.logicalVolumeName)
+
# turn a partition request into a fsset entry
def toEntry(self, partitions):
@@ -866,8 +871,20 @@ class PartitionSpec:
raidmems,
spares = self.raidspares)
# XXX need to handle this obviously
- elif self.type == REQUEST_LV or self.type == REQUEST_VG:
- return None
+ elif self.type == REQUEST_VG:
+ pvs = []
+ for pv in self.physicalVolumes:
+ pvs.append(partitions.getRequestByID(pv).device)
+ device = fsset.VolumeGroupDevice(self.volumeGroupName, pvs)
+ print "found volume group %s" % (self.volumeGroupName)
+ print "pvs are ", pvs
+ elif self.type == REQUEST_LV:
+ device = fsset.LogicalVolumeDevice(
+ partitions.getRequestByID(self.volumeGroup).volumeGroupName,
+ self.size,
+ self.logicalVolumeName)
+ print "found logical volume %s, vg is %s" % (self.logicalVolumeName,
+ self.volumeGroup)
else:
device = fsset.PartitionDevice(self.device)
@@ -1944,8 +1961,14 @@ def partitioningComplete(bl, fsset, diskSet, partitions, intf, instPath, dir):
# XXX hack for lvm not being complete, *must* be error condition pre-release
if entry:
fsset.add (entry)
-## else:
-## raise RuntimeError, "Managed to not get an entry back from request.toEntry"
+ else:
+ raise RuntimeError, "Managed to not get an entry back from request.toEntry"
+ print entry, entry.fsystem.name,
+ if entry.mountpoint:
+ print entry.mountpoint
+ else:
+ print ""
+
if iutil.memInstalled() > isys.EARLY_SWAP_RAM:
return
# XXX this attribute is probably going away