from ganeti.cli import *
from ganeti import compat
+from ganeti import utils
#: default list of fields for L{ListGroups}
"name": "Group", "uuid": "UUID",
"node_cnt": "Nodes", "node_list": "NodeList",
"pinst_cnt": "Instances", "pinst_list": "InstanceList",
+ "ctime": "CTime", "mtime": "MTime", "serial_no": "SerialNo",
}
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):
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 = "?"
"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))),
}
_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)
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"
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.