Prompt for nameserver IP address in dnszone-add

Prompt for nameserver IP address in interactive mode of dnszone-add.

Add a corresponding field to dnszone creation dialog in the web UI.

This parameter is required if and only if:
* New zone is a forward zone
* Nameserver is defined inside the new zone

Add a new unit test to cover this functionality.

https://fedorahosted.org/freeipa/ticket/3603
This commit is contained in:
Ana Krivokapic
2013-05-16 11:01:33 +02:00
committed by Martin Kosek
parent 78774916c8
commit c5bfeb1ed0
5 changed files with 161 additions and 0 deletions
+21
View File
@@ -1781,9 +1781,30 @@ class dnszone_add(LDAPCreate):
),
Str('ip_address?', _validate_ipaddr,
doc=_('Add forward record for nameserver located in the created zone'),
label=_('Nameserver IP address'),
),
)
def interactive_prompt_callback(self, kw):
"""
Interactive mode should prompt for nameserver IP address only if all
of the following conditions are true:
* New zone is a forward zone
* NS is defined inside the new zone (NS can be given either in the
form of absolute or relative name)
"""
if kw.get('ip_address', None):
return
zone = normalize_zone(kw['idnsname'])
ns = kw['idnssoamname']
relative_ns = not ns.endswith('.')
ns_in_zone = self.obj.get_name_in_zone(zone, ns)
if not zone_is_reverse(zone) and (relative_ns or ns_in_zone):
ip_address = self.Backend.textui.prompt(_(u'Nameserver IP address'))
kw['ip_address'] = ip_address
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
assert isinstance(dn, DN)
if not dns_container_exists(self.api.Backend.ldap2):