[ClusterLabs] best practice for scripting

Ken Gaillot kgaillot at redhat.com
Tue Apr 13 13:53:46 EDT 2021

On Tue, 2021-04-13 at 23:32 +0800, d tbsky wrote:
> Tomas Jelinek <tojeline at redhat.com>
> > As we are aware of the difficulties of using pcs in scripts, we
> > indeed
> > have a long term goal to provide machine readable output from pcs.
> > Since
> > pcs started with a focus on producing human readable output, it's a
> > lot
> > of work to do. Quite a big part of pcs code base cannot be easily
> > switched to producing machine parsable output. We are slowly moving
> > towards it (which in some cases may cause text output changes due
> > to
> > code reuse), but it is currently not seen as something to be
> > finished in
> > a year.
> Thanks for the hint. maybe after pacemaker 2.1 the xml output will
> become stable.

FYI, the old and new status XML are nearly identical. The old XML's
outermost element is

 <crm_mon version="...">

while the new XML has

 <pacemaker-result api-version="..." request="...">
   <status code="0" message="OK"/>

As long as you're not looking at those particular elements, parsing the
XML output is the same.

The format is actually stable and selectable since Pacemaker 2.0.3:
crm_mon --as-xml gets the old format, crm_mon --output-as=xml gets the
new. pcs status xml has continued to use --as-xml, but will switch to
--output-as=xml, thus Tomas's warning.

> I will try to start with "pcs status xml" in the future.
> Regards,
> tbskyd
Ken Gaillot <kgaillot at redhat.com>

More information about the Users mailing list