diff options
author | Martin Kosek <mkosek@redhat.com> | 2012-02-03 10:41:21 +0100 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2012-02-03 16:25:26 +0100 |
commit | cb4b2e6facea8fd786384ceb751e6dbedac2be5c (patch) | |
tree | 92aa56fa3896a5756db75aefbcc1a0d8a06f83c9 /ipalib/plugins/dns.py | |
parent | e41282fbc693e24535956c8822786e9e0bc3e8b4 (diff) | |
download | freeipa-cb4b2e6facea8fd786384ceb751e6dbedac2be5c.tar.gz freeipa-cb4b2e6facea8fd786384ceb751e6dbedac2be5c.tar.xz freeipa-cb4b2e6facea8fd786384ceb751e6dbedac2be5c.zip |
Fix NSEC record conversion
NSEC record needs special treatment as it is not composed from
a fixed set of DNS parts divided by space, but it contains
a multivalued DNS part "types" containing a list of RR types
it covers.
There was already a special method for parsing raw NSEC record
to DNS parts, but the other direction was missing. This patch
adds special NSEC convertor to fix this issue.
https://fedorahosted.org/freeipa/ticket/2307
Diffstat (limited to 'ipalib/plugins/dns.py')
-rw-r--r-- | ipalib/plugins/dns.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index d51c2c30f..d296f66d2 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -292,6 +292,11 @@ class DNSRecord(Str): return None return tuple(values) + def _part_values_to_string(self, values, index): + self._validate_parts(values) + return u" ".join(super(DNSRecord, self)._convert_scalar(v, index) \ + for v in values if v is not None) + def get_parts_from_kw(self, kw, raise_on_none=True): part_names = tuple(self.part_name_format % (self.rrtype.lower(), part.name) \ for part in self.parts) @@ -316,10 +321,7 @@ class DNSRecord(Str): def _convert_scalar(self, value, index=None): if isinstance(value, (tuple, list)): - # convert parsed values to the string - self._validate_parts(value) - return u" ".join(super(DNSRecord, self)._convert_scalar(v, index) \ - for v in value if v is not None) + return self._part_values_to_string(value, index) return super(DNSRecord, self)._convert_scalar(value, index) def normalize(self, value): @@ -795,10 +797,10 @@ class NSECRecord(DNSRecord): _domain_name_validator, label=_('Next Domain Name'), ), - StrEnum('types', + StrEnum('types+', label=_('Type Map'), - multivalue=True, values=_allowed_types, + csv=True, ), ) @@ -810,6 +812,16 @@ class NSECRecord(DNSRecord): return (values[0], tuple(values[1:])) + def _part_values_to_string(self, values, index): + self._validate_parts(values) + values_flat = [values[0],] # add "next" part + types = values[1] + if not isinstance(types, (list, tuple)): + types = [types,] + values_flat.extend(types) + return u" ".join(Str._convert_scalar(self, v, index) \ + for v in values_flat if v is not None) + class NSEC3Record(DNSRecord): rrtype = 'NSEC3' rfc = 5155 |