From 4e9a2e0983a92829f497bb3ba6b3ab7b6db2967d Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Tue, 28 Feb 2012 08:48:08 +0100 Subject: Improve dnsrecord-add interactive mode When an invalid record type is entered during dnsrecord-add interactive mode, user is provided with a list of allowed values (record types). However, the provided list contains also unsupported record types (APL, DHCID, etc.) and any attempt to add such records would end with error. This patch limits the list to supported record types only. https://fedorahosted.org/freeipa/ticket/2378 --- ipalib/plugins/dns.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ipalib/plugins') diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index b7f86e20..af23e03c 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -1376,6 +1376,8 @@ def __dns_record_options_iter(): yield extra _dns_record_options = tuple(__dns_record_options_iter()) +_dns_supported_record_types = tuple(record.rrtype for record in _dns_records \ + if record.supported) # dictionary of valid reverse zone -> number of address components _valid_reverse_zones = { @@ -1938,9 +1940,12 @@ class dnsrecord_add(LDAPCreate): if not isinstance(param, DNSRecord): raise ValueError() - except KeyError, ValueError: - all_types = u', '.join(_record_types) - self.Backend.textui.print_plain(_(u'Invalid type. Allowed values are: %s') % all_types) + + if not param.supported: + raise ValueError() + except (KeyError, ValueError): + all_types = u', '.join(_dns_supported_record_types) + self.Backend.textui.print_plain(_(u'Invalid or unsupported type. Allowed values are: %s') % all_types) continue ok = True @@ -1964,7 +1969,7 @@ class dnsrecord_add(LDAPCreate): # check if any record part was added try: rrparam = self.params[param.hint] - except KeyError, AttributeError: + except (KeyError, AttributeError): continue if rrparam.name in entry_attrs: -- cgit