Commit 61481c52 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

Free disk space reporting follows exclusive storage rules



When exclusive_storage is set, nodes report only the space that could be
used to create new disk according to the rules set in the
design-partitioned doc (i.e., non-empty disks are ignored and the space
reserved for rounding/overhead is not reported).
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 319322a7
......@@ -698,6 +698,22 @@ class LogicalVolume(BlockDev):
return data
@classmethod
def _GetExclusiveStorageVgFree(cls, vg_name):
"""Return the free disk space in the given VG, in exclusive storage mode.
@type vg_name: string
@param vg_name: VG name
@rtype: float
@return: free space in MiB
"""
pvs_info = cls.GetPVInfo([vg_name])
if not pvs_info:
return 0.0
pv_size = cls._GetStdPvSize(pvs_info)
num_pvs = len(cls._GetEmptyPvNames(pvs_info))
return pv_size * num_pvs
@classmethod
def GetVGInfo(cls, vg_names, excl_stor, filter_readonly=True):
"""Get the free space info for specific VGs.
......@@ -726,6 +742,11 @@ class LogicalVolume(BlockDev):
# (possibly) skip over vgs which are not in the right volume group(s)
if vg_names and vg_name not in vg_names:
continue
# Exclusive storage needs a different concept of free space
if excl_stor:
es_free = cls._GetExclusiveStorageVgFree(vg_name)
assert es_free <= vg_free
vg_free = es_free
data.append((float(vg_free), float(vg_size), vg_name))
return data
......
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