This reverts commit 6915bc28fe053e92aa16cf2d974d205f1140219c based on thread on
ganeti-devel.
Conflicts:
lib/cmdlib.py (due to the error code classification, trivial)
---
lib/cmdlib.py | 3 ++-
lib/hypervisor/hv_base.py | 2 +-
lib/utils.py | 10 ++++++++++
scripts/gnt-node | 3 ++-
test/docs_unittest.py | 4 ++--
5 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index 768d67b..2f47557 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -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
diff --git a/lib/hypervisor/hv_base.py b/lib/hypervisor/hv_base.py
index 252e665..eacc0ec 100644
--- a/lib/hypervisor/hv_base.py
+++ b/lib/hypervisor/hv_base.py
@@ -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)
diff --git a/lib/utils.py b/lib/utils.py
index f10bcec..b2ffff9 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -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.
diff --git a/scripts/gnt-node b/scripts/gnt-node
index e442110..0ca2794 100755
--- a/scripts/gnt-node
+++ b/scripts/gnt-node
@@ -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()
diff --git a/test/docs_unittest.py b/test/docs_unittest.py
index a3cb2b7..95d81a8 100755
--- a/test/docs_unittest.py
+++ b/test/docs_unittest.py
@@ -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__":
--
1.6.5.3