Commit cb2037a2 authored by Iustin Pop's avatar Iustin Pop
Browse files

Return more data in rpc.call_volume_list

Currently, the volume_list call returns only the volume size. However,
it is useful to also have two other things: the 'inactive' state of the
volume (which might trigger a ‘vgchange -a y’ on the volume group) and
the online state (which shows if the volume is in use or not).

Since this modifies an RPC call, we also bump the protocol version,
although the single user of the call didn't care about the dictionary
values, only about the keys.

Reviewed-by: imsnah
parent ce628bb4
......@@ -210,19 +210,31 @@ def GetVolumeList(vg_name):
"""Compute list of logical volumes and their size.
Returns:
dictionary of all partions (key) with their size:
test1: 20.06MiB
dictionary of all partions (key) with their size (in MiB), inactive
and online status:
{'test1': ('20.06', True, True)}
"""
result = utils.RunCmd(["lvs", "--noheadings", "--units=m",
"-oname,size", vg_name])
lvs = {}
sep = '|'
result = utils.RunCmd(["lvs", "--noheadings", "--units=m", "--nosuffix",
"--separator=%s" % sep,
"-olv_name,lv_size,lv_attr", vg_name])
if result.failed:
logger.Error("Failed to list logical volumes, lvs output: %s" %
result.output)
return {}
lvlist = [line.split() for line in result.stdout.splitlines()]
return dict(lvlist)
return lvs
for line in result.stdout.splitlines():
line = line.strip().rstrip(sep)
name, size, attr = line.split(sep)
if len(attr) != 6:
attr = '------'
inactive = attr[4] == '-'
online = attr[5] == 'o'
lvs[name] = (size, inactive, online)
return lvs
def ListVolumeGroups():
......
......@@ -25,7 +25,7 @@ from ganeti import _autoconf
# various versions
CONFIG_VERSION = 3
PROTOCOL_VERSION = 7
PROTOCOL_VERSION = 8
RELEASE_VERSION = _autoconf.PACKAGE_VERSION
OS_API_VERSION = 5
EXPORT_VERSION = 0
......
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