[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [master] expose FSSet properties and methods through Storage



Ho,

On 09/02/2009 10:15 PM, David Cantrell wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 2 Sep 2009, Hans de Goede wrote:

Hi,

Given the large amount of changes this patch set makes, I've taken the
liberty of applying the patches to my own tree and running pylint,
which resulted in the following:

************* Module storage
E0602:1454:FSSet.parseFSTab: Undefined variable 'self'
E0602:1536:FSSet.fsFreeSpace: Undefined variable 'self'
E0602:1762:FSSet.createSwapFile: Undefined variable 'self'
E0602:1785:FSSet.mkDevRoot: Undefined variable 'self'
E0602:1826:FSSet.write: Undefined variable 'self'

The problem is constructions like this one:

def parseFSTab(self, chroot=self.rootpath):

It is not allowed to reference / use self here to specify
a default value. I've created a simple reproducer and ran it
through python to be sure this was not a false postive
and pylint is correct, this construction is not allowed.

Thanks for checking that. I thought I could cheat and avoid changing other
lines by setting a default that way. Oh well. Here's the updated patch:


Looks ok now,

Regards,

Hans


- ----------

Add the following methods and properties to class Storage which map
through to FSSet methods, modify existing calls to use the method on
class Storage:

turnOnSwap()
mountFilesystems()
umountFilesystems()
parseFSTab()
mkDevRoot()
createSwapFile()
fsFreeSpace()
mtab
mountpoints
migratableDevices
rootDevice

Callers no longer need to pass the Anaconda object to the FSSet methods
directly. The method on Storage takes care of that.

The mtab() method on FSSet is exposed as a property on Storage. The
same is true for fsFreeSpace().
- ---
backend.py | 4 +-
bootloader.py | 2 +-
booty/alpha.py | 4 +-
booty/bootloaderInfo.py | 10 +++---
booty/ppc.py | 10 +++---
booty/s390.py | 4 +-
booty/sparc.py | 6 ++--
booty/x86.py | 10 +++---
installmethod.py | 2 +-
iw/osbootwidget.py | 2 +-
iw/upgrade_migratefs_gui.py | 3 +-
iw/upgrade_swap_gui.py | 5 +--
kickstart.py | 6 ++--
livecd.py | 24 +++++++--------
network.py | 2 +-
packages.py | 13 ++++----
platform.py | 2 +-
rescue.py | 8 ++--
storage/__init__.py | 69 +++++++++++++++++++++++++++++++++++++-----
storage/iscsi.py | 2 +-
textw/upgrade_text.py | 4 +-
upgrade.py | 8 ++--
yuminstall.py | 6 ++--
23 files changed, 126 insertions(+), 80 deletions(-)

diff --git a/backend.py b/backend.py
index 41698af..04235a8 100644
- --- a/backend.py
+++ b/backend.py
@@ -86,7 +86,7 @@ class AnacondaBackend:
# the initrd might need iscsi-initiator-utils, and chances are
# it was not installed yet the first time mkinitrd was run, as
# mkinitrd does not require it.
- - root = anaconda.id.storage.fsset.rootDevice
+ root = anaconda.id.storage.rootDevice
disks = anaconda.id.storage.devicetree.getDevicesByType("iscsi")
for disk in disks:
if root.dependsOn(disk):
@@ -159,7 +159,7 @@ class AnacondaBackend:
if not anaconda.mediaDevice or not os.path.exists(installimg):
return

- - free = anaconda.id.storage.fsset.fsFreeSpace(anaconda.rootPath)
+ free = anaconda.id.storage.fsFreeSpace
self._loopbackFile = "%s%s/rhinstall-install.img" % (anaconda.rootPath,
free[0][0])

diff --git a/bootloader.py b/bootloader.py
index ef6af21..0847f7e 100644
- --- a/bootloader.py
+++ b/bootloader.py
@@ -145,7 +145,7 @@ def writeBootloader(anaconda):
kernelList = []
otherList = []
# getDefault needs to return a device, but that's too invasive for now.
- - rootDev = anaconda.id.storage.fsset.rootDevice
+ rootDev = anaconda.id.storage.rootDevice

if not anaconda.id.bootloader.images.getDefault():
defaultDev = None
diff --git a/booty/alpha.py b/booty/alpha.py
index afdb476..c4a3360 100644
- --- a/booty/alpha.py
+++ b/booty/alpha.py
@@ -18,9 +18,9 @@ class alphaBootloaderInfo(bootloaderInfo):

def writeAboot(self, instRoot, bl, kernelList,
chainList, defaultDev, justConfig):
- - rootDevice = self.storage.fsset.rootDevice
+ rootDevice = self.storage.rootDevice
try:
- - bootDevice = self.storage.fsset.mountpoints["/boot"]
+ bootDevice = self.storage.mountpoints["/boot"]
except KeyError:
bootDevice = rootDevice

diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index e7cd5e3..b2725ab 100644
- --- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -88,7 +88,7 @@ class KernelArguments:

def get(self):
args = self.args
- - root = self.id.storage.fsset.rootDevice
+ root = self.id.storage.rootDevice
for d in self.id.storage.devices:
if root.dependsOn(d):
dracutSetupString = d.dracutSetupString()
@@ -210,7 +210,7 @@ class BootImages:
self.images[dev.name] = (None, None, type)

if not self.images.has_key(self.default):
- - self.default = storage.fsset.rootDevice.name
+ self.default = storage.rootDevice.name
(label, longlabel, type) = self.images[self.default]
if not label:
self.images[self.default] = ("linux", productName, type)
@@ -249,7 +249,7 @@ class BootImages:
# questionable for same reason as above, but on mac this time
retval.append((part, type))

- - rootDevice = storage.fsset.rootDevice
+ rootDevice = storage.rootDevice

if not rootDevice or not rootDevice.format:
raise ValueError, ("Trying to pick boot devices but do not have a "
@@ -343,7 +343,7 @@ class bootloaderInfo:
lilo.addEntry("prompt", replace = 0)
lilo.addEntry("timeout", self.timeout or "20", replace = 0)

- - rootDev = self.storage.fsset.rootDevice
+ rootDev = self.storage.rootDevice

if rootDev.name == defaultDev.name:
lilo.addEntry("default", kernelList[0][0])
@@ -590,7 +590,7 @@ class efiBootloaderInfo(bootloaderInfo):

def addNewEfiEntry(self, instRoot):
try:
- - bootdev = self.storage.fsset.mountpoints["/boot/efi"].name
+ bootdev = self.storage.mountpoints["/boot/efi"].name
except:
bootdev = "sda1"

diff --git a/booty/ppc.py b/booty/ppc.py
index aa4d8dc..9e43090 100644
- --- a/booty/ppc.py
+++ b/booty/ppc.py
@@ -26,10 +26,10 @@ class ppcBootloaderInfo(bootloaderInfo):
# Try to get a boot device; bplan OF understands ext3
if machine == 'Pegasos' or machine == 'Efika':
try:
- - device = self.storage.fsset.mountpoints["/boot"]
+ device = self.storage.mountpoints["/boot"]
except KeyError:
# Try / if we don't have this we're not going to work
- - device = self.storage.fsset.rootDevice
+ device = self.storage.rootDevice

retval.append(device.path)
else:
@@ -45,14 +45,14 @@ class ppcBootloaderInfo(bootloaderInfo):
yabootTarget = string.join(self.getBootDevs(bl))

try:
- - bootDev = self.storage.fsset.mountpoints["/boot"]
+ bootDev = self.storage.mountpoints["/boot"]

cf = "/boot/etc/yaboot.conf"
cfPath = ""
if not os.path.isdir(instRoot + "/boot/etc"):
os.mkdir(instRoot + "/boot/etc")
except KeyError:
- - bootDev = self.storage.fsset.rootDevice
+ bootDev = self.storage.rootDevice

cfPath = "/boot"
cf = "/etc/yaboot.conf"
@@ -101,7 +101,7 @@ class ppcBootloaderInfo(bootloaderInfo):

f.write("\n")

- - rootDev = self.storage.fsset.rootDevice
+ rootDev = self.storage.rootDevice

for (label, longlabel, version) in kernelList:
kernelTag = "-" + version
diff --git a/booty/s390.py b/booty/s390.py
index a60811d..39a57d4 100644
- --- a/booty/s390.py
+++ b/booty/s390.py
@@ -25,7 +25,7 @@ class s390BootloaderInfo(bootloaderInfo):
if not os.access(instRoot + sl.getPath(), os.R_OK):
lilo.delImage(label)

- - rootDev = self.storage.fsset.rootDevice
+ rootDev = self.storage.rootDevice

if rootDev.name == defaultDev.name:
lilo.addEntry("default", kernelList[0][0])
@@ -117,7 +117,7 @@ class s390BootloaderInfo(bootloaderInfo):

def writeZipl(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfigFile):
- - rootDev = self.storage.fsset.rootDevice
+ rootDev = self.storage.rootDevice

cf = '/etc/zipl.conf'
self.perms = 0600
diff --git a/booty/sparc.py b/booty/sparc.py
index 45d58c4..22c4ab8 100644
- --- a/booty/sparc.py
+++ b/booty/sparc.py
@@ -8,7 +8,7 @@ class sparcBootloaderInfo(bootloaderInfo):
chainList, defaultDev, justConfigFile):

try:
- - bootDev = self.storage.fsset.mountpoints["/boot"]
+ bootDev = self.storage.mountpoints["/boot"]

mf = '/silo.message'
cf = "/boot/silo.conf"
@@ -17,7 +17,7 @@ class sparcBootloaderInfo(bootloaderInfo):
if not os.path.isdir(instRoot + "/boot"):
os.mkdir(instRoot + "/boot")
except KeyError:
- - bootDev = self.storage.fsset.rootDevice
+ bootDev = self.storage.rootDevice

cf = "/etc/silo.conf"
mfdir = '/etc'
@@ -46,7 +46,7 @@ class sparcBootloaderInfo(bootloaderInfo):
f.write("default=%s\n" % (kernelList[0][0],))
f.write("\n")

- - rootDev = self.storage.fsset.rootDevice
+ rootDev = self.storage.rootDevice

for (label, longlabel, version) in kernelList:
kernelTag = "-" + version
diff --git a/booty/x86.py b/booty/x86.py
index 5e02f3d..d6a7cc2 100644
- --- a/booty/x86.py
+++ b/booty/x86.py
@@ -134,7 +134,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
def writeGrub(self, instRoot, bl, kernelList, chainList,
defaultDev, justConfigFile):

- - rootDev = self.storage.fsset.rootDevice
+ rootDev = self.storage.rootDevice

# XXX old config file should be read here for upgrade

@@ -166,7 +166,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
"after making changes to this file\n")

