summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/server/plugins/probes/index.txt34
-rw-r--r--src/lib/Server/Plugins/Ohai.py21
2 files changed, 53 insertions, 2 deletions
diff --git a/doc/server/plugins/probes/index.txt b/doc/server/plugins/probes/index.txt
index f723ad528..3c5387180 100644
--- a/doc/server/plugins/probes/index.txt
+++ b/doc/server/plugins/probes/index.txt
@@ -126,3 +126,37 @@ Other examples
manufacturer
producttype
serial-console-speed
+
+===========
+Ohai probes
+===========
+
+.. _Ohai: http://wiki.opscode.com/display/ohai/Home
+.. _Ohai-Install: http://wiki.opscode.com/display/ohai/Installation
+
+The `Ohai`_ plugin is used to detect information about the client
+operating system. The data is reported back to the server using JSON.
+
+Client prerequisites
+====================
+
+On the client, you need to install `Ohai`_. See `Ohai-Install`_ for more
+information.
+
+Server prerequisites
+====================
+
+If you have python 2.6 or later installed, you can continue on to
+:ref:`ohai-setup`. Otherwise, you will need to install the
+python-simplejson module found packaged in most distributions.
+
+.. _ohai-setup:
+
+Setup
+=====
+
+To enable the Ohai plugin, you need to first create an ``Ohai`` directory
+in your Bcfg2 repository (e.g. ``/var/lib/bcfg2/Ohai``). You then need
+to add **Ohai** to the plugins line in ``bcfg2.conf``. Once this is done,
+restart the server and start a client run. You will have the JSON output
+from the client in the ``Ohai`` directory you created previously.
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):