Hello,

First of all I want to excuse me for my bad english!

We use heartbeat 2.1.2-3 in a 2 node cluster, just to manage the virtual
IP adress 172.30.4.170. We have a network service that have to run
at both nodes to make sure they have a synchronous data set.
Therefore both nodes have to know which one holds the virtual IP.
I would like to implement that with the heartbeat API.

Now I've several questions about the heartbeat API client:

- Is it possible to gain the current location of the resource (VIP) via
 get_resources(hb); or node_status(hb, node); ?
 Or is there any other way to get this information inside a C++ program?


- Is there anywhere a documentation about the function "node_status()"?


- What does the second parameter "gboolean need_destroy_chan" of the
 function signoff() mean? He is missing in the docu.


- the apigroupname in the apiauth directive (in ha.cf) is the same
 as the service name that I have to pass the signon() function?
 e.g. If I use the function like this: 'hb->llc_ops->signon(hb, "rsc_loc");'
 then I have to use the apiauth directive in this way, right?

apiauth rsc_loc uid=my_service_user gid=my_service_group


- Is there another way to avoid the C++ keyword conflict than in that way?:
#ifdef __cplusplus
 extern "C" {
 # define delete __fake_delete
 # define private __fake_private
 // Add other defines for any conflicting C++ keyword
#endif
#include <hb_api.h>
#ifdef __cplusplus
 }
#endif


Here are my 2 versions of the code for that:
(only fragments of the whole code from the service)

----
char const *resources;
ll_cluster_t *hb;
hb = ll_cluster_new("heartbeat");

if(hb->llc_ops->signon(hb, "rsc_loc") != HA_OK) {
        write_log("HB: signon error: %s\n", hb->llc_ops->errmsg(hb));
}

if ((resources = hb->llc_ops->get_resources(hb)) == NULL) {
        write_log("HB: get_resource error: %s\n", hb->llc_ops->errmsg(hb));
} else {
        write_log("HB: Current resource status: %s", resources);
        // possible are: local, foreign, all, none, transition
}

if (hb->llc_ops->signoff(hb, FALSE) != HA_OK) {
        write_log("HB: signoff error: %s\n", hb->llc_ops->errmsg(hb));
}

if (hb->llc_ops->delete(hb) != HA_OK) {
        write_log("HB: delete error: %s\n", hb->llc_ops->errmsg(hb));
}
----

----
const char *node;
ll_cluster_t *hb;
static int hb_new = 1;
static int hb_up = 1;

hb = ll_cluster_new("heartbeat");
if (hb == NULL) {
        hb_new = 0;
}
write_log("BH: hb_new = %i\n", hb_new);

if (hb_new) {
        if (hb->llc_ops->signon(hb, "rsc_loc2") != HA_OK) {
                hb_up = 0;
        }
        write_log("BH: hb_up = %i\n", hb_up);

        if (hb_up) {
                hb->llc_ops->init_nodewalk(hb);
                while ((node = hb->llc_ops->nextnode(hb)) != NULL) {
                        write_log("HB: %s = %s\n", node, 
hb->llc_ops->node_status(hb, node));
                }
                hb->llc_ops->end_nodewalk(hb);
                hb->llc_ops->signoff(hb, FALSE);
        }
        hb->llc_ops->delete(hb);
}
----


I'm running heartbeat under CentOS release 4.5 (Final) 2.6.9-55.EL i686
on the nodes defas1 (172.30.4.150) and defas2 (172.30.4.160).

I've installed heartbeat with following RPM-packets:
heartbeat-2.1.2-3.el4.centos, hetbeat-ldirectord-2.1.2-3.el4.centos
(I want to use LVS later), heartbeat-pils-2.1.2-3.el4.centos,
heartbeat-gui-2.1.2-3.el4.centos and heartbeat-stonith-2.1.2-3.el4.centos.

The other configurations are attached to this mail.


Do I'd made any fundamental errors?

Thanks in advance,
Stephan

HELPING HEADS for Hard- and Software
-------------------------------------------------------------------------
Für Ihre Projekte entwickeln wir maßgeschneiderte Lösungen - schnell,
flexibel und direkt vor Ort. Unser eingespieltes Team an erfahrenen Hard-
und Software-Spezialisten unterstützt Sie dort, wo Sie uns brauchen.



