diff options
| author | David Kupka <dkupka@redhat.com> | 2015-12-02 14:20:50 +0000 |
|---|---|---|
| committer | Tomas Babej <tbabej@redhat.com> | 2015-12-14 18:53:53 +0100 |
| commit | 8d19da49c4259411ff333946019f4b981fab2bcf (patch) | |
| tree | b96bc8257c55ecdaa3d5621dd41dbb067fcf2f1d /ipapython | |
| parent | 6c107d819c557d32e90bbbd1ab4d60d8b59006db (diff) | |
| download | freeipa-8d19da49c4259411ff333946019f4b981fab2bcf.tar.gz freeipa-8d19da49c4259411ff333946019f4b981fab2bcf.tar.xz freeipa-8d19da49c4259411ff333946019f4b981fab2bcf.zip | |
dns: Check if domain already exists.
Raise an error when the domain already exists. This can be overriden using
--force or --allow-zone-overlap options.
https://fedorahosted.org/freeipa/ticket/3681
Reviewed-By: Petr Spacek <pspacek@redhat.com>
Diffstat (limited to 'ipapython')
| -rw-r--r-- | ipapython/ipautil.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 4cee81e64..7509f08c1 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -40,7 +40,7 @@ from contextlib import contextmanager import locale import collections -from dns import resolver, rdatatype +from dns import resolver, rdatatype, reversename from dns.exception import DNSException, Timeout import six from six.moves import input @@ -1031,6 +1031,22 @@ def host_exists(host): return True +def reverse_record_exists(ip_address): + """ + Checks if IP address have some reverse record somewhere. + Does not care where it points. + + Returns True/False + """ + reverse = reversename.from_address(str(ip_address)) + try: + resolver.query(reverse, "PTR") + except DNSException: + # really don't care what exception, PTR is simply unresolvable + return False + return True + + def check_zone_overlap(zone, raise_on_timeout=True): root_logger.info("Checking DNS domain %s, please wait ..." % zone) if not isinstance(zone, DNSName): |
