On Fri, Mar 06, 2009 at 05:23:21PM +0100, Hans de Goede wrote: > > > Joel Granados Moreno wrote: > > <huge snip> > > > diff --git a/storage/__init__.py b/storage/__init__.py > > index 7bac367..6c241c2 100644 > > --- a/storage/__init__.py > > +++ b/storage/__init__.py > > @@ -238,7 +238,11 @@ class Storage(object): > > does not necessarily reflect the actual on-disk state of the > > system's disks. > > """ > > - disks = self.devicetree.getDevicesByType("disk") > > + disks = [] > > + devices = self.devicetree.devices > > + for d in devices: > > + if isinstance(devices[d], DiskDevice): > > + disks.append(devices[d]) > > disks.sort(key=lambda d: d.name) > > return disks > > > > @@ -250,7 +254,11 @@ class Storage(object): > > does not necessarily reflect the actual on-disk state of the > > system's disks. > > """ > > - partitions = self.devicetree.getDevicesByType("partition") > > + partitions = [] > > + devices = self.devicetree.devices > > + for d in devices: > > + if isinstance(devices[d], PartitionDevice): > > + partitions.append(devices[d]) > > partitions.sort(key=lambda d: d.name) > > return partitions > > > > We could use the new devicetree.getDevicesByInstance you add in this same patch here instead. yep. I could :) > > <more snip> > >> @@ -1059,12 +1127,27 @@ class PartitionDevice(StorageDevice): >> return disk >> def _setDisk(self, disk): >> + """Change the parent. >> + >> + Setting up a disk is not trivial. It has the potential to change >> + the underlying object. If necessary we must also change this object. >> + """ >> log_method_call(self, self.name, old=self.disk, new=disk) >> if self.disk: >> self.disk.removeChild() >> self.parents = [disk] >> disk.addChild() >> + if isinstance(disk, DMRaidArrayDevice): >> + # modify the partition so it can look like the DMRaidPartitionDevice. >> + >> + self._type = "dmraid partition" >> + self._packages = ["dmraid"] >> + self.devDir = "/dev/mapper" >> + self.updateSysfsPath = DMDevice.updateSysfsPath >> + self.getDMNode = DMDevice.getDMNode >> + >> + >> disk = property(lambda p: p._getDisk(), lambda p,d: >> p._setDisk(d)) >> > > > What if we go the other way around so from being a partition on a DMRaidArrayDevice > to one on a regular DiskDevice ? > >> @@ -2069,41 +2152,130 @@ class MDRaidArrayDevice(StorageDevice): >> self.exists = False >> -class DMRaidArrayDevice(DMDevice): >> +class DMRaidArrayDevice(DiskDevice): >> """ A dmraid (device-mapper RAID) device """ >> _type = "dm-raid array" >> _packages = ["dmraid"] >> + devDir = "/dev/mapper" >> - def __init__(self, name, format=None, size=None, >> - exists=None, parents=None, sysfsPath=''): >> + def __init__(self, name, raidSet=None, level=None, format=None, size=None, >> + major=None, minor=None, parents=None, sysfsPath=''): >> """ Create a DMRaidArrayDevice instance. >> Arguments: >> - name -- the device name (generally a device node's >> basename) >> + name -- the dmraid name also the device node's basename >> Keyword Arguments: >> + raidSet -- the RaidSet object from block >> + level -- the type of dmraid >> parents -- a list of the member devices >> sysfsPath -- sysfs device path >> size -- the device's size >> format -- a DeviceFormat instance >> - exists -- indicates whether this is an existing device >> """ >> if isinstance(parents, list): >> for parent in parents: >> if not parent.format or parent.format.type != "dmraidmember": >> raise ValueError("parent devices must contain dmraidmember format") >> - DMDevice.__init__(self, name, format=format, size=size, >> - parents=parents, sysfsPath=sysfsPath, >> - exists=exists) >> + DiskDevice.__init__(self, name, format=format, size=size, >> + major=major, minor=minor, >> + parents=parents, sysfsPath=sysfsPath) >> - def probe(self): >> - """ Probe for any missing information about this device. >> + self.formatClass = get_device_format_class("dmraidmember") >> + if not self.formatClass: >> + raise DeviceError("cannot find class for 'dmraidmember'") >> - size >> + >> + self._raidSet = raidSet >> + self._level = level >> + >> + @property >> + def raidSet(self): >> + return self._raidSet >> + >> + @raidSet.setter >> + def raidSet(self, val): >> + # If we change self._raidSet, parents list will be invalid. >> + # Don't allow the change. >> + pass >> + > > I think you should just omit the setter then, this will cause python to throw an error > rather then to ignore the write silently. I think dlehman made a similar remark to an > earlier version of this patch. > > <huge snip> > > Regards, > > Hans Yes you are correct. but the comment got lost in all the confustion :) will adjust > > _______________________________________________ > Anaconda-devel-list mailing list > Anaconda-devel-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/anaconda-devel-list -- Joel Andres Granados Brno, Czech Republic, Red Hat. _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list