--------------------------------------------------------------------------
SysDesign GmbH
Säntisstrasse 25
D-88079 Kressbronn am Bodensee

Geschäftsführer: Franz Kleiner, Achim Solle
Handelsregister: Ulm 632138
--------------------------------------------------------------------------

use_logd yes
udpport 694
keepalive 5
deadtime 15
warntime 10
initdead 45
bcast eth1
serial /dev/ttyS0
baud 115200
ping 172.30.4.170
node defas1 defas2
crm on
auto_failback yes
respawn cluster /etc/init.d/httpd
respawn cluster /usr/lib/heartbeat/ipfail
apiauth rsc_loc uid=defas
# cibadmin -Ql
 <cib admin_epoch="0" have_quorum="true" ignore_dtd="false" num_peers="2" 
cib_feature_revision="1.3" generated="true" epoch="2" ccm_transition="2" 
dc_uuid="6ca8e370-6b00-4b8c-85fe-a67da4c562ba" num_updates="16">
   <configuration>
     <crm_config>
       <cluster_property_set id="cib-bootstrap-options">
         <attributes>
           <nvpair id="cib-bootstrap-options-symmetric-cluster" 
name="symmetric-cluster" value="true"/>
           <nvpair id="cib-bootstrap-options-no-quorum-policy" 
name="no-quorum-policy" value="stop"/>
           <nvpair id="cib-bootstrap-options-default-resource-stickiness" 
name="default-resource-stickiness" value="0"/>
           <nvpair 
id="cib-bootstrap-options-default-resource-failure-stickiness" 
name="default-resource-failure-stickiness" value="0"/>
           <nvpair id="cib-bootstrap-options-stonith-enabled" 
name="stonith-enabled" value="false"/>
           <nvpair id="cib-bootstrap-options-stonith-action" 
name="stonith-action" value="reboot"/>
           <nvpair id="cib-bootstrap-options-stop-orphan-resources" 
name="stop-orphan-resources" value="true"/>
           <nvpair id="cib-bootstrap-options-stop-orphan-actions" 
name="stop-orphan-actions" value="true"/>
           <nvpair id="cib-bootstrap-options-remove-after-stop" 
name="remove-after-stop" value="false"/>
           <nvpair id="cib-bootstrap-options-short-resource-names" 
name="short-resource-names" value="true"/>
           <nvpair id="cib-bootstrap-options-transition-idle-timeout" 
name="transition-idle-timeout" value="5min"/>
           <nvpair id="cib-bootstrap-options-default-action-timeout" 
name="default-action-timeout" value="15s"/>
           <nvpair id="cib-bootstrap-options-is-managed-default" 
name="is-managed-default" value="true"/>
         </attributes>
       </cluster_property_set>
     </crm_config>
     <nodes>
       <node id="8d083aa4-14cc-4cca-9a8c-e7308fb2743c" uname="defas2" 
type="normal">
         <instance_attributes id="nodes-8d083aa4-14cc-4cca-9a8c-e7308fb2743c">
           <attributes>
             <nvpair id="standby-8d083aa4-14cc-4cca-9a8c-e7308fb2743c" 
name="standby" value="off"/>
           </attributes>
         </instance_attributes>
       </node>
       <node id="6ca8e370-6b00-4b8c-85fe-a67da4c562ba" uname="defas1" 
type="normal"/>
     </nodes>
     <resources>
       <primitive class="ocf" id="IPaddr_172_30_4_170" provider="heartbeat" 
type="IPaddr">
         <operations>
           <op id="IPaddr_172_30_4_170_mon" interval="5s" name="monitor" 
timeout="5s"/>
         </operations>
         <instance_attributes id="IPaddr_172_30_4_170_inst_attr">
           <attributes>
             <nvpair id="IPaddr_172_30_4_170_attr_0" name="ip" 
value="172.30.4.170"/>
           </attributes>
         </instance_attributes>
       </primitive>
     </resources>
     <constraints>
       <rsc_location id="rsc_location_IPaddr_172_30_4_170" 
rsc="IPaddr_172_30_4_170">
         <rule id="prefered_location_IPaddr_172_30_4_170" score="100">
           <expression attribute="#uname" 
