summaryrefslogtreecommitdiffstats
path: root/ipalib/frontend.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2010-10-27 12:07:53 -0400
committerRob Crittenden <rcritten@redhat.com>2010-10-28 17:47:20 -0400
commit3c795f3251bd0354d56e2b50042ee04cee7cd21f (patch)
tree2b52ddf89754c8375290343cdc51563c147346fd /ipalib/frontend.py
parent7486ead6c910d13ae4d7cbae6fae738ce2bf47eb (diff)
downloadfreeipa-3c795f3251bd0354d56e2b50042ee04cee7cd21f.tar.gz
freeipa-3c795f3251bd0354d56e2b50042ee04cee7cd21f.tar.xz
freeipa-3c795f3251bd0354d56e2b50042ee04cee7cd21f.zip
Return reason for failure when updating group membership fails.
We used to return a list of dns that failed to be added. We now return a list of tuples instead. The tuple looks like (dn, reason) where reason is the exception that was returned. Also made the label we use for failures to be singular instead of plural since we now print them out individually instead of as comma-separated. ticket 270
Diffstat (limited to 'ipalib/frontend.py')
-rw-r--r--ipalib/frontend.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 577c2fcc9..73680ef2f 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -46,6 +46,22 @@ def is_rule(obj):
return callable(obj) and getattr(obj, RULE_FLAG, False) is True
+def entry_count(entry):
+ """
+ Return the number of entries in an entry. This is primarly for the
+ failed output parameter so we don't print empty values.
+
+ We also use this to determine if a non-zero return value is needed.
+ """
+ num_entries = 0
+ for f in entry:
+ if type(entry[f]) is dict:
+ num_entries = num_entries + entry_count(entry[f])
+ else:
+ num_entries = num_entries + len(entry[f])
+
+ return num_entries
+
class HasParam(Plugin):
"""
@@ -844,22 +860,6 @@ class Command(HasParam):
continue
yield param
- def number_failed(self, failed):
- """
- Return the number of entries in the failed output parameter.
-
- This is used to determine whether the failed members should be
- displayed and what the return value should be.
- """
- num_failed = 0
- for f in failed:
- if type(failed[f]) is dict:
- num_failed = num_failed + self.number_failed(failed[f])
- else:
- num_failed = num_failed + len(failed[f])
-
- return num_failed
-
def output_for_cli(self, textui, output, *args, **options):
"""
Generic output method. Prints values the output argument according
@@ -899,7 +899,7 @@ class Command(HasParam):
if o.lower() == 'count' and result == 0:
rv = 1
elif o.lower() == 'failed':
- if self.number_failed(result) == 0:
+ if entry_count(result) == 0:
# Don't display an empty failed list
continue
else: