From 852bbc950a6e8b7da0b9896c53cfcdb95048622b Mon Sep 17 00:00:00 2001 From: Balazs Lecz <leczb@google.com> Date: Fri, 26 Mar 2010 15:25:35 +0000 Subject: [PATCH] Add printing of uid_pool to gnt-cluster info Signed-off-by: Balazs Lecz <leczb@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/uidpool.py | 23 +++++++++++++++++++++++ scripts/gnt-cluster | 1 + 2 files changed, 24 insertions(+) diff --git a/lib/uidpool.py b/lib/uidpool.py index 15ab31487..c8c03a510 100644 --- a/lib/uidpool.py +++ b/lib/uidpool.py @@ -31,6 +31,7 @@ from the pool. from ganeti import errors from ganeti import constants +from ganeti import utils def ParseUidPool(value, separator=None): @@ -108,6 +109,28 @@ def RemoveFromUidPool(uid_pool, remove_uids): uid_pool.remove(uid_range) +def _FormatUidRange(lower, higher): + """Convert a user-id range definition into a string. + + """ + if lower == higher: + return str(lower) + return "%s-%s" % (lower, higher) + + +def FormatUidPool(uid_pool): + """Convert the internal representation of the user-id pool into a string. + + The output format is also accepted by ParseUidPool() + + @param uid_pool: a list of integer pairs representing UID ranges + @return: a string with the formatted results + + """ + return utils.CommaJoin([_FormatUidRange(lower, higher) + for lower, higher in uid_pool]) + + def CheckUidPool(uid_pool): """Sanity check user-id pool range definition values. diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index 8a5098eef..8254325db 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -276,6 +276,7 @@ def ShowClusterConfig(opts, args): ToStdout(" - file storage path: %s", result["file_storage_dir"]) ToStdout(" - maintenance of node health: %s", result["maintain_node_health"]) + ToStdout(" - uid pool: %s", uidpool.FormatUidPool(result["uid_pool"])) ToStdout("Default instance parameters:") _PrintGroupedParams(result["beparams"]) -- GitLab