From 635f0a464c587988f9fe982e5540e0cc18835716 Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Thu, 19 Jan 2012 12:14:41 +0100 Subject: 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 --- ipalib/plugins/dns.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'ipalib/plugins') 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 -- cgit