Revision c04bc777 lib/bdev.py

b/lib/bdev.py
959 959
      sectors = int(result.stdout)
960 960
    except (TypeError, ValueError):
961 961
      _ThrowError("Invalid output from blockdev: '%s'", result.stdout)
962
    bytes = sectors * 512
963
    if bytes < 128 * 1024 * 1024: # less than 128MiB
964
      _ThrowError("Meta device too small (%.2fMib)", (bytes / 1024 / 1024))
962
    num_bytes = sectors * 512
963
    if num_bytes < 128 * 1024 * 1024: # less than 128MiB
964
      _ThrowError("Meta device too small (%.2fMib)", (num_bytes / 1024 / 1024))
965 965
    # the maximum *valid* size of the meta device when living on top
966 966
    # of LVM is hard to compute: it depends on the number of stripes
967 967
    # and the PE size; e.g. a 2-stripe, 64MB PE will result in a 128MB
968 968
    # (normal size), but an eight-stripe 128MB PE will result in a 1GB
969 969
    # size meta device; as such, we restrict it to 1GB (a little bit
970 970
    # too generous, but making assumptions about PE size is hard)
971
    if bytes > 1024 * 1024 * 1024:
972
      _ThrowError("Meta device too big (%.2fMiB)", (bytes / 1024 / 1024))
971
    if num_bytes > 1024 * 1024 * 1024:
972
      _ThrowError("Meta device too big (%.2fMiB)", (num_bytes / 1024 / 1024))
973 973

  
974 974
  def Rename(self, new_id):
975 975
    """Rename a device.

Also available in: Unified diff