summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/f_hostgroup.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipalib/plugins/f_hostgroup.py')
-rw-r--r--ipalib/plugins/f_hostgroup.py64
1 files changed, 27 insertions, 37 deletions
diff --git a/ipalib/plugins/f_hostgroup.py b/ipalib/plugins/f_hostgroup.py
index 6cbf4d51..bde257f9 100644
--- a/ipalib/plugins/f_hostgroup.py
+++ b/ipalib/plugins/f_hostgroup.py
@@ -93,12 +93,11 @@ class hostgroup_add(crud.Add):
return ldap.create(**kw)
- def output_for_cli(self, ret):
+ def output_for_cli(self, textui, result, *args, **options):
"""
Output result of this command to command line interface.
"""
- if ret:
- print "Group added"
+ textui.print_plain("Group added")
api.register(hostgroup_add)
@@ -120,12 +119,11 @@ class hostgroup_del(crud.Del):
return ldap.delete(dn)
- def output_for_cli(self, ret):
+ def output_for_cli(self, textui, result, *args, **options):
"""
Output result of this command to command line interface.
"""
- if ret:
- print "Group deleted"
+ textui.print_plain("Group deleted")
api.register(hostgroup_del)
@@ -150,12 +148,11 @@ class hostgroup_mod(crud.Mod):
dn = ldap.find_entry_dn("cn", cn, hostgroup_filter)
return ldap.update(dn, **kw)
- def output_for_cli(self, ret):
+ def output_for_cli(self, textui, result, *args, **options):
"""
Output result of this command to command line interface.
"""
- if ret:
- print "Group updated"
+ texui.print_plain("Group updated")
api.register(hostgroup_mod)
@@ -178,22 +175,19 @@ class hostgroup_find(crud.Find):
kw['objectclass'] = hostgroup_filter
return ldap.search(**kw)
- def output_for_cli(self, groups):
- if not groups:
- return
-
- counter = groups[0]
- groups = groups[1:]
+ def output_for_cli(self, textui, result, *args, **options):
+ counter = result[0]
+ groups = result[1:]
if counter == 0:
- print "No entries found"
+ textui.print_plain("No entries found")
return
- elif counter == -1:
- print "These results are truncated."
- print "Please refine your search and try again."
for g in groups:
- for a in g.keys():
- print "%s: %s" % (a, g[a])
+ textui.print_entry(g)
+
+ if counter == -1:
+ textui.print_plain("These results are truncated.")
+ textui.print_plain("Please refine your search and try again.")
api.register(hostgroup_find)
@@ -219,12 +213,8 @@ class hostgroup_show(crud.Get):
# FIXME: should kw contain the list of attributes to display?
return ldap.retrieve(dn)
- def output_for_cli(self, group):
- if not group:
- return
-
- for a in group.keys():
- print "%s: %s" % (a, group[a])
+ def output_for_cli(self, textui, result, *args, **options):
+ textui.print_entry(result)
api.register(hostgroup_show)
@@ -283,16 +273,16 @@ class hostgroup_add_member(frontend.Command):
return add_failed
- def output_for_cli(self, add_failed):
+ def output_for_cli(self, textui, result, *args, **options):
"""
Output result of this command to command line interface.
"""
- if add_failed:
- print "These entries failed to add to the group:"
- for a in add_failed:
+ if result:
+ textui.print_plain("These entries failed to add to the group:")
+ for a in result:
print "\t'%s'" % a
else:
- print "Group membership updated."
+ textui.print_entry("Group membership updated.")
api.register(hostgroup_add_member)
@@ -351,15 +341,15 @@ class hostgroup_remove_member(frontend.Command):
return remove_failed
- def output_for_cli(self, remove_failed):
+ def output_for_cli(self, textui, result, *args, **options):
"""
Output result of this command to command line interface.
"""
- if remove_failed:
- print "These entries failed to be removed from the group:"
- for a in remove_failed:
+ if result:
+ textui.print_plain("These entries failed to be removed from the group:")
+ for a in result:
print "\t'%s'" % a
else:
- print "Group membership updated."
+ textui.print_plain("Group membership updated.")
api.register(hostgroup_remove_member)