[ClusterLabs] pcs API / python module

Tomas Jelinek tojeline at redhat.com
Fri Sep 21 10:37:39 UTC 2018


Dne 20. 09. 18 v 17:37 Ken Gaillot napsal(a):
> On Thu, 2018-09-20 at 17:51 +0300, George Melikov wrote:
>> Hello all,
>>   
>> are there any official API for pacemaker/pcs? I'm interested in
>> python integration especially.
>>   
>> There are pcs module, but looks like it doesn't have stable API? http
>> s://lists.clusterlabs.org/pipermail/users/2015-August/001258.html
> 
> I don't think pcs has a public API -- even its command-line interface
> changes pretty regularly.

Pcs has no public API. It is our goal to provide an API and we have been 
working on it for quite some time now. It is, however, a long term task 
as it pretty much requires the whole pcs to be overhauled. It is still 
far from being finished.

You have several options now:

1. Use pcs command line interface
- This is the best, if not the only viable, option right now.
- Even though it changes from time to time, we maintain backward 
compatibility here.
- It provides most of the functionality.
- It is well documented.

2. Use pcsd http interface
- Only provides basic functionality.
- There is no documentation.
- Basically, what poki said in his mail you linked still applies:
the communication protocol between pcsd and pcs is _currently_ for 
internal use only (it's not unified nor stable, hence "API" is rather 
strong label)

3. Use pcs.lib.commands
- This is supposed to be a foundation of the future public API.
- There is some documentation. Still it requires digging through pcs 
code to figure out how to use it.
- It provides limited functionality, essential things (e.g. resource 
management) are missing.
- It is under development and still considered an internal interface - 
expect it to change often in a backward incompatible way.

Regards,
Tomas

> 
> Pacemaker has a C API, but that would be challenging to use from
> python. There's been interest in creating a REST API, but that's a big
> project that no one has tackled yet.
> 
> There are some python bits in pacemaker's CTS test suite, but not a
> stable API or well-suited for use by other projects. I would like to
> generalize it one day into a public python API for pacemaker, but again
> that's a big project without any time for it.
> 
> I would recommend using the pacemaker command-line tools (crm_resource,
> crm_node, etc.). Those interfaces are quite stable, and you could make
> python wrappers for executing them.
> 


More information about the Users mailing list