summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2005-09-27 20:10:03 +0000
committerNarayan Desai <desai@mcs.anl.gov>2005-09-27 20:10:03 +0000
commit369323bd91202879929b47e0278309018ea76d52 (patch)
tree3948a8fed8abca59351b817af509d1e7b3bb03fa
parent5aa7f9d869c821f29cd360ff36c7ee05c5dc3600 (diff)
downloadbcfg2-369323bd91202879929b47e0278309018ea76d52.tar.gz
bcfg2-369323bd91202879929b47e0278309018ea76d52.tar.bz2
bcfg2-369323bd91202879929b47e0278309018ea76d52.zip
switch to fully-qualified mode
(Logical change 1.322) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1310 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/Plugins/SSHbase.py39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py
index 845ce28eb..0dc896d2c 100644
--- a/src/lib/Server/Plugins/SSHbase.py
+++ b/src/lib/Server/Plugins/SSHbase.py
@@ -50,7 +50,6 @@ class SSHbase(Plugin):
prefix + '/etc/ssh/ssh_host_key':self.build_hk,
prefix + '/etc/ssh/ssh_host_key.pub':self.build_hk}}
self.ipcache = {}
- self.domains = ['mcs.anl.gov', 'bgl.mcs.anl.gov', 'globus.org', 'uc.teragrid.org']
def get_ipcache_entry(self, client):
'''build a cache of dns results'''
@@ -58,28 +57,18 @@ class SSHbase(Plugin):
return self.ipcache[client]
else:
# need to add entry
- if self.repository.entries.has_key('domains'):
- domains = self.repository.entries['domains'].data.split()
- else:
- domains = self.domains
- for domain in domains:
- try:
- fqdn = "%s.%s" % (client, domain)
- ipaddr = gethostbyname("%s.%s" % (client, domain))
- self.ipcache[client] = (ipaddr, fqdn)
- return (ipaddr, fqdn)
- except gaierror:
- continue
- if len(domains) == 1:
- domain = domains[0]
- fqdn = "%s.%s" % (client, domain)
- data = popen("getent hosts %s" % (client)).read().strip().split()
- if data:
- return (data[0], fqdn)
- else:
- continue
- self.LogError("Failed to find fqdn for %s" % client)
- raise gaierror
+ try:
+ ipaddr = gethostbyname(client)
+ self.ipcache[client] = (ipaddr, client)
+ return (ipaddr, client)
+ except gaierror:
+ pass
+ ipaddr = popen("getent hosts %s" % client).read().strip().split()
+ if ipaddr:
+ self.ipcache[client] = (ipaddr, client)
+ return (ipaddr, client)
+ self.LogError("Failed to find IP address for %s" % client)
+ raise gaierror
def cache_skn(self):
'''build memory cache of the ssh known hosts file'''
@@ -90,9 +79,9 @@ class SSHbase(Plugin):
(ipaddr, fqdn) = self.get_ipcache_entry(hostname)
except gaierror:
continue
- self.static_skn += "%s,%s,%s %s" % (hostname, fqdn, ipaddr,
+ shortname = hostname.split('.')[0]
+ self.static_skn += "%s,%s,%s %s" % (shortname, fqdn, ipaddr,
self.repository.entries[pubkey].data)
-
def build_skn(self, entry, metadata):
'''This function builds builds a host specific known_hosts file'''