summaryrefslogtreecommitdiffstats
path: root/certmaster/utils.py
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2009-03-03 17:41:12 -0500
committerAdrian Likins <alikins@redhat.com>2009-03-03 17:41:12 -0500
commit919c9c3a4f5418b55108c1ec903160f0400900df (patch)
tree6bac49ce0531be30c6f02c5d8d0e9249dcd482cb /certmaster/utils.py
parent907668bd5063ebf8c4e2c11abcbd6cb46880808d (diff)
downloadcertmaster-919c9c3a4f5418b55108c1ec903160f0400900df.tar.gz
certmaster-919c9c3a4f5418b55108c1ec903160f0400900df.tar.xz
certmaster-919c9c3a4f5418b55108c1ec903160f0400900df.zip
change utils.get_hostname to just do the basic thing. Move the bits
that do all the config checking and route lookup and other madness to func.utils.get_hostname_by_route
Diffstat (limited to 'certmaster/utils.py')
-rw-r--r--certmaster/utils.py30
1 files changed, 1 insertions, 29 deletions
diff --git a/certmaster/utils.py b/certmaster/utils.py
index 958d26d..76d5b4d 100644
--- a/certmaster/utils.py
+++ b/certmaster/utils.py
@@ -107,45 +107,17 @@ def get_hostname(talk_to_certmaster=True):
up the hostname for that.
"""
# FIXME: this code ignores http proxies (which granted, we don't
- # support elsewhere either. It also hardcodes the port number
- # for the certmaster for now
+ # support elsewhere either.
hostname = None
hostname = socket.gethostname()
# print "DEBUG: HOSTNAME TRY1: %s" % hostname
try:
ip = socket.gethostbyname(hostname)
- # print "DEBUG: IP TRY2: %s" % ip
except:
- # print "DEBUG: ERROR: returning"
return hostname
if ip != "127.0.0.1":
- # print "DEBUG: ERROR: returning 2"
return hostname
- if talk_to_certmaster:
- config_file = '/etc/certmaster/minion.conf'
- config = read_config(config_file, MinionConfig)
-
- server = config.certmaster
- port = config.certmaster_port
-
- try:
- s = socket.socket()
- s.settimeout(5)
- s.connect((server, port))
- (intf, port) = s.getsockname()
- remote_hostname = socket.gethostbyaddr(intf)[0]
- if remote_hostname != "localhost":
- hostname = remote_hostname
- # print "DEBUG: HOSTNAME FROM CERTMASTER == %s" % hostname
- s.close()
- except:
- s.close()
- raise
-
- # print "DEBUG: final hostname=%s" % hostname
- return hostname
-
# FIXME: move to requestor module and also create a verbose mode
# prints to the screen for usage by /usr/bin/certmaster-request