summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/dns.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipalib/plugins/dns.py')
-rw-r--r--ipalib/plugins/dns.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index 3ad03402d..fbc445215 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -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):