Re: PATCH: pyblock: Adjust python code for C-code table handling changes

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

 



Looks fine
regards
On Tue, Feb 24, 2009 at 10:43:53PM +0100, Hans de Goede wrote:
> This completes the code re-factoring to make map's with tables with more
> then one row (target in dm speak) work.
> ---
>  __init__.py |    2 +-
>  device.py   |   16 ++++++++--------
>  maps.py     |    7 ++++---
>  3 files changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/__init__.py b/__init__.py
> index 03a4802..9911940 100644
> --- a/__init__.py
> +++ b/__init__.py
> @@ -261,7 +261,7 @@ def getDmTarget(uuid = None, major = None, minor = 
> None, name = None):
>      """
>      map = getMap(uuid=uuid, major=major, minor=minor, name=name)
>      try:
> -        target = map.table.type
> +        target = map.table[0].type
>      except AttributeError:
>          target = None
>      return target
> diff --git a/device.py b/device.py
> index aae1204..8a6d0d9 100644
> --- a/device.py
> +++ b/device.py
> @@ -62,9 +62,10 @@ def map_dev(path):
>          return path
>
>  # 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.
> -def compare_tables(table1,  table2):
> +# The tables will be considered the same if for every row, with everythingelse
> +# being the same, they contain the same sets of devices.
> +def compare_tables(t1, t2):
> +    for table1, table2 in zip(t1, t2):
>          table1 = str(table1).strip().split(' ')
>          table2 = str(table2).strip().split(' ')
>          table1sets = []
> @@ -109,7 +110,7 @@ def compare_tables(table1,  table2):
>                  if table1sets[i] != table2sets[i]:
>                      return False
>
> -        return True
> +    return True
>
>  class BlockDev:
>      def get_major(self):
> @@ -453,8 +454,8 @@ class MultiPath:
>          table = apply(_dm.table, tableParts, {})
>          del _dm
>
> -        self._MultiPath__table = table
> -        return table
> +        self._MultiPath__table = [ table ]
> +        return self._MultiPath__table
>      table = property(get_table, None, None, "block.dm.table")
>
>      def get_map(self):
> @@ -466,8 +467,7 @@ class MultiPath:
>          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() == str(table).strip():
> +            if compare_tables(map.table, table):
>                  if self.name != map.name:
>                      self.name = nameCache.rename(self.name, map.name)
>
> diff --git a/maps.py b/maps.py
> index e6fff76..4090422 100644
> --- a/maps.py
> +++ b/maps.py
> @@ -136,7 +136,7 @@ class DeviceMap:
>              raise RuntimeError, "type cannot be created"
>          f = getattr(self, ff)
>          import dm as _dm
> -        ret = _dm.table(self.start, self.size, self.type, f())
> +        ret = [ _dm.table(self.start, self.size, self.type, f()) ]
>          del _dm
>          return ret
>      table = property(get_table, None, None, "the table for this DeviceMap")
> @@ -172,9 +172,9 @@ class DeviceMap:
>      def create(self, name=None):
>
>          import dm as _dm
> +        import device as _device
>          for map in _dm.maps():
> -            # XXX wtf?  why's it have a space at the end sometimes?
> -            if str(map.table).strip() == str(self.table).strip():
> +            if _device.compare_tables(map.table, self.table):
>                  self.map = map
>                  self.name = map.name
>                  break
> @@ -185,6 +185,7 @@ class DeviceMap:
>                  raise ValueError, "DeviceMap name is not set"
>              self.map = _dm.map(name = self.name, table = self.table)
>          del _dm
> +        del _device
>
>  class LinearDeviceMap(DeviceMap):
>      """map for dm-linear"""
> -- 
> 1.6.1.3
>
> _______________________________________________
> 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

[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