diff options
author | Jan Cholasta <jcholast@redhat.com> | 2016-04-28 10:15:01 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2016-06-03 09:00:34 +0200 |
commit | 4c7be74526bd89ed1b481f3a1ac4bb467ee0ea2c (patch) | |
tree | 3db268df3cfa41bd8a3c4655967e6931428b1ba9 /ipaclient/plugins/topology.py | |
parent | 6cfb9d73d9701767d8b76d7ff5bbc080a6be9386 (diff) | |
download | freeipa-4c7be74526bd89ed1b481f3a1ac4bb467ee0ea2c.tar.gz freeipa-4c7be74526bd89ed1b481f3a1ac4bb467ee0ea2c.tar.xz freeipa-4c7be74526bd89ed1b481f3a1ac4bb467ee0ea2c.zip |
ipalib: split off client-side plugin code into ipaclient
Provide client-side overrides for command plugins which implement any of
the client-side `interactive_prompt_callback`, `forward` or
`output_for_cli` methods and move the methods from the original plugins to
the overrides.
https://fedorahosted.org/freeipa/ticket/4739
Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'ipaclient/plugins/topology.py')
-rw-r--r-- | ipaclient/plugins/topology.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/ipaclient/plugins/topology.py b/ipaclient/plugins/topology.py new file mode 100644 index 000000000..522dcfa9a --- /dev/null +++ b/ipaclient/plugins/topology.py @@ -0,0 +1,54 @@ +# +# Copyright (C) 2015 FreeIPA Contributors see COPYING for license +# + +import six + +from ipaclient.frontend import MethodOverride +from ipalib.plugable import Registry +from ipalib import _ + +if six.PY3: + unicode = str + +register = Registry() + + +@register(override=True) +class topologysuffix_verify(MethodOverride): + def output_for_cli(self, textui, output, *args, **options): + + in_order = output['result']['in_order'] + connect_errors = output['result']['connect_errors'] + max_agmts_errors = output['result']['max_agmts_errors'] + + if in_order: + header = _('Replication topology of suffix "%(suffix)s" ' + 'is in order.') + else: + header = _('Replication topology of suffix "%(suffix)s" contains ' + 'errors.') + textui.print_h1(header % {'suffix': args[0]}) + + if connect_errors: + textui.print_dashed(unicode(_('Topology is disconnected'))) + for err in connect_errors: + msg = _("Server %(srv)s can't contact servers: %(replicas)s") + msg = msg % {'srv': err[0], 'replicas': ', '.join(err[2])} + textui.print_indented(msg) + + if max_agmts_errors: + textui.print_dashed(unicode(_('Recommended maximum number of ' + 'agreements per replica exceeded'))) + textui.print_attribute( + unicode(_("Maximum number of agreements per replica")), + [output['result']['max_agmts']] + ) + for err in max_agmts_errors: + msg = _('Server "%(srv)s" has %(n)d agreements with servers:') + msg = msg % {'srv': err[0], 'n': len(err[1])} + textui.print_indented(msg) + for replica in err[1]: + textui.print_indented(replica, 2) + + return 0 |