[Pacemaker] Newcomer's question - API?

Tim Serong tserong at suse.com
Tue Nov 1 23:33:06 EDT 2011


On 11/02/2011 08:34 AM, Florian Haas wrote:
> On 2011-11-01 21:30, Andrew Beekhof wrote:
>> On Wed, Nov 2, 2011 at 7:04 AM, Florian Haas<florian at hastexo.com>  wrote:
>>> On 2011-11-01 17:52, Tim Ward wrote:
>>>>> You can try tooking at LCMC as that is a Java-based GUI that
>>>>> should at least get you going.
>>>>
>>>> I did find some Java code but we can't use it because it's GPL, and I
>>>> didn't want to study it in case I accidentally copied some of it in
>>>> recreating it.
>>>
>>> Well if you can't use anything that's under GPL, I presume anything
>>> derived from cib.h is off limits to you anyway, as _that_ is under GPL.
>>
>> LGPL iirc
>
>> From include/crm/cib.h:
>
> /*
>   * Copyright (C) 2004 Andrew Beekhof<andrew at beekhof.net>
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public
>   * License as published by the Free Software Foundation; either
>   * version 2 of the License, or (at your option) any later version.
>
> Doesn't say much about LGPL afaics.

<ianal>I vaguely recall reading the FSF considered headers generally 
exempt from GPL provisions, provided they're "boring", i.e. just 
structs, function definitions etc.  If they're a whole lotta inline 
code, things are a bit different</ianal>.

Anyway.  Roughly speaking, if we *did* have other language bindings for 
libcib/libpengine, the story would be something like this (Andrew can 
correct me if I'm wrong):

libcib would let you manipulate the CIB programatically, with much the 
same ability you have when running cibadmin, i.e. you're just 
manipulating chunks of XML.  Unless I'm not paying attention, there's no 
e.g. "create resource" API; your program would have to construct the 
correct XML resource definition then give it to libcib to inject into 
the cluster configuration.  Likewise, to stop and start a resource, 
you'll be writing code to set the target-role meta attribute of that 
resource.  So you may as well just invoke cibadmin, crm_resource, 
crm_attribute directly.  I think it's safe to assume those interfaces 
are stable.  At a higher level, "crm configure ..." should also be 
considered pretty stable; we know people use it in scripts so we try not 
to break it (and BTW, I use all this stuff in Hawk[1]).

libpengine is more interesting.  That would give you reliable 
information about resource status.  The alternative (given no other 
language bindings) is generally either:

   - various invocations of crm_mon and crm_resource (maybe lots of
     invocations, depending on what information you want to extract),
     which can suck on large clusters, or,

   - one invocation of "cibadmin -Q" to get the CIB status section,
     then process this yourself to determine resource status, using the
     Dragon Page[2] as a guide.  If you do a good jobs of this and/or
     you care about op history (not just current status), you will
     end up reimplementing parts of the determine_online_status() and
     unpack_rsc_op() functions from Pacemaker's lib/pengine/unpack.c in
     $other_language_of_your_choice.

Regards,

Tim

[1] http://clusterlabs.org/wiki/Hawk
[2] 
http://www.clusterlabs.org/doc/en-US/Pacemaker/1.1/html/Pacemaker_Explained/ch-status.html

-- 
Tim Serong
Senior Clustering Engineer
SUSE
tserong at suse.com




More information about the Pacemaker mailing list