From 8dae884cba115d4013d3038d8b97d6e840d48d88 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Mon, 31 Jan 2011 09:40:56 -0600 Subject: SSHbase: Fix hang when file not present on client Signed-off-by: Sol Jerome --- doc/appendix/guides/import-existing-ssh-keys.txt | 2 +- src/lib/Server/Plugins/SSHbase.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/appendix/guides/import-existing-ssh-keys.txt b/doc/appendix/guides/import-existing-ssh-keys.txt index d3befec26..e606ba908 100644 --- a/doc/appendix/guides/import-existing-ssh-keys.txt +++ b/doc/appendix/guides/import-existing-ssh-keys.txt @@ -88,7 +88,7 @@ stats and insert it as host-specific copies of these files in for key in ssh_host_rsa_key ssh_host_dsa_key ssh_host_key; do sudo bcfg2-admin pull Path /etc/ssh/$key - sudo bcfg2-admin pull Path /etc/ssh/${key}.pub + sudo bcfg2-admin pull Path /etc/ssh/$key.pub done This for loop pulls data that was collected by the bcfg2 client out of diff --git a/src/lib/Server/Plugins/SSHbase.py b/src/lib/Server/Plugins/SSHbase.py index 6d68ecb0a..96a444875 100644 --- a/src/lib/Server/Plugins/SSHbase.py +++ b/src/lib/Server/Plugins/SSHbase.py @@ -274,6 +274,10 @@ class SSHbase(Bcfg2.Server.Plugin.Plugin, # specific will always be host specific filename = "%s/%s.H_%s" % (self.data, entry['name'].split('/')[-1], specific.hostname) - open(filename, 'w').write(entry['text']) - if log: - print "Wrote file %s" % filename + try: + open(filename, 'w').write(entry['text']) + if log: + print "Wrote file %s" % filename + except KeyError: + self.logger.error("Failed to pull %s. This file does not currently " + "exist on the client" % entry.get('name')) -- cgit v1.2.3-1-g7c22