[Linux-HA] how to start/stop a resource and wait until
success/fail by PROGRAM?
beekhof at gmail.com
Mon Oct 22 06:10:53 MDT 2007
On 10/22/07, dxj_600 <dxj_600 at 126.com> wrote:
> I use heartbeat-2.1.2, consider the following configurations:
> <crm_config> .... </crm_config>
> <node uname="node0" id="node0"/>
> <primative id="rsc_xxx" class="ocf" type="Stateful" provider="heartbeat" is_managed="true">
> <rsc_location id="location_xxx" rsc="rsc_xxx">
> <rule id="location_xxx_rule" score="-infinity"/>
> 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()
> int start_xxx()
> cib_t *cib=cib_new();
> 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???????
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