Commit 4edc512c authored by Adeodato Simo's avatar Adeodato Simo

Expose new node group attributes in CLI and RAPI

Signed-off-by: default avatarAdeodato Simo <dato@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent e11a1b77
......@@ -26,6 +26,7 @@
from ganeti.cli import *
from ganeti import compat
from ganeti import utils
#: default list of fields for L{ListGroups}
......@@ -37,6 +38,7 @@ _LIST_HEADERS = {
"name": "Group", "uuid": "UUID",
"node_cnt": "Nodes", "node_list": "NodeList",
"pinst_cnt": "Instances", "pinst_list": "InstanceList",
"ctime": "CTime", "mtime": "MTime", "serial_no": "SerialNo",
}
......@@ -59,8 +61,9 @@ def ListGroups(opts, args):
else:
headers = _LIST_HEADERS
int_type_fields = frozenset(["node_cnt", "pinst_cnt"])
int_type_fields = frozenset(["node_cnt", "pinst_cnt", "serial_no"])
list_type_fields = frozenset(["node_list", "pinst_list"])
date_type_fields = frozenset(["mtime", "ctime"])
for row in output:
for idx, field in enumerate(desired_fields):
......@@ -70,6 +73,8 @@ def ListGroups(opts, args):
val = ",".join(val)
elif opts.roman_integers and field in int_type_fields:
val = compat.TryToRoman(val)
elif field in date_type_fields:
val = utils.FormatTime(val)
elif val is None:
val = "?"
......@@ -88,7 +93,10 @@ commands = {
"list": (
ListGroups, ARGS_MANY_GROUPS,
[NOHDR_OPT, SEP_OPT, FIELDS_OPT, SYNC_OPT, ROMAN_OPT],
"[<group_name>...]", "Lists the node groups in the cluster."),
"[<group_name>...]",
"Lists the node groups in the cluster. The available fields are (see"
" the man page for details): %s. The default list is (in order): %s." %
(utils.CommaJoin(_LIST_HEADERS), utils.CommaJoin(_LIST_DEF_FIELDS))),
}
......
......@@ -10311,7 +10311,7 @@ class LUQueryGroups(NoHooksLU):
_FIELDS_DYNAMIC = utils.FieldSet()
_SIMPLE_FIELDS = ["name", "uuid"]
_SIMPLE_FIELDS = ["name", "uuid", "ctime", "mtime", "serial_no"]
_FIELDS_STATIC = utils.FieldSet(
"node_cnt", "node_list", "pinst_cnt", "pinst_list", *_SIMPLE_FIELDS)
......
......@@ -75,7 +75,8 @@ N_FIELDS = ["name", "offline", "master_candidate", "drained",
G_FIELDS = ["name", "uuid",
"node_cnt", "node_list",
]
"ctime", "mtime", "serial_no",
] # "tags" is missing to be able to use _COMMON_FIELDS here.
_NR_DRAINED = "drained"
_NR_MASTER_CANDIATE = "master-candidate"
......
......@@ -60,5 +60,21 @@ pinst_cnt
pinst_list
the list of primary instances in the group
ctime
the creation time of the group; note that this field contains spaces
and as such it's harder to parse
if this attribute is not present (e.g. when upgrading from older
versions), then "N/A" will be shown instead
mtime
the last modification time of the group; note that this field
contains spaces and as such it's harder to parse
serial_no
the so called 'serial number' of the group; this is a numeric field
that is incremented each time the node is modified, and it can be
used to detect modifications
If no group names are given, then all groups are included. Otherwise,
only the named groups will be listed.
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