summaryrefslogtreecommitdiffstats
path: root/ipaserver/install/installutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipaserver/install/installutils.py')
-rw-r--r--ipaserver/install/installutils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/ipaserver/install/installutils.py b/ipaserver/install/installutils.py
index 3868c4d04..554e9b1cb 100644
--- a/ipaserver/install/installutils.py
+++ b/ipaserver/install/installutils.py
@@ -33,6 +33,9 @@ import time
from ipapython import ipautil
from ipapython import dnsclient
+class HostnameLocalhost(Exception):
+ pass
+
def get_fqdn():
fqdn = ""
try:
@@ -421,3 +424,15 @@ def wait_for_open_ports(host, ports, timeout=0):
else:
raise e
+def resolve_host(host_name):
+ try:
+ addrinfos = socket.getaddrinfo(host_name, None,
+ socket.AF_UNSPEC, socket.SOCK_STREAM)
+ for ai in addrinfos:
+ ip = ai[4][0]
+ if ip == "127.0.0.1" or ip == "::1":
+ raise HostnameLocalhost("The hostname resolves to the localhost address")
+
+ return addrinfos[0][4][0]
+ except:
+ return None