try:
- - bootDev = self.storage.fsset.mountpoints["/boot"]
+ bootDev = self.storage.mountpoints["/boot"]
grubPath = "/grub"
cfPath = "/"
f.write("# NOTICE: You have a /boot partition. This means "
@@ -174,7 +174,7 @@ class x86BootloaderInfo(efiBootloaderInfo):
f.write("# all kernel and initrd paths are relative "
"to /boot/, eg.\n")
except KeyError:
- - bootDev = self.storage.fsset.rootDevice
+ bootDev = self.storage.rootDevice
grubPath = "/boot/grub"
cfPath = "/boot/"
f.write("# NOTICE: You do not have a /boot partition. "
@@ -482,11 +482,11 @@ class x86BootloaderInfo(efiBootloaderInfo):
# so we have to do shenanigans to get updated grub installed...
# steal some more code above
try:
- - bootDev = self.storage.fsset.mountpoints["/boot"].name
+ bootDev = self.storage.mountpoints["/boot"].name
grubPath = "/grub"
cfPath = "/"
except KeyError:
- - bootDev = self.storage.fsset.rootDevice.name
+ bootDev = self.storage.rootDevice.name
grubPath = "/boot/grub"
cfPath = "/boot/"

diff --git a/installmethod.py b/installmethod.py
index c412c94..0550bd4 100644
- --- a/installmethod.py
+++ b/installmethod.py
@@ -47,7 +47,7 @@ def doMethodComplete(anaconda):
dev.eject()

mtab = "/dev/root / ext3 ro 0 0\n"
- - rootDevice = anaconda.id.storage.fsset.rootDevice
+ rootDevice = anaconda.id.storage.rootDevice
if rootDevice:
mtab = "/dev/root / %s ro 0 0\n" % rootDevice.format.type

diff --git a/iw/osbootwidget.py b/iw/osbootwidget.py
index c70118f..2f066da 100644
- --- a/iw/osbootwidget.py
+++ b/iw/osbootwidget.py
@@ -361,7 +361,7 @@ class OSBootWidget:
continue

isRoot = 0
- - rootDev = self.storage.fsset.rootDevice
+ rootDev = self.storage.rootDevice
if rootDev and rootDev.name == dev:
isRoot = 1

diff --git a/iw/upgrade_migratefs_gui.py b/iw/upgrade_migratefs_gui.py
index 428ead2..8a3ac96 100644
- --- a/iw/upgrade_migratefs_gui.py
+++ b/iw/upgrade_migratefs_gui.py
@@ -61,8 +61,7 @@ class UpgradeMigrateFSWindow (InstallWindow):

def getScreen (self, anaconda):
self.devicetree = anaconda.id.storage.devicetree
- - self.fsset = anaconda.id.storage.fsset
- - self.migent = self.fsset.migratableDevices
+ self.migent = anaconda.id.storage.migratableDevices

box = gtk.VBox (False, 5)
box.set_border_width (5)
diff --git a/iw/upgrade_swap_gui.py b/iw/upgrade_swap_gui.py
index 5197d9e..247137b 100644
- --- a/iw/upgrade_swap_gui.py
+++ b/iw/upgrade_swap_gui.py
@@ -66,7 +66,7 @@ class UpgradeSwapWindow (InstallWindow):

else:
if flags.setupFilesystems:
- - self.fsset.createSwapFile(self.instPath, dev, val)
+ self.storage.createSwapFile(dev, val)
self.dispatch.skipStep("addswap", 1)

return None
@@ -79,8 +79,7 @@ class UpgradeSwapWindow (InstallWindow):

def getScreen (self, anaconda):
self.neededSwap = 0
- - self.fsset = anaconda.id.storage.fsset
- - self.instPath = anaconda.rootPath
+ self.storage = anaconda.id.storage
self.intf = anaconda.intf
self.dispatch = anaconda.dispatch

diff --git a/kickstart.py b/kickstart.py
index 2337d2c..81182cc 100644
- --- a/kickstart.py
+++ b/kickstart.py
@@ -436,7 +436,7 @@ class LogVol(commands.logvol.F9_LogVol):
# old one.
try:
if lvd.mountpoint:
- - device = storage.fsset.mountpoints[lvd.mountpoint]
+ device = storage.mountpoints[lvd.mountpoint]
storage.destroyDevice(device)
except KeyError:
pass
@@ -684,7 +684,7 @@ class Partition(commands.partition.F11_Partition):
# old one.
try:
if pd.mountpoint:
- - device = storage.fsset.mountpoints[pd.mountpoint]
+ device = storage.mountpoints[pd.mountpoint]
storage.destroyDevice(device)
except KeyError:
pass
@@ -820,7 +820,7 @@ class Raid(commands.raid.F9_Raid):
# old one.
try:
if rd.mountpoint:
- - device = storage.fsset.mountpoints[rd.mountpoint]
+ device = storage.mountpoints[rd.mountpoint]
storage.destroyDevice(device)
except KeyError:
pass
diff --git a/livecd.py b/livecd.py
index 9d60efc..73c075c 100644
- --- a/livecd.py
+++ b/livecd.py
@@ -151,8 +151,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
def postAction(self, anaconda):
self._unmountNonFstabDirs(anaconda)
try:
- - anaconda.id.storage.fsset.umountFilesystems(anaconda.rootPath,
- - swapoff = False)
+ anaconda.id.storage.umountFilesystems(swapoff = False)
os.rmdir(anaconda.rootPath)
except Exception, e:
log.error("Unable to unmount filesystems: %s" % e) @@ -161,8 +160,7 @@
class LiveCDCopyBackend(backend.AnacondaBackend):
if anaconda.dir == DISPATCH_BACK:
self._unmountNonFstabDirs(anaconda)
return
- - anaconda.id.storage.fsset.umountFilesystems(anaconda.rootPath,
- - swapoff = False)
+ anaconda.id.storage.umountFilesystems(swapoff = False)

def doInstall(self, anaconda):
log.info("Preparing to install packages")
@@ -177,7 +175,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
osimg = self._getLiveBlockDevice() # the real image
osfd = os.open(osimg, os.O_RDONLY)

- - rootDevice = anaconda.id.storage.fsset.rootDevice
+ rootDevice = anaconda.id.storage.rootDevice
rootDevice.setup()
rootfd = os.open(rootDevice.path, os.O_WRONLY)

@@ -227,10 +225,10 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
self._resizeRootfs(anaconda, wait)

# remount filesystems
- - anaconda.id.storage.fsset.mountFilesystems(anaconda)
+ anaconda.id.storage.mountFilesystems()

# restore the label of / to what we think it is
- - rootDevice = anaconda.id.storage.fsset.rootDevice
+ rootDevice = anaconda.id.storage.rootDevice
rootDevice.setup()
# ensure we have a random UUID on the rootfs
# FIXME: this should be abstracted per filesystem type
@@ -257,8 +255,8 @@ class LiveCDCopyBackend(backend.AnacondaBackend):

# now create a tree so that we know what's mounted under where
fsdict = {"/": []}
- - for mount in sorted(anaconda.id.storage.fsset.mountpoints.keys()):
- - entry = anaconda.id.storage.fsset.mountpoints[mount]
+ for mount in sorted(anaconda.id.storage.mountpoints.keys()):
+ entry = anaconda.id.storage.mountpoints[mount]
tocopy = entry.format.mountpoint
if tocopy.startswith("/mnt") or tocopy == "swap":
continue
@@ -277,7 +275,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
continue
copied.append(tocopy)
copied.extend(map(lambda x: x.format.mountpoint, fsdict[tocopy]))
- - entry = anaconda.id.storage.fsset.mountpoints[tocopy]
+ entry = anaconda.id.storage.mountpoints[tocopy]

# FIXME: all calls to wait.refresh() are kind of a hack... we
# should do better about not doing blocking things in the
@@ -321,7 +319,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):

def _resizeRootfs(self, anaconda, win = None):
log.info("going to do resize")
- - rootDevice = anaconda.id.storage.fsset.rootDevice
+ rootDevice = anaconda.id.storage.rootDevice

# FIXME: we'd like to have progress here to give an idea of
# how long it will take. or at least, to give an indefinite
@@ -364,7 +362,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
# now write out the "real" fstab and mtab
anaconda.id.storage.write(anaconda.rootPath)
f = open(anaconda.rootPath + "/etc/mtab", "w+")
- - f.write(anaconda.id.storage.fsset.mtab())
+ f.write(anaconda.id.storage.mtab)
f.close()

# copy over the modprobe.conf
@@ -393,7 +391,7 @@ class LiveCDCopyBackend(backend.AnacondaBackend):
# FIXME: really, this should be in the general sanity checking, but
# trying to weave that in is a little tricky at present.
ossize = self._getLiveSizeMB()
- - slash = anaconda.id.storage.fsset.rootDevice
+ slash = anaconda.id.storage.rootDevice
if slash.size < ossize:
rc = anaconda.intf.messageWindow(_("Error"),
_("The root filesystem you created is "
diff --git a/network.py b/network.py
index db14e3a..104e420 100644
- --- a/network.py
+++ b/network.py
@@ -586,7 +586,7 @@ class Network:
# installation when / is on a network backed device.
if anaconda is not None:
import storage
- - rootdev = anaconda.id.storage.fsset.rootDevice
+ rootdev = anaconda.id.storage.rootDevice
# FIXME: use device.host_address to only add "NM_CONTROLLED=no"
# for interfaces actually used enroute to the device
for d in anaconda.id.storage.devices:
diff --git a/packages.py b/packages.py
index dda98c4..960a0af 100644
- --- a/packages.py
+++ b/packages.py
@@ -94,7 +94,7 @@ def turnOnFilesystems(anaconda):
if anaconda.dir == DISPATCH_BACK:
if not anaconda.id.upgrade:
log.info("unmounting filesystems")
- - anaconda.id.storage.fsset.umountFilesystems(anaconda.rootPath)
+ anaconda.id.storage.umountFilesystems()
return DISPATCH_NOOP

if flags.setupFilesystems:
@@ -109,7 +109,7 @@ def turnOnFilesystems(anaconda):

upgrade_migrate = False
if anaconda.id.upgrade:
- - for d in anaconda.id.storage.fsset.migratableDevices:
+ for d in anaconda.id.storage.migratableDevices:
if d.format.migrate:
upgrade_migrate = True

@@ -193,11 +193,10 @@ def turnOnFilesystems(anaconda):
sys.exit(1)

if not anaconda.id.upgrade:
- - anaconda.id.storage.fsset.turnOnSwap(anaconda)
- - anaconda.id.storage.fsset.mountFilesystems(anaconda,
- - raiseErrors=False,
- - readOnly=False,
- - skipRoot=anaconda.backend.skipFormatRoot)
+ anaconda.id.storage.turnOnSwap()
+ anaconda.id.storage.mountFilesystems(raiseErrors=False,
+ readOnly=False,
+ skipRoot=anaconda.backend.skipFormatRoot)
else:
if upgrade_migrate:
# we should write out a new fstab with the migrated fstype
diff --git a/platform.py b/platform.py
index 122984e..072efe5 100644
- --- a/platform.py
+++ b/platform.py
@@ -127,7 +127,7 @@ class Platform(object):
errors.append(_("Bootable partitions cannot be on an %s filesystem.") %
req.format.name)

# vfat /boot is insane.
- - if req == self.anaconda.id.storage.fsset.rootDevice and
req.format.type == "vfat":
+ if req == self.anaconda.id.storage.rootDevice and req.format.type ==
"vfat":
errors.append(_("Bootable partitions cannot be on an %s filesystem.") %
req.format.type)

if req.type == "luks/dm-crypt":
diff --git a/rescue.py b/rescue.py
index 9dafec0..b6e6c10 100644
- --- a/rescue.py
+++ b/rescue.py
@@ -117,7 +117,7 @@ class RescueInterface:
# XXX grub-install is stupid and uses df output to figure out
# things when installing grub. make /etc/mtab be at least
# moderately useful. - -def makeMtab(instPath, fsset):
+def makeMtab(instPath, storage):
try:
f = open(instPath + "/etc/mtab", "w+")
except IOError, e:
@@ -125,7 +125,7 @@ def makeMtab(instPath, fsset):
return

try:
- - f.write(fsset.mtab())
+ f.write(storage.mtab)
finally:
f.close()

@@ -366,7 +366,7 @@ def runRescue(anaconda, instClass):
# now turn on swap
if not readOnly:
try:
- - anaconda.id.storage.fsset.turnOnSwap(anaconda)
+ anaconda.id.storage.turnOnSwap()
except:
log.error("Error enabling swap")

@@ -453,7 +453,7 @@ def runRescue(anaconda, instClass):
msgStr = ""

if rootmounted and not readOnly:
- - makeMtab(anaconda.rootPath, anaconda.id.storage.fsset)
+ makeMtab(anaconda.rootPath, anaconda.id.storage)
try:
makeResolvConf(anaconda.rootPath)
except Exception, e:
diff --git a/storage/__init__.py b/storage/__init__.py
index 81dd06d..6ec5cff 100644
- --- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -805,7 +805,7 @@ class Storage(object):
mustbeonlinuxfs = ['/', '/var', '/tmp', '/usr', '/home', '/usr/share',
'/usr/lib']
mustbeonroot = ['/bin','/dev','/sbin','/etc','/lib','/root', '/mnt',
'lost+found', '/proc']

- - filesystems = self.fsset.mountpoints
+ filesystems = self.mountpoints
root = self.fsset.rootDevice
swaps = self.fsset.swapDevices
try:
@@ -988,6 +988,45 @@ class Storage(object):
self.fcoe.writeKS(f)
self.zfcp.writeKS(f)

+ def turnOnSwap(self, upgrading=None):
+ self.fsset.turnOnSwap(self.anaconda, upgrading=upgrading)
+
+ def mountFilesystems(self, raiseErrors=None, readOnly=None,
skipRoot=False):
+ self.fsset.mountFilesystems(self.anaconda, raiseErrors=raiseErrors,
+ readOnly=readOnly, skipRoot=skipRoot)
+
+ def umountFilesystems(self, ignoreErrors=True, swapoff=True):
+ self.fsset.umountFilesystems(ignoreErrors=ignoreErrors, swapoff=swapoff)
+
+ def parseFSTab(self):
+ self.fsset.parseFSTab()
+
+ def mkDevRoot(self):
+ self.fsset.mkDevRoot()
+
+ def createSwapFile(self, device, size):
+ self.fsset.createSwapFile(device, size)
+
+ @property
+ def fsFreeSpace(self):
+ return self.fsset.fsFreeSpace()
+
+ @property
+ def mtab(self):
+ return self.fsset.mtab()
+
+ @property
+ def mountpoints(self):
+ return self.fsset.mountpoints
+
+ @property
+ def migratableDevices(self):
+ return self.fsset.migratableDevices
+
+ @property
+ def rootDevice(self):
+ return self.fsset.rootDevice
+

def getReleaseString(mountpoint):
relName = None
@@ -1079,7 +1118,7 @@ def mountExistingSystem(anaconda, rootEnt,
mountpoint="/",
options=readOnly)

- - fsset.parseFSTab(chroot=rootPath)
+ fsset.parseFSTab()

# check for dirty filesystems
dirtyDevs = []
@@ -1415,7 +1454,7 @@ class FSSet(object):

return device

- - def parseFSTab(self, chroot=""):
+ def parseFSTab(self, chroot=None):
""" parse /etc/fstab

preconditions:
@@ -1429,7 +1468,7 @@ class FSSet(object):
loop mounts?
"""
if not chroot or not os.path.isdir(chroot):
- - chroot = ""
+ chroot = self.rootpath

path = "%s/etc/fstab" % chroot
if not os.access(path, os.R_OK):
@@ -1497,7 +1536,10 @@ class FSSet(object):
# just write duplicates back out post-install
self.preserveLines.append(line)

- - def fsFreeSpace(self, chroot='/'):
+ def fsFreeSpace(self, chroot=None):
+ if not chroot:
+ chroot = self.rootpath
+
space = []
for device in self.devices:
if not device.format.mountable or \
@@ -1708,7 +1750,7 @@ class FSSet(object):

self.active = True

- - def umountFilesystems(self, instPath, ignoreErrors=True, swapoff=True):
+ def umountFilesystems(self, ignoreErrors=True, swapoff=True):
devices = self.mountpoints.values() + self.swapDevices
devices.extend([self.dev, self.devshm, self.devpts, self.sysfs, self.proc])
devices.sort(key=lambda d: getattr(d.format, "mountpoint", None))
@@ -1723,8 +1765,11 @@ class FSSet(object):

self.active = False

- - def createSwapFile(self, rootPath, device, size):
+ def createSwapFile(self, device, size, rootPath=None):
""" Create and activate a swap file under rootPath. """
+ if not rootPath:
+ rootPath = self.rootpath
+
filename = "/SWAP"
count = 0
basedir = os.path.normpath("%s/%s" % (rootPath,
@@ -1746,7 +1791,10 @@ class FSSet(object):
# nasty, nasty
self.devicetree._addDevice(dev)

- - def mkDevRoot(self, instPath):
+ def mkDevRoot(self, instPath=None):
+ if not instPath:
+ instPath = self.rootpath
+
root = self.rootDevice
dev = "%s/%s" % (instPath, root.path)
if not os.path.exists("%s/dev/root" %(instPath,)) and os.path.exists(dev):
@@ -1787,7 +1835,10 @@ class FSSet(object):

return migratable

- - def write(self, instPath):
+ def write(self, instPath=None):
+ if not instPath:
+ instPath = self.rootpath
+
""" write out all config files based on the set of filesystems """
# /etc/fstab
fstab_path = os.path.normpath("%s/etc/fstab" % instPath)
diff --git a/storage/iscsi.py b/storage/iscsi.py
index 974fc89..75d3d02 100644
- --- a/storage/iscsi.py
+++ b/storage/iscsi.py
@@ -264,7 +264,7 @@ class iscsi(object):
return

if not flags.test:
- - root = anaconda.id.storage.fsset.rootDevice
+ root = anaconda.id.storage.rootDevice

# set iscsi nodes to autostart
for node in self.nodes:
diff --git a/textw/upgrade_text.py b/textw/upgrade_text.py
index 17e3236..77993bb 100644
- --- a/textw/upgrade_text.py
+++ b/textw/upgrade_text.py
@@ -31,7 +31,7 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
class UpgradeMigrateFSWindow:
def __call__ (self, screen, anaconda):

- - migent = anaconda.id.storage.fsset.migratableDevices
+ migent = anaconda.id.storage.migratableDevices

g = GridFormHelp(screen, _("Migrate File Systems"), "upmigfs", 1, 4)

@@ -190,7 +190,7 @@ class UpgradeSwapWindow:
else:
screen.popWindow()
if flags.setupFilesystems:
- - anaconda.id.storage.fsset.createSwapFile(anaconda.rootPath, dev, val)
+ anaconda.id.storage.createSwapFile(dev, val)
anaconda.dispatch.skipStep("addswap", 1)
return INSTALL_OK

diff --git a/upgrade.py b/upgrade.py
index 826419c..c751533 100644
- --- a/upgrade.py
+++ b/upgrade.py
@@ -108,7 +108,7 @@ def bindMountDevDirectory(instPath):

# returns None if no filesystem exist to migrate
def upgradeMigrateFind(anaconda):
- - migents = anaconda.id.storage.fsset.migratableDevices
+ migents = anaconda.id.storage.migratableDevices
if not migents or len(migents) < 1:
anaconda.dispatch.skipStep("upgrademigratefs")
else:
@@ -254,10 +254,10 @@ def upgradeMountFilesystems(anaconda):
type="ok")
return DISPATCH_BACK

- - anaconda.id.storage.fsset.parseFSTab(chroot=anaconda.rootPath)
+ anaconda.id.storage.parseFSTab()
if flags.setupFilesystems:
- - anaconda.id.storage.fsset.turnOnSwap(anaconda, upgrading=True)
- - anaconda.id.storage.fsset.mkDevRoot(anaconda.rootPath)
+ anaconda.id.storage.turnOnSwap(upgrading=True)
+ anaconda.id.storage.mkDevRoot()

# Move /etc/rpm/platform out of the way.
if os.path.exists(anaconda.rootPath + "/etc/rpm/platform"):
diff --git a/yuminstall.py b/yuminstall.py
index 20a3085..b247b52 100644
- --- a/yuminstall.py
+++ b/yuminstall.py
@@ -819,7 +819,7 @@ class AnacondaYum(YumSorter):
if len(mkeys) > 1:
stage2img = "%s/images/install.img" % self.tree
if self.anaconda.backend.mountInstallImage(self.anaconda, stage2img):
- -
self.anaconda.id.storage.fsset.umountFilesystems(self.anaconda.rootPath)
+ self.anaconda.id.storage.umountFilesystems()
return DISPATCH_BACK

for i in mkeys:
@@ -1350,7 +1350,7 @@
reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon

(self.dlpkgs, self.totalSize, self.totalFiles) =
self.ayum.getDownloadPkgs()

if not anaconda.id.getUpgrade():
- - largePart = anaconda.id.storage.fsset.mountpoints.get("/usr",
anaconda.id.storage.fsset.rootDevice)
+ largePart = anaconda.id.storage.mountpoints.get("/usr",
anaconda.id.storage.rootDevice)

if largePart and largePart.size < self.totalSize / 1024:
rc = anaconda.intf.messageWindow(_("Error"),
@@ -1488,7 +1488,7 @@
reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon


# make a /etc/mtab so mkinitrd can handle certain hw (usb) correctly
f = open(anaconda.rootPath + "/etc/mtab", "w+")
- - f.write(anaconda.id.storage.fsset.mtab())
+ f.write(anaconda.id.storage.mtab)
f.close()

def checkSupportedUpgrade(self, anaconda):
- -- 1.6.2.5

- -- David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkqe0l8ACgkQ5hsjjIy1VknylwCeIGzySSY9wb3gRHoO7WNUgaTi
5UUAnAsPum/SDUwDp1eQ40+5QuWUC+kb
=pHyd
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list redhat com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]