[ClusterLabs Developers] formatted output

Christopher Lumens clumens at redhat.com
Fri Mar 8 12:14:31 EST 2019

Hey everyone, I recently opened a PR for adding formatted output to the
various pacemaker tools.  Right now it only addresses stonith_admin both
because there was a bug opened about that and because I wanted to start
with something simple.

Here's the PR:


The basic layout is that there's a structure defined in pcmki/pcmki_output.h
with a bunch of function pointers that do the hard work of outputting a
specific kind of thing.  Multiple output formats are supported - at the
moment, text and XML.  At the top level, you select the formatting you
want and the destination (stdout, /dev/null, a file).

Then throughout the tool, you call the function in the structure to get
the specific formatting you want.  This lets you do things like output
lists, single items, XML, and so forth.  I imagine lots more function
pointers will be added as I go along converting other tools.

Error output is handled on the side.  If an error occurs, it's printed to
stderr and an error code returned.  We could potentially do something
different here, but it's tough.  Errors could occur in command line
processing before output formatting is set up, so what to do with those?
There's other problems in this area that I've forgotten, but I'm sure
I will remember once I take a look again.

Note that this is internal API.  The plan is that the format of the output
will be public and not change - there's a versioned RNG schema for
validating the XML output against.  The functions that generate that
output will remain internal so we can hopefully decrease the number of
them over time.

I've put some sample XML output in the PR as well so you can see what's
going on.

Suggestions are welcome, especially when it comes to the XML formatting.
Before I get too into converting a bunch of the other tools, I want to
make sure this is useful.

- Chris

More information about the Developers mailing list