[ClusterLabs] best practice for scripting
tojeline at redhat.com
Tue Apr 13 08:21:33 EDT 2021
You can use 'pcs cluster cib' for pacemaker configuration and 'pcs
cluster status xml' for pacemaker status. Both commands basically just
pass xml obtained from pacemaker, though. As far as I know, corosync
also provides parsable output, take a look at corosync-cmapctl. I'm not
sure about other cluster components.
Be aware that 'pcs status xml' may change in a near future. The reason
for that is that the xml produced by pacemaker is also changing as a
part of an effort to provide standardized xml output from most of (or
all) pacemaker tools.
As far as pcs text output changes: Yes, they are happening. Sometimes
it's a result of a change in another cluster component (e.g. 'pcs
status' prints text output from crm_mon). In other cases, it's due to
adding features, fixing bugs, standardizing output format, etc. It's not
always possible to avoid the changes.
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
Dne 13. 04. 21 v 9:17 d tbsky napsal(a):
> I have some scripts which use 'pcs' and 'crm_mon'. I prefer pcs
> since it is an all-in-one tool. but besides 'pcs cluster cib' it has
> no stable text output. reading document of pacemaker 2.1 I found it
> "In addition to crm_mon and stonith_admin, the crmadmin, crm_resource,
> crm_simulate, and crm_verify commands now support the --output-as and
> --output-to options, including XML output (which scripts and
> higher-level tools are strongly recommended to use instead of trying
> to parse the text output, which may change from release to release)."
> so if I need to parse the command output, I think I should study these
> commands instead of pcs in the future? RedHat is doing great job to
> maintain the 'pcs' output consistency between minor versions (eg:
> 7.2-> 7.3). but with major version 7->8 many things changed. if there
> is a more stable method for scripting I would like to follow it.
> thanks a lot for help!
> Manage your subscription:
> ClusterLabs home: https://www.clusterlabs.org/
More information about the Users