diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2007-04-05 19:30:36 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2007-04-05 19:30:36 +0000 |
commit | ac79a867a819102f9c678f558dd9252e141cee94 (patch) | |
tree | 40eb0937230b832e8ea0ed79a60af7f55771e823 /src | |
parent | ca0148e3ee939b0eb84e61ba40c5fbdc9b81afc2 (diff) | |
download | bcfg2-ac79a867a819102f9c678f558dd9252e141cee94.tar.gz bcfg2-ac79a867a819102f9c678f558dd9252e141cee94.tar.bz2 bcfg2-ac79a867a819102f9c678f558dd9252e141cee94.zip |
Add bcfg2-admin pull support to SSHbase
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3014 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Plugins/SSHbase.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py index 6c2c730ca..0d9cd1c82 100644 --- a/src/lib/Server/Plugins/SSHbase.py +++ b/src/lib/Server/Plugins/SSHbase.py @@ -1,7 +1,14 @@ '''This module manages ssh key files for bcfg2''' __revision__ = '$Revision$' -import binascii, os, socket, Bcfg2.Server.Plugin +import binascii, difflib, os, socket, xml.sax.saxutils +import Bcfg2.Server.Plugin + +def update_file(path, diff): + '''Update file at path using diff''' + newdata = '\n'.join(difflib.restore(xml.sax.saxutils.unescape(diff).split('\n'), 1)) + print "writing file, %s" % path + open(path, 'w').write(newdata) class SSHbase(Bcfg2.Server.Plugin.Plugin): '''The sshbase generator manages ssh host keys (both v1 and v2) @@ -168,3 +175,12 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin): os.unlink("%s.pub" % temploc) except OSError: self.logger.error("Failed to unlink temporary ssh keys") + + def AcceptEntry(self, meta, _, entry_name, diff): + '''per-plugin bcfg2-admin pull support''' + filename = "%s/%s.H_%s" % (self.data, entry_name.split('/')[-1], + meta.hostname) + print "This file will be installed as file %s" % filename + if raw_input("Should it be installed? (N/y): ") in 'Yy': + update_file(filename, diff) + |