mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
parent
409e4062f4
commit
a1a8e7c138
@ -260,6 +260,9 @@ class host_add(LDAPCreate):
|
|||||||
Flag('force',
|
Flag('force',
|
||||||
doc=_('force host name even if not in DNS'),
|
doc=_('force host name even if not in DNS'),
|
||||||
),
|
),
|
||||||
|
Flag('no_reverse',
|
||||||
|
doc=_('skip reverse DNS detection'),
|
||||||
|
),
|
||||||
Str('ipaddr?', validate_ipaddr,
|
Str('ipaddr?', validate_ipaddr,
|
||||||
doc=_('Add the host to DNS with this IP address'),
|
doc=_('Add the host to DNS with this IP address'),
|
||||||
),
|
),
|
||||||
@ -277,6 +280,8 @@ class host_add(LDAPCreate):
|
|||||||
break
|
break
|
||||||
if not match:
|
if not match:
|
||||||
raise errors.NotFound(reason=_('DNS zone %(zone)s not found' % dict(zone=domain)))
|
raise errors.NotFound(reason=_('DNS zone %(zone)s not found' % dict(zone=domain)))
|
||||||
|
if not options.get('no_reverse',False):
|
||||||
|
# we prefer lookup of the IP through the reverse zone
|
||||||
revzone, revname = get_reverse_zone(options['ipaddr'])
|
revzone, revname = get_reverse_zone(options['ipaddr'])
|
||||||
# Verify that our reverse zone exists
|
# Verify that our reverse zone exists
|
||||||
match = False
|
match = False
|
||||||
@ -292,6 +297,10 @@ class host_add(LDAPCreate):
|
|||||||
raise errors.DuplicateEntry(message=u'This IP address is already assigned.')
|
raise errors.DuplicateEntry(message=u'This IP address is already assigned.')
|
||||||
except errors.NotFound:
|
except errors.NotFound:
|
||||||
pass
|
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.')
|
||||||
if not options.get('force', False) and not 'ipaddr' in options:
|
if not options.get('force', False) and not 'ipaddr' in options:
|
||||||
util.validate_host_dns(self.log, keys[-1])
|
util.validate_host_dns(self.log, keys[-1])
|
||||||
if 'locality' in entry_attrs:
|
if 'locality' in entry_attrs:
|
||||||
|
Loading…
Reference in New Issue
Block a user