summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSol Jerome <solj@ices.utexas.edu>2009-06-23 14:16:05 +0000
committerSol Jerome <solj@ices.utexas.edu>2009-06-23 14:16:05 +0000
commit542dafea6974627df8e327be7f80d9f7bf417892 (patch)
treea38705246c9255654bb616b3681b32748e3ff0ee /src
parent7139c9cd7ea4a1d13323d4add72f87a0bd3f293f (diff)
downloadbcfg2-542dafea6974627df8e327be7f80d9f7bf417892.tar.gz
bcfg2-542dafea6974627df8e327be7f80d9f7bf417892.tar.bz2
bcfg2-542dafea6974627df8e327be7f80d9f7bf417892.zip
SSHBase: Make SSHBase aware of aliases
SSHBase is now aware of aliases listed in the clients.xml file. ClientMetadata now includes `addresses` which are a mapping from an alias to an (ip, name) tuple. The ip addresses can be specified either in clients.xml as an address attribute to the Alias or in DNS. Signed-off-by: Sol Jerome <solj@ices.utexas.edu> git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5295 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugins/Metadata.py21
-rw-r--r--src/lib/Server/Plugins/SSHbase.py17
2 files changed, 34 insertions, 4 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index a911e6fd3..906a16fac 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -18,11 +18,12 @@ class MetadataRuntimeError(Exception):
class ClientMetadata(object):
'''This object contains client metadata'''
- def __init__(self, client, profile, groups, bundles, categories, uuid,
- password, query):
+ def __init__(self, client, profile, groups, bundles,
+ addresses, categories, uuid, password, query):
self.hostname = client
self.profile = profile
self.bundles = bundles
+ self.addresses = addresses
self.groups = groups
self.categories = categories
self.uuid = uuid
@@ -375,6 +376,20 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
self.set_profile(client, self.default, (None, None))
profile = self.default
[bundles, groups, categories] = self.groups[self.default]
+ '''
+ Handle aliases listed in clients.xml
+ addresses - contains address information for all aliases
+ mapping is as follows:
+ {alias: (ip, realname)}
+ '''
+ addresses = {}
+ for alias, host in self.aliases.iteritems():
+ for ip in self.addresses:
+ for name in self.addresses[ip]:
+ if name == host:
+ addresses[alias] = (ip, host)
+ if alias not in addresses:
+ addresses[alias] = (None, host)
newgroups = set(groups)
newbundles = set(bundles)
newcategories = {}
@@ -396,7 +411,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
[newbundles.add(b) for b in nbundles if b not in newbundles]
[newgroups.add(g) for g in ngroups if g not in newgroups]
newcategories.update(ncategories)
- return ClientMetadata(client, profile, newgroups, newbundles,
+ return ClientMetadata(client, profile, newgroups, newbundles, addresses,
newcategories, uuid, password, self.query)
def get_client_names_by_profiles(self, profiles):
diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py
index 1485df626..242aaf580 100644
--- a/src/lib/Server/Plugins/SSHbase.py
+++ b/src/lib/Server/Plugins/SSHbase.py
@@ -28,7 +28,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin,
public key for (hostname)
ssh_known_hosts -> the current known hosts file. this
is regenerated each time a new key is generated.
-'''
+ '''
name = 'SSHbase'
__version__ = '$Id$'
__author__ = 'bcfg-dev@mcs.anl.gov'
@@ -143,6 +143,7 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin,
def build_skn(self, entry, metadata):
'''This function builds builds a host specific known_hosts file'''
client = metadata.hostname
+ addresses = metadata.addresses
entry.text = self.skn
hostkeys = [keytmpl % client for keytmpl in self.pubkeys \
if (keytmpl % client) in self.entries]
@@ -150,6 +151,20 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin,
for hostkey in hostkeys:
entry.text += "localhost,localhost.localdomain,127.0.0.1 %s" % (
self.entries[hostkey].data)
+ # add entries listed in clients.xml
+ for addr, (ip, host) in addresses.iteritems():
+ shortname = addr.split('.')[0]
+ fqdn = addr
+ if ip == None:
+ ipaddr = self.get_ipcache_entry(addr)[0]
+ else:
+ ipaddr = ip
+ for key in self.entries.keys():
+ if key.find('.pub.H_%s' % host) != -1:
+ entry.text += "%s,%s,%s %s" % (shortname,
+ fqdn,
+ ipaddr,
+ self.entries[key].data)
permdata = {'owner':'root', 'group':'root', 'perms':'0644'}
[entry.attrib.__setitem__(key, permdata[key]) for key in permdata]