id="prefered_location_IPaddr_172_30_4_170_expr" operation="eq" value="defas1"/>
         </rule>
       </rsc_location>
     </constraints>
   </configuration>
   <status>
     <node_state uname="defas1" crmd="online" shutdown="0" in_ccm="true" 
ha="active" join="member" expected="member" 
id="6ca8e370-6b00-4b8c-85fe-a67da4c562ba">
       <lrm id="6ca8e370-6b00-4b8c-85fe-a67da4c562ba">
         <lrm_resources>
           <lrm_resource type="IPaddr" class="ocf" provider="heartbeat" 
id="IPaddr_172_30_4_170">
             <lrm_rsc_op operation="monitor" 
transition_key="3:0:178e89cb-1e2f-42d4-b61d-495f88443227" call_id="2" 
crm_feature_set="1.0.9" rc_code="7" interval="0" 
op_digest="13778353ce3bc00b69d81fa556ee96bc" id="IPaddr_172_30_4_170_monitor_0" 
transition_magic="4:7;3:0:178e89cb-1e2f-42d4-b61d-495f88443227" op_status="4"/>
             <lrm_rsc_op id="IPaddr_172_30_4_170_start_0" operation="start" 
crm-debug-origin="do_update_resource" 
transition_key="4:0:178e89cb-1e2f-42d4-b61d-495f88443227" 
transition_magic="0:0;4:0:178e89cb-1e2f-42d4-b61d-495f88443227" call_id="3" 
crm_feature_set="1.0.9" rc_code="0" op_status="0" interval="0" 
op_digest="13778353ce3bc00b69d81fa556ee96bc"/>
             <lrm_rsc_op id="IPaddr_172_30_4_170_monitor_5000" 
operation="monitor" crm-debug-origin="do_update_resource" 
transition_key="5:1:178e89cb-1e2f-42d4-b61d-495f88443227" 
transition_magic="0:0;5:1:178e89cb-1e2f-42d4-b61d-495f88443227" call_id="4" 
crm_feature_set="1.0.9" rc_code="0" op_status="0" interval="5000" 
op_digest="13778353ce3bc00b69d81fa556ee96bc"/>
           </lrm_resource>
         </lrm_resources>
       </lrm>
       <transient_attributes id="6ca8e370-6b00-4b8c-85fe-a67da4c562ba">
         <instance_attributes id="status-6ca8e370-6b00-4b8c-85fe-a67da4c562ba">
           <attributes>
             <nvpair 
id="status-6ca8e370-6b00-4b8c-85fe-a67da4c562ba-probe_complete" 
name="probe_complete" value="true"/>
           </attributes>
         </instance_attributes>
       </transient_attributes>
     </node_state>
     <node_state id="8d083aa4-14cc-4cca-9a8c-e7308fb2743c" uname="defas2" 
ha="active" crm-debug-origin="do_cib_replaced" crmd="online" shutdown="0" 
in_ccm="true" join="member" expected="member">
       <lrm id="8d083aa4-14cc-4cca-9a8c-e7308fb2743c">
         <lrm_resources>
           <lrm_resource id="IPaddr_172_30_4_170" type="IPaddr" class="ocf" 
provider="heartbeat">
             <lrm_rsc_op id="IPaddr_172_30_4_170_monitor_0" operation="monitor" 
crm-debug-origin="do_update_resource" 
transition_key="4:2:178e89cb-1e2f-42d4-b61d-495f88443227" 
transition_magic="0:7;4:2:178e89cb-1e2f-42d4-b61d-495f88443227" call_id="2" 
crm_feature_set="1.0.9" rc_code="7" op_status="0" interval="0" 
op_digest="13778353ce3bc00b69d81fa556ee96bc"/>
           </lrm_resource>
         </lrm_resources>
       </lrm>
       <transient_attributes id="8d083aa4-14cc-4cca-9a8c-e7308fb2743c">
         <instance_attributes id="status-8d083aa4-14cc-4cca-9a8c-e7308fb2743c">
           <attributes>
             <nvpair 
id="status-8d083aa4-14cc-4cca-9a8c-e7308fb2743c-probe_complete" 
name="probe_complete" value="true"/>
           </attributes>
         </instance_attributes>
       </transient_attributes>
     </node_state>
   </status>
 </cib>
 
