summaryrefslogtreecommitdiffstats
path: root/src/lib/Server
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2011-07-11 08:06:23 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2011-07-11 08:06:23 -0400
commit16ad53c10645ce0a097663780ecb5f92a92568f1 (patch)
treeade241f6b9cb64afb4f7f2e7070bd0350ab94800 /src/lib/Server
parent841cdd56e4ae141f8ba159e8cacc6c70003dd2fb (diff)
downloadbcfg2-16ad53c10645ce0a097663780ecb5f92a92568f1.tar.gz
bcfg2-16ad53c10645ce0a097663780ecb5f92a92568f1.tar.bz2
bcfg2-16ad53c10645ce0a097663780ecb5f92a92568f1.zip
made ohai plugin fail gracefully on machines without ohai installed
Diffstat (limited to 'src/lib/Server')
-rw-r--r--src/lib/Server/Plugins/Ohai.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/Server/Plugins/Ohai.py b/src/lib/Server/Plugins/Ohai.py
index 6bd3edc34..049aadd4f 100644
--- a/src/lib/Server/Plugins/Ohai.py
+++ b/src/lib/Server/Plugins/Ohai.py
@@ -19,8 +19,18 @@ except:
raise ImportError
-class OhaiCache(object):
+probecode = """#!/bin/sh
+
+if type ohai >& /dev/null; then
+ ohai
+else
+ echo group:ohai-not-installed
+ # an empty dict, so "'foo' in metadata.Ohai" tests succeed
+ echo '{}'
+fi
+"""
+class OhaiCache(object):
def __init__(self, dirname):
self.dirname = dirname
self.cache = dict()
@@ -62,7 +72,7 @@ class Ohai(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Connector.__init__(self)
self.probe = lxml.etree.Element('probe', name='Ohai', source='Ohai',
interpreter='/bin/sh')
- self.probe.text = 'ohai'
+ self.probe.text = probecode
try:
os.stat(self.data)
except: