summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/server/plugins/connectors/properties.txt17
-rw-r--r--doc/server/plugins/probes/index.txt43
2 files changed, 51 insertions, 9 deletions
diff --git a/doc/server/plugins/connectors/properties.txt b/doc/server/plugins/connectors/properties.txt
index 1cbc4cf65..3329f48bd 100644
--- a/doc/server/plugins/connectors/properties.txt
+++ b/doc/server/plugins/connectors/properties.txt
@@ -38,7 +38,7 @@ Usage
Specific property files can be referred to in
templates as ``metadata.Properties[<filename>]``. The
-data attribute is an LXML element object. (Documented
+``xdata`` attribute is an LXML element object. (Documented
`here <http://codespeak.net/lxml/tutorial.html#the-element-class>`_)
Currently, only one access method is defined for this data, ``Match``.
@@ -56,10 +56,21 @@ more details on how Group and Client tags are parsed.) For instance::
As we formulate more common use cases, we will add them to the
!PropertyFile class as methods. This will simplify templates.
+You can also access the XML data that comprises a property file
+directly in one of several ways:
+
+* ``metadata.Properties['prop-file'].xdata`` is an lxml.etree._Element
+ object representing the top-level element in the file.
+* ``metadata.Properties['prop-file'].data`` is the raw contents of the
+ property file as a string.
+* ``metadata.Properties['prop-file'].entries`` is a list of
+ lxml.etree._Element objects representing the direct children of the
+ top-level element. (I.e., everything directly under the
+ ``<Properties>`` tag.)
+
Accessing Properties contents from TGenshi
==========================================
Access contents of ``Properties/auth.xml``::
-
- ${metadata.Properties['auth.xml'].data.find('file').find('bcfg2.key').text}
+ ${metadata.Properties['auth.xml'].xdata.find('file').find('bcfg2.key').text}
diff --git a/doc/server/plugins/probes/index.txt b/doc/server/plugins/probes/index.txt
index b9f698a0f..d52e7bb95 100644
--- a/doc/server/plugins/probes/index.txt
+++ b/doc/server/plugins/probes/index.txt
@@ -85,10 +85,12 @@ file looks like::
#end if
Any Probe script you run will store its output in
-``$self.metadata.Probes["scriptname"]``, so we get to our `scratchlocal`
-script's output as seen above. Note that we had to wrap the output in an
-`int()` call; the script output is treated as a string, so it needs to
-be converted before it can be tested numerically.
+``$self.metadata.Probes["scriptname"]``, so we get to our
+`scratchlocal` script's output as seen above. (See `Handling Probe
+Output`_, below, for more information on how this is done.) Note that
+we had to wrap the output in an `int()` call; the script output is
+treated as a string, so it needs to be converted before it can be
+tested numerically.
With all of these pieces in place, the following series of events will
happen when the client is run:
@@ -110,8 +112,37 @@ is to add the ``/etc/auto.master`` to a Bundle:
<Path name='/etc/auto.master'/>
-Host and Group Specific probes
-==============================
+Handling Probe Output
+=====================
+
+Bcfg2 stores output from probes in the ``Probes`` property of a
+client's metadata object. To access this data in TGenshi, for
+instance, you could do::
+
+ ${metadata.Probes['script-name']}
+
+This is not the full output of the probe; any lines that start with
+"group:" have been stripped from the output. The data is a
+string-like object that has some interesting and salient features:
+
+* If the data is a valid XML document, then
+ ``metadata.Probes['script-name'].xdata`` will be an
+ ``lxml.etree._Element`` object representing the XML data.
+* If the data is a valid JSON document, and the Python ``json`` module
+ is installed (included in Python 2.6 onward), then
+ ``metadata.Probes['script-name'].json`` will be a data structure
+ representing the JSON data.
+* If the data is a valid YAML document, and either the Python ``yaml``
+ module or ``syck`` module is installed, then
+ ``metadata.Probes['script-name'].yaml`` will be a data structure
+ representing the YAML data.
+
+If these conditions are not met, then the named properties will be
+``None``. In all other fashions, the probe data objects should act
+like strings.
+
+Host- and Group-Specific probes
+===============================
Bcfg2 has the ability to alter probes based on client hostname and group
membership. These files work similarly to files in Cfg.