use_logd yes
udpport 694
keepalive 5
deadtime 15
warntime 10
initdead 45
bcast eth1
serial /dev/ttyS0
baud 115200
ping 172.30.4.170
node defas1 defas2
crm on
auto_failback yes
respawn cluster /etc/init.d/httpd
respawn cluster /usr/lib/heartbeat/ipfail
apiauth rsc_loc uid=defas
# cibadmin -Ql
 <cib admin_epoch="0" have_quorum="true" ignore_dtd="false" num_peers="2" 
cib_feature_revision="1.3" generated="true" epoch="2" num_updates="16" 
cib-last-written="Wed Jan  2 11:54:15 2008" ccm_transition="2" 
dc_uuid="6ca8e370-6b00-4b8c-85fe-a67da4c562ba">
   <configuration>
     <crm_config>
       <cluster_property_set id="cib-bootstrap-options">
         <attributes>
           <nvpair id="cib-bootstrap-options-symmetric-cluster" 
name="symmetric-cluster" value="true"/>
           <nvpair id="cib-bootstrap-options-no-quorum-policy" 
name="no-quorum-policy" value="stop"/>
           <nvpair id="cib-bootstrap-options-default-resource-stickiness" 
name="default-resource-stickiness" value="0"/>
           <nvpair 
id="cib-bootstrap-options-default-resource-failure-stickiness" 
name="default-resource-failure-stickiness" value="0"/>
           <nvpair id="cib-bootstrap-options-stonith-enabled" 
name="stonith-enabled" value="false"/>
           <nvpair id="cib-bootstrap-options-stonith-action" 
name="stonith-action" value="reboot"/>
           <nvpair id="cib-bootstrap-options-stop-orphan-resources" 
name="stop-orphan-resources" value="true"/>
           <nvpair id="cib-bootstrap-options-stop-orphan-actions" 
name="stop-orphan-actions" value="true"/>
           <nvpair id="cib-bootstrap-options-remove-after-stop" 
name="remove-after-stop" value="false"/>
           <nvpair id="cib-bootstrap-options-short-resource-names" 
name="short-resource-names" value="true"/>
           <nvpair id="cib-bootstrap-options-transition-idle-timeout" 
name="transition-idle-timeout" value="5min"/>
           <nvpair id="cib-bootstrap-options-default-action-timeout" 
name="default-action-timeout" value="15s"/>
           <nvpair id="cib-bootstrap-options-is-managed-default" 
name="is-managed-default" value="true"/>
         </attributes>
       </cluster_property_set>
     </crm_config>
     <nodes>
       <node id="8d083aa4-14cc-4cca-9a8c-e7308fb2743c" uname="defas2" 
type="normal">
         <instance_attributes id="nodes-8d083aa4-14cc-4cca-9a8c-e7308fb2743c">
           <attributes>
             <nvpair id="standby-8d083aa4-14cc-4cca-9a8c-e7308fb2743c" 
name="standby" value="off"/>
           </attributes>
         </instance_attributes>
       </node>
       <node id="6ca8e370-6b00-4b8c-85fe-a67da4c562ba" uname="defas1" 
type="normal"/>
     </nodes>
     <resources>
       <primitive class="ocf" id="IPaddr_172_30_4_170" provider="heartbeat" 
type="IPaddr">
         <operations>
           <op id="IPaddr_172_30_4_170_mon" interval="5s" name="monitor" 
timeout="5s"/>
         </operations>
         <instance_attributes id="IPaddr_172_30_4_170_inst_attr">
           <attributes>
             <nvpair id="IPaddr_172_30_4_170_attr_0" name="ip" 
value="172.30.4.170"/>
           </attributes>
         </instance_attributes>
       </primitive>
     </resources>
     <constraints>
       <rsc_location id="rsc_location_IPaddr_172_30_4_170" 
rsc="IPaddr_172_30_4_170">
         <rule id="prefered_location_IPaddr_172_30_4_170" score="100">
           <expression attribute="#uname" 
id="prefered_location_IPaddr_172_30_4_170_expr" operation="eq" value="defas1"/>
         </rule>
       </rsc_location>
     </constraints>
   </configuration>
   <status>
     <node_state id="6ca8e370-6b00-4b8c-85fe-a67da4c562ba" uname="defas1" 
