diff options
author | David Cantrell <dcantrell@redhat.com> | 2006-12-13 20:52:19 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2006-12-13 20:52:19 +0000 |
commit | 9756654625f088ae908c4d198cba1b6301199ee5 (patch) | |
tree | 771a140a4cf5ad1b0de6c38408a0841196c08bdb /partedUtils.py | |
parent | a45acd9e9a0a1cd4ed49b9fb1c6bb0bce4118429 (diff) | |
download | anaconda-9756654625f088ae908c4d198cba1b6301199ee5.tar.gz anaconda-9756654625f088ae908c4d198cba1b6301199ee5.tar.xz anaconda-9756654625f088ae908c4d198cba1b6301199ee5.zip |
* anaconda (__main__): Pass reference to anaconda object to InstallData.
* fsset.py (readFstab): Take reference to anaconda object rather than
a path and intf. Pass anaconda reference to DiskSet().
* fssey.py (__main__): Removed.
* installclass.py (BaseInstallClass): Pass anaconda reference to the
reset() method for InstallData.
* instdata.py (InstallData.reset): Take anaconda object reference as
parameter. Pass anaconda to DiskSet().
* instdata.py (InstallData.__init__): Take anaconda object ref as
parameter, pass it to reset() method.
* kickstart.py (AnacondaKSHandlers): Store anaconda object reference,
pass to DiskSet() object creations.
* partedUtils.py (DiskSet): Take anaconda object reference, store. Use
self.anaconda throughout DiskSet object, remove individual pass-ins
of intf and other anaconda object parts.
* partedUtils.py (DiskSet.dastFmt): Remove -P dasdfmt(8) arg (#218861).
* partedUtils.py (DiskSet.openDevices): Remove intf, initAll, zeroMbr,
and clearDevs params since those are in the anaconda object. When a
kickstart install is running, the dasd found is in the clearpart list,
and the --initlabel option has been used, skip the interactive dialog
asking if you want to format the DASD and just do it (#218861).
* partitioning.py (partitionObjectsInitialize): Removed arguments since
the anaconda object provides those now.
* upgrade.py (mountRootPartition): Pass anaconda object ref to DiskSet.
Only pass anaconda ref to readFstab().
* upgrade.py (upgradeMountFilesystems): Likewise.
Diffstat (limited to 'partedUtils.py')
-rw-r--r-- | partedUtils.py | 115 |
1 files changed, 65 insertions, 50 deletions
diff --git a/partedUtils.py b/partedUtils.py index bb05f7b06..5dd0861f9 100644 --- a/partedUtils.py +++ b/partedUtils.py @@ -552,9 +552,10 @@ class DiskSet: dmList = None mpList = None - def __init__ (self): + def __init__ (self, anaconda): self.disks = {} self.onlyPrimary = None + self.anaconda = anaconda def onlyPrimaryParts(self): for disk in self.disks.values(): @@ -701,7 +702,7 @@ class DiskSet: return labels - def findExistingRootPartitions(self, anaconda, upgradeany = 0): + def findExistingRootPartitions(self, upgradeany = 0): """Return a list of all of the partitions which look like a root fs.""" rootparts = [] @@ -717,15 +718,15 @@ class DiskSet: found = 0 for fs in fsset.getFStoTry(dev): try: - isys.mount(dev, anaconda.rootPath, fs, readOnly = 1) + isys.mount(dev, self.anaconda.rootPath, fs, readOnly = 1) found = 1 break except SystemError, (errno, msg): pass if found: - if os.access (anaconda.rootPath + '/etc/fstab', os.R_OK): - relstr = getReleaseString(anaconda.rootPath) + if os.access (self.anaconda.rootPath + '/etc/fstab', os.R_OK): + relstr = getReleaseString(self.anaconda.rootPath) if ((upgradeany == 1) or (productMatches(relstr, productName))): @@ -735,7 +736,7 @@ class DiskSet: label = None rootparts.append ((dev, fs, relstr, label)) - isys.umount(anaconda.rootPath) + isys.umount(self.anaconda.rootPath) # now, look for candidate lvm roots lvm.vgscan() @@ -748,15 +749,15 @@ class DiskSet: found = 0 for fs in fsset.getFStoTry(dev): try: - isys.mount(dev, anaconda.rootPath, fs, readOnly = 1) + isys.mount(dev, self.anaconda.rootPath, fs, readOnly = 1) found = 1 break except SystemError: pass if found: - if os.access (anaconda.rootPath + '/etc/fstab', os.R_OK): - relstr = getReleaseString(anaconda.rootPath) + if os.access (self.anaconda.rootPath + '/etc/fstab', os.R_OK): + relstr = getReleaseString(self.anaconda.rootPath) if ((upgradeany == 1) or (productMatches(relstr, productName))): @@ -766,7 +767,7 @@ class DiskSet: label = None rootparts.append ((dev, fs, relstr, label)) - isys.umount(anaconda.rootPath) + isys.umount(self.anaconda.rootPath) lvm.vgdeactivate() @@ -791,19 +792,19 @@ class DiskSet: # In hard drive ISO method, don't try to mount the # protected partitions because that'll throw up a # useless error message. - protected = anaconda.method.protectedPartitions() + protected = self.anaconda.method.protectedPartitions() if protected and node in protected: part = disk.next_partition(part) continue try: - isys.mount(node, anaconda.rootPath, part.fs_type.name) + isys.mount(node, self.anaconda.rootPath, part.fs_type.name) except SystemError, (errno, msg): part = disk.next_partition(part) continue - if os.access (anaconda.rootPath + '/etc/fstab', os.R_OK): - relstr = getReleaseString(anaconda.rootPath) + if os.access (self.anaconda.rootPath + '/etc/fstab', os.R_OK): + relstr = getReleaseString(self.anaconda.rootPath) if ((upgradeany == 1) or (productMatches(relstr, productName))): @@ -814,7 +815,7 @@ class DiskSet: rootparts.append ((node, part.fs_type.name, relstr, label)) - isys.umount(anaconda.rootPath) + isys.umount(self.anaconda.rootPath) part = disk.next_partition(part) return rootparts @@ -874,12 +875,11 @@ class DiskSet: del disk self.refreshDevices() - def refreshDevices (self, intf = None, initAll = 0, - zeroMbr = 0, clearDevs = []): + def refreshDevices (self): """Reread the state of the disks as they are on disk.""" self.closeDevices() self.disks = {} - self.openDevices(intf, initAll, zeroMbr, clearDevs) + self.openDevices() def closeDevices (self): """Close all of the disks which are open.""" @@ -889,13 +889,13 @@ class DiskSet: #self.disks[disk].close() del self.disks[disk] - def dasdFmt (self, intf = None, drive = None): + def dasdFmt (self, drive = None): """Format dasd devices (s390).""" if self.disks.has_key(drive): del self.disks[drive] - w = intf.progressWindow (_("Initializing"), + w = self.anaconda.intf.progressWindow (_("Initializing"), _("Please wait while formatting drive %s...\n" ) % (drive,), 100) try: @@ -907,7 +907,6 @@ class DiskSet: "-y", "-b", "4096", "-d", "cdl", - "-P", "-F", "-f", "/tmp/%s" % drive] @@ -971,14 +970,14 @@ class DiskSet: return 1 - def openDevices (self, intf = None, initAll = 0, - zeroMbr = 0, clearDevs = []): + def openDevices (self): """Open the disks on the system and skip unopenable devices.""" if self.disks: return self.startMPath() self.startDmRaid() + for drive in self.driveList(): # ignoredisk takes precedence over clearpart (#186438). if drive in DiskSet.skippedDisks: @@ -987,14 +986,26 @@ class DiskSet: if not isys.mediaPresent(drive): DiskSet.skippedDisks.append(drive) continue + + if self.anaconda.isKickstart: + cdl = self.anaconda.ksdata.clearpart["drives"] + initlbl = self.anaconda.ksdata.clearpart["initAll"] + else: + cdl = [] + initlbl = False + # FIXME: need the right fix for z/VM formatted dasd if rhpl.getArch() == "s390" and drive[:4] == "dasd" and isys.getDasdState(drive): devs = isys.getDasdDevPort() - if intf is None: + if self.anaconda.intf is None: DiskSet.skippedDisks.append(drive) continue - rc = intf.messageWindow(_("Warning"), - _("The partition table on device %s (%s) was unreadable. " + + if self.anaconda.isKickstart and (drive in cdl) and initlbl: + rc = 1 + else: + rc = self.anaconda.intf.messageWindow(_("Warning"), + _("The partition table on device %s (%s) was unreadable. " "To create new partitions it must be initialized, " "causing the loss of ALL DATA on this drive.\n\n" "This operation will override any previous " @@ -1003,11 +1014,12 @@ class DiskSet: "Would you like to initialize this drive, " "erasing ALL DATA?") % (drive, devs[drive]), type = "yesno") + if rc == 0: DiskSet.skippedDisks.append(drive) continue else: - if (self.dasdFmt(intf, drive)): + if (self.dasdFmt(drive)): DiskSet.skippedDisks.append(drive) continue @@ -1017,10 +1029,9 @@ class DiskSet: DiskSet.skippedDisks.append(drive) continue - if (initAll and ((clearDevs is None) or (len(clearDevs) == 0) - or drive in clearDevs) and not flags.test): + if not flags.test: if rhpl.getArch() == "s390" and drive[:4] == "dasd": - if (intf is None or self.dasdFmt(intf, drive)): + if self.dasdFmt(drive): DiskSet.skippedDisks.append(drive) continue else: @@ -1037,29 +1048,33 @@ class DiskSet: self.disks[drive] = disk except parted.error, msg: recreate = 0 - if zeroMbr: + if self.anaconda.id.partitions.zeroMbr: log.error("zeroMBR was set and invalid partition table " "found on %s" % (dev.path[5:])) recreate = 1 - elif not intf: + elif not self.anaconda.intf: DiskSet.skippedDisks.append(drive) continue else: if rhpl.getArch() == "s390" and drive[:4] == "dasd": - devs = isys.getDasdDevPort() - format = drive + " (" + devs[drive] + ")" + devs = isys.getDasdDevPort() + format = drive + " (" + devs[drive] + ")" else: - format = drive - rc = intf.messageWindow(_("Warning"), - _("The partition table on device %s was unreadable. " - "To create new partitions it must be initialized, " - "causing the loss of ALL DATA on this drive.\n\n" - "This operation will override any previous " - "installation choices about which drives to " - "ignore.\n\n" - "Would you like to initialize this drive, " - "erasing ALL DATA?") - % (format,), type = "yesno") + format = drive + + if self.anaconda.isKickstart and (drive in cdl) and initlbl: + rc = 1 + else: + rc = intf.messageWindow(_("Warning"), + _("The partition table on device %s was unreadable. " + "To create new partitions it must be initialized, " + "causing the loss of ALL DATA on this drive.\n\n" + "This operation will override any previous " + "installation choices about which drives to " + "ignore.\n\n" + "Would you like to initialize this drive, " + "erasing ALL DATA?") % (format,), type = "yesno") + if rc == 0: DiskSet.skippedDisks.append(drive) continue @@ -1068,7 +1083,7 @@ class DiskSet: if recreate == 1 and not flags.test: if rhpl.getArch() == "s390" and drive[:4] == "dasd": - if (intf is None or self.dasdFmt(intf, drive)): + if self.dasdFmt(drive): DiskSet.skippedDisks.append(drive) continue else: @@ -1088,13 +1103,13 @@ class DiskSet: filter_partitions(disk, validateFsType) # check that their partition table is valid for their architecture - ret = checkDiskLabel(disk, intf) + ret = checkDiskLabel(disk) if ret == 1: DiskSet.skippedDisks.append(drive) continue elif ret == -1: if rhpl.getArch() == "s390" and drive[:4] == "dasd": - if (intf is None or self.dasdFmt(intf, drive)): + if self.dasdFmt(drive): DiskSet.skippedDisks.append(drive) continue else: @@ -1166,10 +1181,10 @@ class DiskSet: part = disk.next_partition(part) return rc - def checkNoDisks(self, intf): + def checkNoDisks(self): """Check that there are valid disk devices.""" if len(self.disks.keys()) == 0: - intf.messageWindow(_("No Drives Found"), + self.anaconda.intf.messageWindow(_("No Drives Found"), _("An error has occurred - no valid devices were " "found on which to create new file systems. " "Please check your hardware for the cause " |