Commit ab3e6da8 authored by Iustin Pop's avatar Iustin Pop
Browse files

Revert "Get rid of utils.CommaJoin"

This reverts commit 6915bc28

 based on thread on
ganeti-devel.

Conflicts:

	lib/cmdlib.py (due to the error code classification, trivial)
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 8d0a4f99
......@@ -2015,7 +2015,8 @@ class LUSetClusterParams(LogicalUnit):
invalid_hvs = set(self.hv_list) - constants.HYPER_TYPES
if invalid_hvs:
raise errors.OpPrereqError("Enabled hypervisors contains invalid"
" entries: %s" % " ,".join(invalid_hvs),
" entries: %s" %
utils.CommaJoin(invalid_hvs),
errors.ECODE_INVAL)
else:
self.hv_list = cluster.enabled_hypervisors
......
......@@ -82,7 +82,7 @@ def ParamInSet(required, my_set):
"""
fn = lambda x: x in my_set
err = ("The value must be one of: %s" % " ,".join(my_set))
err = ("The value must be one of: %s" % utils.CommaJoin(my_set))
return (required, fn, err, None, None)
......
......@@ -1884,6 +1884,16 @@ def SafeEncode(text):
return resu
def CommaJoin(names):
"""Nicely join a set of identifiers.
@param names: set, list or tuple
@return: a string with the formatted results
"""
return ", ".join(["'%s'" % val for val in names])
def BytesToMebibyte(value):
"""Converts bytes to mebibytes.
......
......@@ -98,7 +98,8 @@ _STORAGE_TYPE_OPT = \
choices=_USER_STORAGE_TYPE.keys(),
default=None,
metavar="STORAGE_TYPE",
help=("Storage type (%s)" % " ,".join(_USER_STORAGE_TYPE.keys())))
help=("Storage type (%s)" %
utils.CommaJoin(_USER_STORAGE_TYPE.keys())))
_REPAIRABLE_STORAGE_TYPES = \
[st for st, so in constants.VALID_STORAGE_OPERATIONS.iteritems()
......
......@@ -114,7 +114,7 @@ class TestDocs(unittest.TestCase):
self.failIf(undocumented,
msg=("Missing RAPI resource documentation for %s" %
" ,".join(undocumented)))
utils.CommaJoin(undocumented)))
class TestManpages(unittest.TestCase):
......@@ -145,7 +145,7 @@ class TestManpages(unittest.TestCase):
self.failIf(missing,
msg=("Manpage for '%s' missing documentation for %s" %
(script, " ,".join(missing))))
(script, utils.CommaJoin(missing))))
if __name__ == "__main__":
......
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