summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/host.py
diff options
context:
space:
mode:
authorJan Zeleny <jzeleny@redhat.com>2010-12-14 19:02:18 +0100
committerRob Crittenden <rcritten@redhat.com>2010-12-20 10:45:27 -0500
commita1a8e7c13834d720ac9b8d597fc7dda9cda9cb65 (patch)
treed9823950c9af45e8d24e8d0b1b831378bc2b24a9 /ipalib/plugins/host.py
parent409e4062f463a67a4d013e738274f553a782359b (diff)
downloadfreeipa-a1a8e7c13834d720ac9b8d597fc7dda9cda9cb65.tar.gz
freeipa-a1a8e7c13834d720ac9b8d597fc7dda9cda9cb65.tar.xz
freeipa-a1a8e7c13834d720ac9b8d597fc7dda9cda9cb65.zip
Added option --no-reverse to add-host
When adding a host with specific IP address, the operation would fail in case IPA doesn't own the reverse DNS. This new option overrides the check for reverse DNS zone and falls back to different IP address existence check. https://fedorahosted.org/freeipa/ticket/417
Diffstat (limited to 'ipalib/plugins/host.py')
-rw-r--r--ipalib/plugins/host.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index 91aa6515..9b9ac4b4 100644
--- a/ipalib/plugins/host.py
+++ b/ipalib/plugins/host.py
@@ -260,6 +260,9 @@ class host_add(LDAPCreate):
Flag('force',
doc=_('force host name even if not in DNS'),
),
+ Flag('no_reverse',
+ doc=_('skip reverse DNS detection'),
+ ),
Str('ipaddr?', validate_ipaddr,
doc=_('Add the host to DNS with this IP address'),
),
@@ -277,21 +280,27 @@ class host_add(LDAPCreate):
break
if not match:
raise errors.NotFound(reason=_('DNS zone %(zone)s not found' % dict(zone=domain)))
- revzone, revname = get_reverse_zone(options['ipaddr'])
- # Verify that our reverse zone exists
- match = False
- for zone in result:
- if revzone == zone['idnsname'][0]:
- match = True
- break
- if not match:
- raise errors.NotFound(reason=_('Reverse DNS zone %(zone)s not found' % dict(zone=revzone)))
- try:
- reverse = api.Command['dns_find_rr'](revzone, revname)
- if reverse['count'] > 0:
+ if not options.get('no_reverse',False):
+ # we prefer lookup of the IP through the reverse zone
+ revzone, revname = get_reverse_zone(options['ipaddr'])
+ # Verify that our reverse zone exists
+ match = False
+ for zone in result:
+ if revzone == zone['idnsname'][0]:
+ match = True
+ break
+ if not match:
+ raise errors.NotFound(reason=_('Reverse DNS zone %(zone)s not found' % dict(zone=revzone)))
+ try:
+ reverse = api.Command['dns_find_rr'](revzone, revname)
+ if reverse['count'] > 0:
+ raise errors.DuplicateEntry(message=u'This IP address is already assigned.')
+ except errors.NotFound:
+ pass
+ else:
+ result = api.Command['dnsrecord_find'](domain, arecord=options['ipaddr'])
+ if result['count'] > 0:
raise errors.DuplicateEntry(message=u'This IP address is already assigned.')
- except errors.NotFound:
- pass
if not options.get('force', False) and not 'ipaddr' in options:
util.validate_host_dns(self.log, keys[-1])
if 'locality' in entry_attrs: