Re: [PATCH 5/6] Remove devices property from FSSet, use the one from Storage.

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 2 Sep 2009, David Lehman wrote:

On Wed, 2009-09-02 at 13:33 -1000, David Cantrell wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 2 Sep 2009, David Lehman wrote:

On Tue, 2009-09-01 at 15:25 -1000, David Cantrell wrote:
The devices property in Storage and FSSet were the same.  Remove the one
from FSSet and have that class reference the one from Storage.

Here we are are taking the device list from one point in time, before
we've parsed the fstab. More importantly, we're taking the list of
devices from before we've done any partitioning, &c. Since we now have a
list of devices instead of a property in FSSet we will not pick up
changes to the list of devices, which I think is going to be
problematic.

Correct me if I'm wrong, but any access of the 'devices' property on Storage
is going to resort devicetree.devices, right?  Isn't devicetree the same
between Storage and FSSet (it looks like FSSet just has a reference to the one
in Storage).  In FSSet when 'devices' is accessed, devicetree.devices will be
resorted and a new list returned.

I don't think it will happen that way. It seems to me that self.devices
is evaluated when the FSSet is instantiated and from that point forward
it is just a list. It's not like passing a reference to a
method/function. Here's a little python session that helped me to arrive
at this conclusion:

[dave@localhost anaconda]$ python
Python 2.6 (r26:66714, Jun  8 2009, 16:07:29)
[GCC 4.4.0 20090506 (Red Hat 4.4.0-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
class X(object):
...     def __init__(self, x):
...             self._x = x
...     @property
...     def x(self):
...             return self._x
...
x = X(3)
foo = x.x
foo
3
x._x = 1
foo
3


Dave

Fair enough, dumping this patch.  Bah, my Python feels rusty.




Dave

---
 booty/ppc.py        |    4 ++--
 storage/__init__.py |   17 +++++++----------
 upgrade.py          |    2 +-
 yuminstall.py       |    2 +-
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/booty/ppc.py b/booty/ppc.py
index 9e43090..42aae57 100644
--- a/booty/ppc.py
+++ b/booty/ppc.py
@@ -14,11 +14,11 @@ class ppcBootloaderInfo(bootloaderInfo):
         machine = iutil.getPPCMachine()

         if machine == 'pSeries':
-            for dev in self.storage.fsset.devices:
+            for dev in self.storage.devices:
                 if dev.format.type == "prepboot":
                     retval.append(dev.path)
         elif machine == 'PMac':
-            for dev in self.storage.fsset.devices:
+            for dev in self.storage.devices:
                 if dev.format.type == "hfs" and dev.format.bootable:
                     retval.append(dev.path)

diff --git a/storage/__init__.py b/storage/__init__.py
index 494bef0..10fe07a 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -224,7 +224,8 @@ class Storage(object):
                                      passphrase=self.encryptionPassphrase,
                                      luksDict=self.__luksDevs,
                                      iscsi=self.iscsi)
-        self.fsset = FSSet(self.devicetree, self.anaconda.rootPath)
+        self.fsset = FSSet(self.devicetree, self.anaconda.rootPath,
+                           self.devices)

     def doIt(self):
         self.devicetree.processActions()
@@ -291,7 +292,8 @@ class Storage(object):
                                      luksDict=self.__luksDevs,
                                      iscsi=self.iscsi)
         self.devicetree.populate()
-        self.fsset = FSSet(self.devicetree, self.anaconda.rootPath)
+        self.fsset = FSSet(self.devicetree, self.anaconda.rootPath,
+                           self.devices)
         self.anaconda.id.rootParts = None
         self.anaconda.id.upgradeRoot = None
         w.pop()
@@ -299,9 +301,7 @@ class Storage(object):
     @property
     def devices(self):
         """ A list of all the devices in the device tree. """
-        devices = self.devicetree.devices
-        devices.sort(key=lambda d: d.path)
-        return devices
+        return sorted(self.devicetree.devices, key=lambda d: d.path)

     @property
     def disks(self):
@@ -1306,9 +1306,10 @@ def get_containing_device(path, devicetree):

 class FSSet(object):
     """ A class to represent a set of filesystems. """
-    def __init__(self, devicetree, rootpath):
+    def __init__(self, devicetree, rootpath, devices):
         self.devicetree = devicetree
         self.rootpath = rootpath
+        self.devices = devices
         self.cryptTab = None
         self.blkidTab = None
         self.origFStab = None
@@ -1364,10 +1365,6 @@ class FSSet(object):
         return self._devshm

     @property
-    def devices(self):
-        return sorted(self.devicetree.devices, key=lambda d: d.path)
-
-    @property
     def mountpoints(self):
         filesystems = {}
         for device in self.devices:
diff --git a/upgrade.py b/upgrade.py
index c751533..1ae9a58 100644
--- a/upgrade.py
+++ b/upgrade.py
@@ -146,7 +146,7 @@ def upgradeSwapSuggestion(anaconda):

     fsList = []

-    for device in anaconda.id.storage.fsset.devices:
+    for device in anaconda.id.storage.devices:
         if not device.format:
             continue
         if device.format.mountable and device.format.linuxNative:
diff --git a/yuminstall.py b/yuminstall.py
index b247b52..4e13939 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -1295,7 +1295,7 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
             selectKernel("kernel")

     def selectFSPackages(self, storage):
-        for device in storage.fsset.devices:
+        for device in storage.devices:
             # this takes care of device and filesystem packages
             map(self.selectPackage, device.packages)


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


- --
David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

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

iEYEARECAAYFAkqfAM0ACgkQ5hsjjIy1Vkn5TwCfbA6OnrhQJAT8nKGxL5kc0mG0
Xn0An1G7Bi6/zAtHQG/1q01r2SOChPeC
=zv+u
-----END PGP SIGNATURE-----

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

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


- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

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

iEYEARECAAYFAkqfBtoACgkQ5hsjjIy1VknCfQCfdzyKBzxv4yHdsuD5oHZGUJ3V
qCwAn2sH/AfzhNBc8avSHo/rZoWiYaCo
=G79X
-----END PGP SIGNATURE-----

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

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux