summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Ohai.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Plugins/Ohai.py')
-rw-r--r--src/lib/Server/Plugins/Ohai.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/lib/Server/Plugins/Ohai.py b/src/lib/Server/Plugins/Ohai.py
index 02d6ef58b..c18bcbbce 100644
--- a/src/lib/Server/Plugins/Ohai.py
+++ b/src/lib/Server/Plugins/Ohai.py
@@ -1,10 +1,26 @@
-
-import json
import lxml.etree
import os
+
+import logging
+logger = logging.getLogger('Bcfg2.Plugins.Ohai')
+
import Bcfg2.Server.Plugin
+try:
+ import json
+except:
+ # FIXME: can be removed when server prereq is >= python 2.6
+ # necessary for clients without the in-tree json module
+ try:
+ import simplejson as json
+ except:
+ logger.error("Unable to load any json modules. Make sure "
+ "python-simplejson is installed.")
+ raise ImportError
+
+
class OhaiCache(object):
+
def __init__(self, dirname):
self.dirname = dirname
self.cache = dict()
@@ -27,6 +43,7 @@ class OhaiCache(object):
data.extend([x[:-5] for x in os.listdir(self.dirname)])
return data.__iter__()
+
class Ohai(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Probing,
Bcfg2.Server.Plugin.Connector):