From 1a8ec58602504427679784c5576522c137481e38 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 18 Feb 2009 17:12:27 -0500 Subject: Utility function to get the local hostname --- ipalib/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ipalib/util.py') diff --git a/ipalib/util.py b/ipalib/util.py index f1a7928a..3e47cc3a 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): -- cgit