summaryrefslogtreecommitdiffstats
path: root/partedUtils.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2006-12-15 15:57:24 +0000
committerDavid Cantrell <dcantrell@redhat.com>2006-12-15 15:57:24 +0000
commit7a905795ef6a73793fc95b6566953e1f908bc78d (patch)
treeb640624a18c377ba22b75218f2ac89cbdaac0c60 /partedUtils.py
parent74f1a3fff40983bd5707eefbda2923ca311bfdae (diff)
downloadanaconda-7a905795ef6a73793fc95b6566953e1f908bc78d.tar.gz
anaconda-7a905795ef6a73793fc95b6566953e1f908bc78d.tar.xz
anaconda-7a905795ef6a73793fc95b6566953e1f908bc78d.zip
* fsset.py: This file is fsset.py, not fstab.py.
* partedUtils.py (DiskSet): Handle instantiation from LabelFactory where we will be handed no anaconda object reference (#219789).
Diffstat (limited to 'partedUtils.py')
-rw-r--r--partedUtils.py100
1 files changed, 58 insertions, 42 deletions
diff --git a/partedUtils.py b/partedUtils.py
index 3668569ed..057480efb 100644
--- a/partedUtils.py
+++ b/partedUtils.py
@@ -552,7 +552,7 @@ class DiskSet:
dmList = None
mpList = None
- def __init__ (self, anaconda):
+ def __init__ (self, anaconda = None):
self.disks = {}
self.onlyPrimary = None
self.anaconda = anaconda
@@ -978,6 +978,13 @@ class DiskSet:
self.startMPath()
self.startDmRaid()
+ if self.anaconda is None:
+ intf = None
+ zeroMbr = None
+ else:
+ intf = self.anaconda.intf
+ zeroMbr = self.anaconda.id.partitions.zeroMbr
+
for drive in self.driveList():
# ignoredisk takes precedence over clearpart (#186438).
if drive in DiskSet.skippedDisks:
@@ -987,41 +994,45 @@ class DiskSet:
DiskSet.skippedDisks.append(drive)
continue
- if self.anaconda.isKickstart:
- clearDevs = self.anaconda.id.ksdata.clearpart["drives"]
- initAll = self.anaconda.id.ksdata.clearpart["initAll"]
- else:
- clearDevs = []
- initAll = False
+ ks = False
+ clearDevs = []
+ initAll = False
+ if self.anaconda is not None:
+ if self.anaconda.isKickstart:
+ ks = True
+ clearDevs = self.anaconda.id.ksdata.clearpart["drives"]
+ initAll = self.anaconda.id.ksdata.clearpart["initAll"]
# 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 self.anaconda.intf is None:
+ if intf is None:
DiskSet.skippedDisks.append(drive)
continue
- if self.anaconda.isKickstart and (drive in clearDevs) and initAll:
- 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 "
- "installation choices about which drives to "
- "ignore.\n\n"
- "Would you like to initialize this drive, "
- "erasing ALL DATA?")
+ # if anaconda is None here, we are called from labelFactory
+ if self.anaconda is not None:
+ if ks and (drive in clearDevs) and initAll:
+ rc = 1
+ else:
+ rc = 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 "
+ "installation choices about which drives to "
+ "ignore.\n\n"
+ "Would you like to initialize this drive, "
+ "erasing ALL DATA?")
% (drive, devs[drive]), type = "yesno")
- if rc == 0:
- DiskSet.skippedDisks.append(drive)
- continue
- elif rc != 0:
- if (self.dasdFmt(drive)):
+ if rc == 0:
DiskSet.skippedDisks.append(drive)
continue
+ elif rc != 0:
+ if (self.dasdFmt(drive)):
+ DiskSet.skippedDisks.append(drive)
+ continue
try:
dev = parted.PedDevice.get (deviceFile)
@@ -1049,11 +1060,11 @@ class DiskSet:
self.disks[drive] = disk
except parted.error, msg:
recreate = 0
- if self.anaconda.id.partitions.zeroMbr:
+ if zeroMbr:
log.error("zeroMBR was set and invalid partition table "
"found on %s" % (dev.path[5:]))
recreate = 1
- elif not self.anaconda.intf:
+ elif intf is None:
DiskSet.skippedDisks.append(drive)
continue
else:
@@ -1063,24 +1074,29 @@ class DiskSet:
else:
format = drive
- if self.anaconda.isKickstart and (drive in clearDevs) and initAll:
- rc = 1
+ # if anaconda is None here, we are called from labelFactory
+ if self.anaconda is not None:
+ if ks and (drive in clearDevs) and initAll:
+ 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
+ elif rc != 0:
+ recreate = 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
- elif rc != 0:
- recreate = 1
if recreate == 1 and not flags.test:
if rhpl.getArch() == "s390" and drive[:4] == "dasd":