crmd="online" crm-debug-origin="do_lrm_query" shutdown="0" in_ccm="true" 
ha="active" join="member" expected="member">
       <transient_attributes id="6ca8e370-6b00-4b8c-85fe-a67da4c562ba">
         <instance_attributes id="status-6ca8e370-6b00-4b8c-85fe-a67da4c562ba">
           <attributes>
             <nvpair 
id="status-6ca8e370-6b00-4b8c-85fe-a67da4c562ba-probe_complete" 
name="probe_complete" value="true"/>
           </attributes>
         </instance_attributes>
       </transient_attributes>
       <lrm id="6ca8e370-6b00-4b8c-85fe-a67da4c562ba">
         <lrm_resources>
           <lrm_resource id="IPaddr_172_30_4_170" type="IPaddr" class="ocf" 
provider="heartbeat">
             <lrm_rsc_op id="IPaddr_172_30_4_170_monitor_0" operation="monitor" 
crm-debug-origin="build_active_RAs" 
transition_key="3:0:178e89cb-1e2f-42d4-b61d-495f88443227" 
transition_magic="4:7;3:0:178e89cb-1e2f-42d4-b61d-495f88443227" call_id="2" 
crm_feature_set="1.0.9" rc_code="7" op_status="4" interval="0" 
op_digest="13778353ce3bc00b69d81fa556ee96bc"/>
             <lrm_rsc_op id="IPaddr_172_30_4_170_start_0" operation="start" 
crm-debug-origin="build_active_RAs" 
transition_key="4:0:178e89cb-1e2f-42d4-b61d-495f88443227" 
transition_magic="0:0;4:0:178e89cb-1e2f-42d4-b61d-495f88443227" call_id="3" 
crm_feature_set="1.0.9" rc_code="0" op_status="0" interval="0" 
op_digest="13778353ce3bc00b69d81fa556ee96bc"/>
             <lrm_rsc_op id="IPaddr_172_30_4_170_monitor_5000" 
operation="monitor" crm-debug-origin="build_active_RAs" 
transition_key="5:1:178e89cb-1e2f-42d4-b61d-495f88443227" 
transition_magic="0:0;5:1:178e89cb-1e2f-42d4-b61d-495f88443227" call_id="4" 
crm_feature_set="1.0.9" rc_code="0" op_status="0" interval="5000" 
op_digest="13778353ce3bc00b69d81fa556ee96bc"/>
           </lrm_resource>
         </lrm_resources>
       </lrm>
     </node_state>
     <node_state id="8d083aa4-14cc-4cca-9a8c-e7308fb2743c" uname="defas2" 
ha="active" crm-debug-origin="do_update_resource" crmd="online" shutdown="0" 
in_ccm="true" join="member" expected="member">
       <lrm id="8d083aa4-14cc-4cca-9a8c-e7308fb2743c">
         <lrm_resources>
           <lrm_resource id="IPaddr_172_30_4_170" type="IPaddr" class="ocf" 
provider="heartbeat">
             <lrm_rsc_op id="IPaddr_172_30_4_170_monitor_0" operation="monitor" 
crm-debug-origin="do_update_resource" 
transition_key="4:2:178e89cb-1e2f-42d4-b61d-495f88443227" 
transition_magic="0:7;4:2:178e89cb-1e2f-42d4-b61d-495f88443227" call_id="2" 
crm_feature_set="1.0.9" rc_code="7" op_status="0" interval="0" 
op_digest="13778353ce3bc00b69d81fa556ee96bc"/>
           </lrm_resource>
         </lrm_resources>
       </lrm>
       <transient_attributes id="8d083aa4-14cc-4cca-9a8c-e7308fb2743c">
         <instance_attributes id="status-8d083aa4-14cc-4cca-9a8c-e7308fb2743c">
           <attributes>
             <nvpair 
id="status-8d083aa4-14cc-4cca-9a8c-e7308fb2743c-probe_complete" 
name="probe_complete" value="true"/>
           </attributes>
         </instance_attributes>
       </transient_attributes>
     </node_state>
   </status>
 </cib>
 
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to