summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2003-02-11 03:25:50 +0000
committerJeremy Katz <katzj@redhat.com>2003-02-11 03:25:50 +0000
commitf331f6551588ef2234204ffa8c81a8a1aa4ee1d6 (patch)
tree20dbea1a943b0578a8da83b9bfefddd3a8b16606
parenta755df42cc0b38aa5bef7be65529ec91ec27ca32 (diff)
downloadanaconda-f331f6551588ef2234204ffa8c81a8a1aa4ee1d6.tar.gz
anaconda-f331f6551588ef2234204ffa8c81a8a1aa4ee1d6.tar.xz
anaconda-f331f6551588ef2234204ffa8c81a8a1aa4ee1d6.zip
add (undocumented) preexisting lvm/raid support to kickstart. use
the partition strings in error cases to avoid breaking string freeze (should be fixed post gingin) Adds the following: raid / --device md0 --useexisting Use existing raid device md0, don't format it raid /home --device md0 --noformat Use existing raid device, but format it volgroup myvg --noformat volgroup myvg --useexisting Use existing volume group. Doesn't run vgcreate logvol /foo --vgname=myvg --name=root --noformat Reuse existing logical volume myvg/root and don't format logvol / --vgname=myvg --name=root --useexisting Reuse existing logical volume myvg/root and format it clearpart --none For completeness sake (and because I tried to use it :-) These aren't really supported but are there so that people can play with them and hopefully find the bugs before taroon :) Also has the side effect of probably fixing the occasional traceback mikem sees with lvm that I haven't reproduced (but got something similar to while testing this stuff)
-rw-r--r--autopart.py86
-rw-r--r--kickstart.py48
-rw-r--r--partitions.py4
3 files changed, 125 insertions, 13 deletions
diff --git a/autopart.py b/autopart.py
index 263d277c3..8ad5fcec2 100644
--- a/autopart.py
+++ b/autopart.py
@@ -1152,7 +1152,8 @@ def doAutoPartition(dir, diskset, partitions, intf, instClass, dispatch):
drives = partitions.autoClearPartDrives
for request in partitions.autoPartitionRequests:
- if request.device:
+ if (isinstance(request, partRequests.PartitionSpec) and
+ request.device):
# get the preexisting partition they want to use
req = partitions.getRequestByDeviceName(request.device)
if not req or not req.type or req.type != REQUEST_PREEXIST:
@@ -1177,6 +1178,89 @@ def doAutoPartition(dir, diskset, partitions, intf, instClass, dispatch):
else:
req.format = 1
req.fstype = request.fstype
+ # XXX whee! lots of cut and paste code lies below
+ elif (isinstance(request, partRequests.RaidRequestSpec) and
+ request.preexist == 1):
+ req = partitions.getRequestByDeviceName(request.device)
+ if not req or req.preexist == 0:
+ intf.messageWindow(_("Requested Partition Does Not Exist"),
+ _("Unable to locate partition %s to use "
+ "for %s.\n\n"
+ "Press 'OK' to reboot your system.")
+ % (request.device,
+ request.mountpoint),
+ custom_icon='error')
+ sys.exit(0)
+
+ # now go through and set things from the request to the
+ # preexisting partition's request... ladeda
+ if request.mountpoint:
+ req.mountpoint = request.mountpoint
+ if request.badblocks:
+ req.badblocks = request.badblocks
+ if request.uniqueID: # for raid to work
+ req.uniqueID = request.uniqueID
+ if not request.format:
+ req.format = 0
+ else:
+ req.format = 1
+ req.fstype = request.fstype
+ # XXX not copying the raid bits because they should be handled
+ # automagically (actually, people probably aren't specifying them)
+
+ elif (isinstance(request, partRequests.VolumeGroupRequestSpec) and
+ request.preexist == 1):
+ # get the preexisting partition they want to use
+ req = partitions.getRequestByVolumeGroupName(request.volumeGroupName)
+ if not req or req.preexist == 0 or req.format == 1:
+ intf.messageWindow(_("Requested Partition Does Not Exist"),
+ _("Unable to locate partition %s to use "
+ "for %s.\n\n"
+ "Press 'OK' to reboot your system.")
+ % (request.volumeGroupName,
+ request.mountpoint),
+ custom_icon='error')
+ sys.exit(0)
+
+ # now go through and set things from the request to the
+ # preexisting partition's request... ladeda
+ if request.physicalVolumes:
+ req.physicalVolumes = request.physicalVolumes
+ if request.pesize:
+ req.pesize = request.pesize
+ if request.uniqueID: # for raid to work
+ req.uniqueID = request.uniqueID
+ if not request.format:
+ req.format = 0
+ else:
+ req.format = 1
+ elif (isinstance(request, partRequests.LogicalVolumeRequestSpec) and
+ request.preexist == 1):
+ # get the preexisting partition they want to use
+ req = partitions.getRequestByLogicalVolumeName(request.logicalVolumeName)
+ if not req or req.preexist == 0:
+ intf.messageWindow(_("Requested Partition Does Not Exist"),
+ _("Unable to locate partition %s to use "
+ "for %s.\n\n"
+ "Press 'OK' to reboot your system.")
+ % (request.logicalVolumeName,
+ request.mountpoint),
+ custom_icon='error')
+ sys.exit(0)
+
+ # now go through and set things from the request to the
+ # preexisting partition's request... ladeda
+ if request.volumeGroup:
+ req.volumeGroup = request.volumeGroup
+ if request.mountpoint:
+ req.mountpoint = request.mountpoint
+ if request.uniqueID: # for raid to work
+ req.uniqueID = request.uniqueID
+ if not request.format:
+ req.format = 0
+ else:
+ req.format = 1
+ req.fstype = request.fstype
else:
req = copy.copy(request)
if req.type == REQUEST_NEW and not req.drive:
diff --git a/kickstart.py b/kickstart.py
index 4a211f302..fa39a794f 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -703,7 +703,7 @@ class KickstartBase(BaseInstallClass):
initAll = 0
(args, extra) = isys.getopt(args, '', [ 'linux', 'all', 'drives=',
- 'initlabel'])
+ 'initlabel', 'none'])
for n in args:
(str, arg) = n
@@ -715,6 +715,8 @@ class KickstartBase(BaseInstallClass):
drives = string.split(arg, ',')
elif str == '--initlabel':
initAll = 1
+ elif str == '--none':
+ type = CLEARPART_TYPE_NONE
self.setClearParts(id, type, drives, initAll = initAll)
@@ -725,7 +727,10 @@ class KickstartBase(BaseInstallClass):
'fstype=',
'percent=',
'maxsize=',
- 'grow', 'recommended'])
+ 'grow',
+ 'recommended',
+ 'noformat',
+ 'useexisting'])
mountpoint = None
vgname = None
@@ -737,6 +742,7 @@ class KickstartBase(BaseInstallClass):
maxSizeMB = 0
format = 1
recommended = None
+ preexist = 0
for n in args:
(str, arg) = n
@@ -756,6 +762,11 @@ class KickstartBase(BaseInstallClass):
grow = 1
elif str == '--recommended':
recommended = 1
+ elif str == "--noformat":
+ format = 0
+ preexist = 1
+ elif str == "--useexisting":
+ preexist = 1
else:
print str, " ", arg
@@ -794,15 +805,25 @@ class KickstartBase(BaseInstallClass):
volgroup = vgid,
lvname = name,
grow = grow,
- maxSizeMB=maxSizeMB)
+ maxSizeMB=maxSizeMB,
+ preexist = preexist)
id.partitions.autoPartitionRequests.append(request)
def defineVolumeGroup(self, id, args):
- (args, extra) = isys.getopt(args, '', [])
+ (args, extra) = isys.getopt(args, '', ['noformat','useexisting'])
+
+ preexist = 0
+ format = 1
vgname = extra[0]
+ for n in args:
+ (str, arg) = n
+ if str == '--noformat' or str == '--useexisting':
+ preexist = 1
+ format = 0
+
pvs = []
# get the unique ids of each of the physical volumes
for pv in extra[1:]:
@@ -810,7 +831,7 @@ class KickstartBase(BaseInstallClass):
raise RuntimeError, "Tried to use an undefined partition in Volume Group specification"
pvs.append(self.ksPVMapping[pv])
- if len(pvs) == 0:
+ if len(pvs) == 0 and not preexist:
raise ValueError, "Volume group defined without any physical volumes"
# get a sort of hackish id
@@ -819,14 +840,16 @@ class KickstartBase(BaseInstallClass):
self.ksID = self.ksID + 1
request = partRequests.VolumeGroupRequestSpec(vgname = vgname,
- physvols = pvs)
+ physvols = pvs,
+ preexist = preexist,
+ format = format)
request.uniqueID = uniqueID
id.partitions.autoPartitionRequests.append(request)
def defineRaid(self, id, args):
(args, extra) = isys.getopt(args, '', [ 'level=', 'device=',
'spares=', 'fstype=',
- 'noformat'] )
+ 'noformat', 'useexisting'] )
level = None
raidDev = None
@@ -834,6 +857,7 @@ class KickstartBase(BaseInstallClass):
fstype = None
format = 1
uniqueID = None
+ preexist = 0
for n in args:
(str, arg) = n
@@ -848,6 +872,9 @@ class KickstartBase(BaseInstallClass):
spares = int(arg)
elif str == "--noformat":
format = 0
+ preexist = 1
+ elif str == "--useexisting":
+ preexist = 1
elif str == "--fstype":
fstype = arg
@@ -888,9 +915,9 @@ class KickstartBase(BaseInstallClass):
elif raid.isRaid5(level):
level = "RAID5"
- if not level:
+ if not level and preexist == 0:
raise ValueError, "RAID Partition defined without RAID level"
- if len(raidmems) == 0:
+ if len(raidmems) == 0 and preexist == 0:
raise ValueError, "RAID Partition defined without any RAID members"
request = partRequests.RaidRequestSpec(filesystem,
@@ -899,7 +926,8 @@ class KickstartBase(BaseInstallClass):
raidlevel = level,
raidspares = spares,
format = format,
- raidminor = raidDev)
+ raidminor = raidDev,
+ preexist = preexist)
if uniqueID:
request.uniqueID = uniqueID
diff --git a/partitions.py b/partitions.py
index 9e466e295..7cc33e86a 100644
--- a/partitions.py
+++ b/partitions.py
@@ -162,7 +162,7 @@ class Partitions:
fsystem = fsset.fileSystemTypeGet(fs)
if fs == "swap":
- mnt = "swap"
+ mnt = None
# more forced swap format hacking
format = 1
else:
@@ -269,7 +269,7 @@ class Partitions:
fsystem = fsset.fileSystemTypeGet(fs)
if fs == "swap":
- mnt = "swap"
+ mnt = None
format = 1
else:
mnt = None