summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2012-02-28 08:48:08 +0100
committerMartin Kosek <mkosek@redhat.com>2012-02-29 18:42:38 +0100
commit4e9a2e0983a92829f497bb3ba6b3ab7b6db2967d (patch)
treef8fe949a0658fe8aa110a3f734e769bd436507ed
parente294f79488aee881e636b6a3c0565287c26da65d (diff)
downloadfreeipa-4e9a2e0983a92829f497bb3ba6b3ab7b6db2967d.tar.gz
freeipa-4e9a2e0983a92829f497bb3ba6b3ab7b6db2967d.tar.xz
freeipa-4e9a2e0983a92829f497bb3ba6b3ab7b6db2967d.zip
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
-rw-r--r--ipalib/plugins/dns.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index b7f86e201..af23e03c3 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: