From 196ec587786f0bcc073a9a9358e6f5f7099573b6 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Thu, 27 May 2010 11:26:16 +0100
Subject: [PATCH] FormatUidPool: provide optional roman conversion

The convert= option of compat.tryToRoman is used to do optional
conversion without duplicating formatting code.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/uidpool.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/uidpool.py b/lib/uidpool.py
index aba5febe6..9be7381cc 100644
--- a/lib/uidpool.py
+++ b/lib/uidpool.py
@@ -36,6 +36,7 @@ import random
 
 from ganeti import errors
 from ganeti import constants
+from ganeti import compat
 from ganeti import utils
 
 
@@ -114,16 +115,17 @@ def RemoveFromUidPool(uid_pool, remove_uids):
     uid_pool.remove(uid_range)
 
 
-def _FormatUidRange(lower, higher):
+def _FormatUidRange(lower, higher, roman=False):
   """Convert a user-id range definition into a string.
 
   """
   if lower == higher:
-    return str(lower)
-  return "%s-%s" % (lower, higher)
+    return str(compat.TryToRoman(lower, convert=roman))
+  return "%s-%s" % (compat.TryToRoman(lower, convert=roman),
+                    compat.TryToRoman(higher, convert=roman))
 
 
-def FormatUidPool(uid_pool, separator=None):
+def FormatUidPool(uid_pool, separator=None, roman=False):
   """Convert the internal representation of the user-id pool into a string.
 
   The output format is also accepted by ParseUidPool()
@@ -136,7 +138,7 @@ def FormatUidPool(uid_pool, separator=None):
   """
   if separator is None:
     separator = ", "
-  return separator.join([_FormatUidRange(lower, higher)
+  return separator.join([_FormatUidRange(lower, higher, roman=roman)
                          for lower, higher in uid_pool])
 
 
-- 
GitLab