diff options
author | Sol Jerome <solj@ices.utexas.edu> | 2010-03-04 17:22:40 +0000 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2010-03-04 17:22:40 +0000 |
commit | 81089eae40e9bc6cef778f05c23f10a7a746ae06 (patch) | |
tree | cadae0f8600bbec24d4b539165f014943b7f25f6 /src/lib/Server | |
parent | 7ff0c5743ac8000980d5760f3baf9b19825d4efd (diff) | |
download | bcfg2-81089eae40e9bc6cef778f05c23f10a7a746ae06.tar.gz bcfg2-81089eae40e9bc6cef778f05c23f10a7a746ae06.tar.bz2 bcfg2-81089eae40e9bc6cef778f05c23f10a7a746ae06.zip |
Ohai: Add support for pre-2.6 versions of python
The Ohai plugin now works with servers using python 2.4-2.5 alongside
the python-simplejson python module.
Signed-off-by: Sol Jerome <solj@ices.utexas.edu>
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5748 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Plugins/Ohai.py | 21 |
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): |