diff options
author | Jan Cholasta <jcholast@redhat.com> | 2016-09-02 16:42:57 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-09-06 12:54:38 +0200 |
commit | dce95a14595a37ce83bcf3e28f41feab715d0c81 (patch) | |
tree | 978d789e3822390df36e7503b1dd7c2be645d712 /ipaclient/plugins | |
parent | afea9616318fbbffc2c296b7c41890db8595e3cc (diff) | |
download | freeipa-dce95a14595a37ce83bcf3e28f41feab715d0c81.tar.gz freeipa-dce95a14595a37ce83bcf3e28f41feab715d0c81.tar.xz freeipa-dce95a14595a37ce83bcf3e28f41feab715d0c81.zip |
dns: prompt for missing record parts in CLI
Fix the code which determines if a record part is required and thus should
be prompted not to wrongfully consider all record parts to be optional.
https://fedorahosted.org/freeipa/ticket/6203
Reviewed-By: Martin Basti <mbasti@redhat.com>
Diffstat (limited to 'ipaclient/plugins')
-rw-r--r-- | ipaclient/plugins/dns.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/ipaclient/plugins/dns.py b/ipaclient/plugins/dns.py index db9c17f8b..5e29b8c66 100644 --- a/ipaclient/plugins/dns.py +++ b/ipaclient/plugins/dns.py @@ -25,10 +25,10 @@ import copy from ipaclient.frontend import MethodOverride from ipalib import errors -from ipalib.dns import (get_part_rrtype, - get_record_rrtype, +from ipalib.dns import (get_record_rrtype, has_cli_options, iterate_rrparams_by_parts, + part_name_format, record_name_format) from ipalib.parameters import Bool from ipalib.plugable import Registry @@ -46,9 +46,9 @@ _rev_top_record_types = ('PTR', ) _zone_top_record_types = ('NS', 'MX', 'LOC', ) -def __get_part_param(cmd, part, output_kw, default=None): - name = part.name - label = unicode(part.label) +def __get_part_param(rrtype, cmd, part, output_kw, default=None): + name = part_name_format % (rrtype.lower(), part.name) + label = unicode(cmd.params[name].label) optional = not part.required output_kw[name] = cmd.prompt_param(part, @@ -64,29 +64,31 @@ def prompt_parts(rrtype, cmd, mod_dnsvalue=None): name, mod_dnsvalue)['result'] user_options = {} - parts = [p for p in cmd.params() if get_part_rrtype(p.name) == rrtype] - if not parts: + try: + rrobj = cmd.api.Object['dns{}record'.format(rrtype.lower())] + except KeyError: return user_options - for part_id, part in enumerate(parts): + for part_id, part in enumerate(rrobj.params()): if mod_parts: default = mod_parts[part_id] else: default = None - __get_part_param(cmd, part, user_options, default) + __get_part_param(rrtype, cmd, part, user_options, default) return user_options def prompt_missing_parts(rrtype, cmd, kw, prompt_optional=False): user_options = {} - parts = [p for p in cmd.params() if get_part_rrtype(p.name) == rrtype] - if not parts: + try: + rrobj = cmd.api.Object['dns{}record'.format(rrtype.lower())] + except KeyError: return user_options - for part in parts: - name = part.name + for part in rrobj.params(): + name = part_name_format % (rrtype.lower(), part.name) if name in kw: continue @@ -96,7 +98,7 @@ def prompt_missing_parts(rrtype, cmd, kw, prompt_optional=False): continue default = part.get_default(**kw) - __get_part_param(cmd, part, user_options, default) + __get_part_param(rrtype, cmd, part, user_options, default) return user_options |