summaryrefslogtreecommitdiffstats
path: root/ipalib/util.py
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2009-02-18 17:12:27 -0500
committerRob Crittenden <rcritten@redhat.com>2009-02-19 10:09:24 -0500
commit1a8ec58602504427679784c5576522c137481e38 (patch)
treea08142e9708092d0d22cea961460391e62445e86 /ipalib/util.py
parent83d5987db917b8097ff80ba4df72db754cf4f943 (diff)
downloadfreeipa-1a8ec58602504427679784c5576522c137481e38.tar.gz
freeipa-1a8ec58602504427679784c5576522c137481e38.tar.xz
freeipa-1a8ec58602504427679784c5576522c137481e38.zip
Utility function to get the local hostname
Diffstat (limited to 'ipalib/util.py')
-rw-r--r--ipalib/util.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ipalib/util.py b/ipalib/util.py
index f1a7928a2..3e47cc3a1 100644
--- a/ipalib/util.py
+++ b/ipalib/util.py
@@ -30,6 +30,7 @@ import time
from types import NoneType
from xmlrpclib import Binary
import krbV
+import socket
def get_current_principal():
@@ -40,6 +41,16 @@ def get_current_principal():
print "Unable to get kerberos principal"
return None
+def get_fqdn():
+ fqdn = ""
+ try:
+ fqdn = socket.getfqdn()
+ except:
+ try:
+ fqdn = socket.gethostname()
+ except:
+ fqdn = ""
+ return fqdn
# FIXME: This function has no unit test
def find_modules_in_dir(src_dir):