Pls ignore this one :) Its some trash I had in the tree. On Wed, Feb 18, 2009 at 07:14:12PM +0100, Joel Granados Moreno wrote: > From: Joel Granados <joel.granados@xxxxxxxxx> > > The patch > -- > Joel Andres Granados > Brno, Czech Republic > > commit fdb810e492cad453aaa576e87a98404b6a09a09c > Author: Joel Granados Moreno <jgranado@xxxxxxxxxx> > Date: Tue Feb 17 23:57:25 2009 +0100 > > A more general approach to the comparison of tables. > --- > device.py | 69 ++++++++++++++++++++++++++++++++++++++++-------------------- > 1 files changed, 46 insertions(+), 23 deletions(-) > > diff --git a/device.py b/device.py > index cbf196c..fa33f35 100644 > --- a/device.py > +++ b/device.py > @@ -658,46 +658,69 @@ class RaidSet: > pass > bdev = property(get_bdev, None, None, "block.BlockDev") > > - def get_map(self): > - if not self._RaidSet__map is None: > - return self._RaidSet__map > + # Helper function for get_map > + # The tables will be considered the same if, everything else being the > + # same, they contain the same sets of devices. > > - # we get "/dev/hda" from one and "3:0" from the other, so we have to > - # fix up the device name > + def equal(self, table1, table2): > def map_dev(path): > if path[0] != '/': > - return path.strip() > + return path > > try: > statinfo = _os.stat(path) > if not _stat.S_ISBLK(statinfo.st_mode): > - return path.strip() > + return path > > return "%d:%d" % (statinfo.st_rdev/256, statinfo.st_rdev%256, ) > except: > - return path.strip() > + return path > > - parts = str(self.rs.dmTable).split(' ') > + table1 = table1.strip().split(' ') > + table2 = table2.strip().split(' ') > + table1sets = [] > + table2sets = [] > > - table = [] > - for part in parts: > - table += [map_dev(part),] > - tablestr = _string.join(table, ' ') > - # sometimes dmraid and dm have the disks of a mirror swapped > - if self.rs.dmTable.type == "mirror": > - tmp = table[8] > - table[8] = table[10] > - table[10] = tmp > - alt_tablestr = _string.join(table, ' ') > - else: > - alt_tablestr = None > + # We do this to avoid the index out of range exception > + if len(table1) != len(table2): > + return False > + > + # We parse the first section before the list of devs. > + for i in range(len(table1)): > + d1 = map_dev(table1[i]) > + d2 = map_dev(table2[i]) > + > + # when at least one changes its a device. > + if (table1[i] != d1) or (table2[i] != d2): > + # The d{1,2} will always have the major:minor string > + table1sets.append(d1) > + table2sets.append(d2) > + continue > + > + # these are not devices > + if (table1[i] == d1) and (table2[i] == d2): > + if d1 == d2: > + continue > + > + if d1 != d2: > + return False > + > + # check the devs. > + for elem in table1sets: > + if elem not in table2sets: > + return False > + > + return True > + > + def get_map(self): > + if not self._RaidSet__map is None: > + return self._RaidSet__map > > import dm as _dm > > for map in _dm.maps(): > # XXX wtf? why's it have a space at the end sometimes? > - if str(map.table).strip() == tablestr or alt_tablestr and \ > - str(map.table).strip() == alt_tablestr: > + if self.equal(str(map.table), str(self.rs.dmTable)): > self._RaidSet__map = map > self.active = True > del _dm > -- > 1.6.0.6 > > _______________________________________________ > 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