[Linux-HA] how to start/stop a resource and wait until
success/fail by PROGRAM?
Andrew Beekhof
beekhof at gmail.com
Mon Oct 22 06:10:53 MDT 2007
On 10/22/07, dxj_600 <dxj_600 at 126.com> wrote:
> Hi,
>
> I use heartbeat-2.1.2, consider the following configurations:
> <cib>
> <configuration>
> <crm_config> .... </crm_config>
> <nodes>
> <node uname="node0" id="node0"/>
> </nodes>
> <resources>
> <primative id="rsc_xxx" class="ocf" type="Stateful" provider="heartbeat" is_managed="true">
> </primative>
> </resources>
> <constraints>
> <rsc_location id="location_xxx" rsc="rsc_xxx">
> <rule id="location_xxx_rule" score="-infinity"/>
> </rsc_location>
> </constraints>
> </configuration>
> </cib>
>
> I want to code a program which can start/stop a resource, and I want the function to be synchronous.
> static BOOL cib_updated=FALSE;
> void on_cib_diff()
> {
> cib_updated=TRUE;
> }
> int start_xxx()
> {
> cib_t *cib=cib_new();
> cib->cmds->signon();
> cib_conn->cmds->add_notify_callback(cib, T_CIB_DIFF_NOTIFY, on_cib_diff);
>
> code with effect: cibadmin -D -o constraints -X '<rsc_location id="location_xxx"/>'
> while(cib_updated==FALSE) sleep(1);
> /* Now, cib has been updated, and will trigger the pengine/tengine to start the resource
> MY QUESTION IS:
> WHEN and HOW can i determine that the resource xxx has been started successfully???????
> */
>
> cib->cmds->signoff();
> cib=NULL;
> }
your program should connect to the cib and subscribe to change
notifications (the TE does this, look there for how).
once you make your update, look for an lrm_rsc_op for (your resource +
action=start + rc=0)
once you see that, then you know it has started
More information about the Linux-HA
mailing list