summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2012-02-03 10:41:21 +0100
committerMartin Kosek <mkosek@redhat.com>2012-02-03 16:25:35 +0100
commit43c3fbc3b06d5bc453f0178d05f7bc63ee2dc592 (patch)
tree698cd2f6338df9bd90bc6cfd0c64c91725179df5 /ipalib
parent8f17a9ff975a20ad5c8691b11815a45dd11f4707 (diff)
downloadfreeipa.git-43c3fbc3b06d5bc453f0178d05f7bc63ee2dc592.tar.gz
freeipa.git-43c3fbc3b06d5bc453f0178d05f7bc63ee2dc592.tar.xz
freeipa.git-43c3fbc3b06d5bc453f0178d05f7bc63ee2dc592.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')
-rw-r--r--ipalib/plugins/dns.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index d51c2c30..d296f66d 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