Revision 196ec587 lib/uidpool.py
b/lib/uidpool.py | ||
---|---|---|
36 | 36 |
|
37 | 37 |
from ganeti import errors |
38 | 38 |
from ganeti import constants |
39 |
from ganeti import compat |
|
39 | 40 |
from ganeti import utils |
40 | 41 |
|
41 | 42 |
|
... | ... | |
114 | 115 |
uid_pool.remove(uid_range) |
115 | 116 |
|
116 | 117 |
|
117 |
def _FormatUidRange(lower, higher): |
|
118 |
def _FormatUidRange(lower, higher, roman=False):
|
|
118 | 119 |
"""Convert a user-id range definition into a string. |
119 | 120 |
|
120 | 121 |
""" |
121 | 122 |
if lower == higher: |
122 |
return str(lower) |
|
123 |
return "%s-%s" % (lower, higher) |
|
123 |
return str(compat.TryToRoman(lower, convert=roman)) |
|
124 |
return "%s-%s" % (compat.TryToRoman(lower, convert=roman), |
|
125 |
compat.TryToRoman(higher, convert=roman)) |
|
124 | 126 |
|
125 | 127 |
|
126 |
def FormatUidPool(uid_pool, separator=None): |
|
128 |
def FormatUidPool(uid_pool, separator=None, roman=False):
|
|
127 | 129 |
"""Convert the internal representation of the user-id pool into a string. |
128 | 130 |
|
129 | 131 |
The output format is also accepted by ParseUidPool() |
... | ... | |
136 | 138 |
""" |
137 | 139 |
if separator is None: |
138 | 140 |
separator = ", " |
139 |
return separator.join([_FormatUidRange(lower, higher) |
|
141 |
return separator.join([_FormatUidRange(lower, higher, roman=roman)
|
|
140 | 142 |
for lower, higher in uid_pool]) |
141 | 143 |
|
142 | 144 |
|
Also available in: Unified diff