Commit baa7f1d6 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

New BlockDev methods to get spindles



Two new methods are created to get the number of spindles, one alone, and
one together with size. For devices that don't support spindles, None is
returned.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent b5d48e87
......@@ -330,6 +330,28 @@ class BlockDev(object):
ThrowError("Failed to parse blockdev output: %s", str(err))
return sz
def GetActualSpindles(self):
"""Return the actual number of spindles used.
This is not supported by all devices; if not supported, C{None} is returned.
@note: the device needs to be active when this is called
"""
assert self.attached, "BlockDevice not attached in GetActualSpindles()"
return None
def GetActualDimensions(self):
"""Return the actual disk size and number of spindles used.
@rtype: tuple
@return: (size, spindles); spindles is C{None} when they are not supported
@note: the device needs to be active when this is called
"""
return (self.GetActualSize(), self.GetActualSpindles())
def __repr__(self):
return ("<%s: unique_id: %s, children: %s, %s:%s, %s>" %
(self.__class__, self.unique_id, self._children,
......
......@@ -746,6 +746,13 @@ class LogicalVolume(base.BlockDev):
return
base.ThrowError("Can't grow LV %s: %s", self.dev_path, result.output)
def GetActualSpindles(self):
"""Return the number of spindles used.
"""
assert self.attached, "BlockDevice not attached in GetActualSpindles()"
return len(self.pv_names)
class FileStorage(base.BlockDev):
"""File device.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment