summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2012-01-19 12:14:41 +0100
committerMartin Kosek <mkosek@redhat.com>2012-01-24 16:55:05 +0100
commit635f0a464c587988f9fe982e5540e0cc18835716 (patch)
treee233fcba0064e320c14c478be52ccfc26d87d77d
parentef68c02c6acdba29de9d4bab2c7f5aa956b55da2 (diff)
downloadfreeipa.git-635f0a464c587988f9fe982e5540e0cc18835716.tar.gz
freeipa.git-635f0a464c587988f9fe982e5540e0cc18835716.tar.xz
freeipa.git-635f0a464c587988f9fe982e5540e0cc18835716.zip
Mark optional DNS record parts
All DNS record part options in dnsrecord commands need to be optional so that all of them are not required in every dnsrecord command. However, FreeIPA API then does not include an information which DNS record part options are optional in term of creating a new DNS record. For example, LOC record option "latitude seconds" is not needed to add a new LOC record. This patch adds a flag "dnsrecord_optional" to all such options so that this information is available for any other UI reading the FreeIPA API. https://fedorahosted.org/freeipa/ticket/2208
-rw-r--r--ipalib/plugins/dns.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index abb2e90b..da4934fc 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -401,13 +401,27 @@ class DNSRecord(Str):
def get_parts(self):
if self.parts is None:
return tuple()
- return tuple(part.clone_rename(self.part_name_format % (self.rrtype.lower(), part.name),
- cli_name=self.cli_name_format % (self.rrtype.lower(), part.name),
- label=self.part_label_format % (self.rrtype, unicode(part.label)),
- required=False,
- option_group=self.option_group_format % self.rrtype,
- flags=(tuple(part.flags) + ('dnsrecord_part', 'virtual_attribute',))) \
- for part in self.parts)
+
+ parts = []
+
+ for part in self.parts:
+ name = self.part_name_format % (self.rrtype.lower(), part.name)
+ cli_name = self.cli_name_format % (self.rrtype.lower(), part.name)
+ label = self.part_label_format % (self.rrtype, unicode(part.label))
+ option_group = self.option_group_format % self.rrtype
+ flags = list(part.flags) + ['dnsrecord_part', 'virtual_attribute',]
+
+ if not part.required:
+ flags.append('dnsrecord_optional')
+
+ parts.append(part.clone_rename(name,
+ cli_name=cli_name,
+ label=label,
+ required=False,
+ option_group=option_group,
+ flags=flags))
+
+ return tuple(parts)
def prompt_parts(self, backend, mod_dnsvalue=None):
mod_parts = None