summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-01-07 11:17:55 -0500
committerRob Crittenden <rcritten@redhat.com>2011-01-10 10:32:10 -0500
commit6f58f38748085e6a104de6f9e992469d3b685d5a (patch)
treeebc3a92f95feae19afc8ababcf306782e62988f8 /ipalib
parent0a79836082b897ebf734d9073583769cb276937c (diff)
downloadfreeipa-6f58f38748085e6a104de6f9e992469d3b685d5a.tar.gz
freeipa-6f58f38748085e6a104de6f9e992469d3b685d5a.tar.xz
freeipa-6f58f38748085e6a104de6f9e992469d3b685d5a.zip
Display the entries that failed when deleting with --continue.
We collected the failures but didn't report it back. This changes the API of most delete commands so rather than returning a boolean it returns a dict with the only current key as failed. This also adds a new parameter flag, suppress_empty. This will try to not print values that are empty if included. This makes the output of the delete commands a bit prettier. ticket 687
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/cli.py9
-rw-r--r--ipalib/frontend.py9
-rw-r--r--ipalib/output.py8
-rw-r--r--ipalib/plugins/aci.py2
-rw-r--r--ipalib/plugins/baseldap.py8
-rw-r--r--ipalib/plugins/delegation.py2
-rw-r--r--ipalib/plugins/selfservice.py2
7 files changed, 27 insertions, 13 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 436607f27..892db8081 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -326,16 +326,16 @@ class textui(backend.Backend):
for attr in sorted(entry):
print_attr(attr)
- def print_entries(self, entries, order=None, labels=None, print_all=True, format='%s: %s', indent=1):
+ def print_entries(self, entries, order=None, labels=None, flags=None, print_all=True, format='%s: %s', indent=1):
assert isinstance(entries, (list, tuple))
first = True
for entry in entries:
if not first:
print ''
first = False
- self.print_entry(entry, order, labels, print_all, format, indent)
+ self.print_entry(entry, order, labels, flags, print_all, format, indent)
- def print_entry(self, entry, order=None, labels=None, print_all=True, format='%s: %s', indent=1):
+ def print_entry(self, entry, order=None, labels=None, flags=None, print_all=True, format='%s: %s', indent=1):
"""
"""
if isinstance(entry, (list, tuple)):
@@ -351,7 +351,10 @@ class textui(backend.Backend):
if key not in entry:
continue
label = labels.get(key, key)
+ flag = flags.get(key, [])
value = entry[key]
+ if 'suppress_empty' in flag and value in [u'', '', [], None]:
+ continue
if isinstance(value, dict):
if frontend.entry_count(value) == 0:
continue
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 18ea7287d..7177bd185 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -895,6 +895,7 @@ class Command(HasParam):
labels = None
else:
labels = dict((p.name, unicode(p.label)) for p in self.output_params())
+ flags = dict((p.name, p.flags) for p in self.output_params())
for o in self.output:
outp = self.output[o]
@@ -912,13 +913,13 @@ class Command(HasParam):
# Return an error to the shell
rv = 1
if isinstance(outp, ListOfEntries):
- textui.print_entries(result, order, labels, print_all)
+ textui.print_entries(result, order, labels, flags, print_all)
elif isinstance(result, (tuple, list)):
- textui.print_entries(result, order, labels, print_all)
+ textui.print_entries(result, order, labels, flags, print_all)
elif isinstance(outp, Entry):
- textui.print_entry(result, order, labels, print_all)
+ textui.print_entry(result, order, labels, flags, print_all)
elif isinstance(result, dict):
- textui.print_entry(result, order, labels, print_all)
+ textui.print_entry(result, order, labels, flags, print_all)
elif isinstance(result, unicode):
if o == 'summary':
textui.print_summary(result)
diff --git a/ipalib/output.py b/ipalib/output.py
index 60abe798c..617136274 100644
--- a/ipalib/output.py
+++ b/ipalib/output.py
@@ -136,8 +136,14 @@ standard_list_of_entries = (
standard_delete = (
summary,
+ Output('result', dict, 'list of deletions that failed'),
+ value,
+)
+
+standard_boolean = (
+ summary,
Output('result', bool, 'True means the operation was successful'),
value,
)
-standard_value = standard_delete
+standard_value = standard_boolean
diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index 0193be5db..939fe535a 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -473,7 +473,7 @@ class aci_del(crud.Delete):
Delete ACI.
"""
INTERNAL = True
- has_output = output.standard_delete
+ has_output = output.standard_boolean
msg_summary = _('Deleted ACI "%(value)s"')
def execute(self, aciname, **kw):
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index ecc3fd0b9..fbe4fcece 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -136,6 +136,10 @@ global_output_params = (
Str('memberuser',
label=_('Failed users/groups'),
),
+ Str('failed',
+ label=_('Failed to remove'),
+ flags=['suppress_empty'],
+ ),
)
@@ -937,8 +941,8 @@ class LDAPDelete(LDAPMultiQuery):
deleted.append(pkey)
if self.obj.primary_key and pkeyiter[0] is not None:
- return dict(result=result, value=u','.join(deleted))
- return dict(result=result, value=u'')
+ return dict(result=dict(failed=u','.join(failed)), value=u','.join(deleted))
+ return dict(result=dict(failed=u''), value=u'')
def pre_callback(self, ldap, dn, *keys, **options):
return dn
diff --git a/ipalib/plugins/delegation.py b/ipalib/plugins/delegation.py
index 6ed224421..19d4c6da6 100644
--- a/ipalib/plugins/delegation.py
+++ b/ipalib/plugins/delegation.py
@@ -174,7 +174,7 @@ class delegation_del(crud.Delete):
Delete a delegation.
"""
- has_output = output.standard_delete
+ has_output = output.standard_boolean
msg_summary = _('Deleted delegation "%(value)s"')
def execute(self, aciname, **kw):
diff --git a/ipalib/plugins/selfservice.py b/ipalib/plugins/selfservice.py
index b5f754ee8..adf6acb79 100644
--- a/ipalib/plugins/selfservice.py
+++ b/ipalib/plugins/selfservice.py
@@ -134,7 +134,7 @@ class selfservice_del(crud.Delete):
Delete a selfservice.
"""
- has_output = output.standard_delete
+ has_output = output.standard_boolean
msg_summary = _('Deleted selfservice "%(value)s"')
def execute(self, aciname, **kw):