Send Linux-ha-cvs mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: lib by andrew from 
      ([email protected])
   2. Linux-HA CVS: include by andrew from 
      ([email protected])
   3. Linux-HA CVS: include by andrew from 
      ([email protected])
   4. Linux-HA CVS: crm by andrew from 
      ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Fri,  5 May 2006 06:54:34 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/crm/common


Modified Files:
        xml.c 


Log Message:
Allow replace to work on any object in the CIB not only entire sections

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/xml.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -3 -r1.75 -r1.76
--- xml.c       2 May 2006 13:03:18 -0000       1.75
+++ xml.c       5 May 2006 12:54:33 -0000       1.76
@@ -1,4 +1,4 @@
-/* $Id: xml.c,v 1.75 2006/05/02 13:03:18 andrew Exp $ */
+/* $Id: xml.c,v 1.76 2006/05/05 12:54:33 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -2020,31 +2020,37 @@
 }
 
 gboolean
-delete_xml_child(crm_data_t *parent, crm_data_t *child, crm_data_t *to_delete)
+replace_xml_child(crm_data_t *parent, crm_data_t *child, crm_data_t *update, 
gboolean delete_only)
 {
        gboolean can_delete = FALSE;
        const char *right_val = NULL;
        
        CRM_CHECK(child != NULL, return FALSE);
-       CRM_CHECK(to_delete != NULL, return FALSE);
+       CRM_CHECK(update != NULL, return FALSE);
        
-       if(safe_str_eq(crm_element_name(to_delete), crm_element_name(child))) {
+       if(safe_str_eq(ID(child), ID(update))) {
                can_delete = TRUE;
        }
-       xml_prop_iter(to_delete, prop_name, left_value,
-                     if(can_delete == FALSE) {
-                             break;
-                     }
-                     right_val = crm_element_value(child, prop_name);
-                     if(safe_str_neq(left_value, right_val)) {
-                             can_delete = FALSE;
-                     }
-               );
+       if(safe_str_neq(crm_element_name(update), crm_element_name(child))) {
+               can_delete = FALSE;
+       }
+       if(can_delete && delete_only) {
+               xml_prop_iter(update, prop_name, left_value,
+                             right_val = crm_element_value(child, prop_name);
+                             if(safe_str_neq(left_value, right_val)) {
+                                     can_delete = FALSE;
+                             }
+                       );
+       }
        
        if(can_delete && parent != NULL) {
                crm_log_xml_debug(child, "Delete match found...");
                cl_msg_remove_value(parent, child);
                child = NULL;
+               if(delete_only == FALSE) {
+                       add_node_copy(parent, update);
+               }
+               return TRUE;
                
        } else if(can_delete) {
                crm_log_xml_debug(child, "Cannot delete the search root");
@@ -2058,7 +2064,7 @@
                if(can_delete) {
                        break;
                }
-               can_delete = delete_xml_child(child, child_of_child, to_delete);
+               can_delete = replace_xml_child(child, child_of_child, update, 
delete_only);
                );
        
        return can_delete;




------------------------------

Message: 2
Date: Fri,  5 May 2006 06:54:34 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: include by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : include

Dir     : linux-ha/include/crm/common


Modified Files:
        xml.h 


Log Message:
Allow replace to work on any object in the CIB not only entire sections

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/crm/common/xml.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -3 -r1.44 -r1.45
--- xml.h       4 Apr 2006 13:08:52 -0000       1.44
+++ xml.h       5 May 2006 12:54:33 -0000       1.45
@@ -1,4 +1,4 @@
-/* $Id: xml.h,v 1.44 2006/04/04 13:08:52 andrew Exp $ */
+/* $Id: xml.h,v 1.45 2006/05/05 12:54:33 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -228,8 +228,8 @@
 
 extern void crm_set_element_parent(crm_data_t *data, crm_data_t *parent);
 
-extern gboolean delete_xml_child(
-       crm_data_t *parent, crm_data_t *child, crm_data_t *to_delete);
+extern gboolean replace_xml_child(
+       crm_data_t *parent, crm_data_t *child, crm_data_t *update, gboolean 
delete_only);
 
 extern gboolean update_xml_child(crm_data_t *child, crm_data_t *to_update);
 




------------------------------

Message: 3
Date: Fri,  5 May 2006 06:55:41 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: include by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : include

Dir     : linux-ha/include/crm


Modified Files:
        msg_xml.h 


Log Message:
The concatinated version of a resource's name

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/crm/msg_xml.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -3 -r1.52 -r1.53
--- msg_xml.h   18 Apr 2006 11:15:37 -0000      1.52
+++ msg_xml.h   5 May 2006 12:55:41 -0000       1.53
@@ -1,4 +1,4 @@
-/* $Id: msg_xml.h,v 1.52 2006/04/18 11:15:37 andrew Exp $ */
+/* $Id: msg_xml.h,v 1.53 2006/05/05 12:55:41 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -54,6 +54,7 @@
 #define XML_ATTR_VERSION               "version"
 #define XML_ATTR_DESC                  "description"
 #define XML_ATTR_ID                    "id"
+#define XML_ATTR_ID_LONG               "long-id"
 #define XML_ATTR_TYPE                  "type"
 #define XML_ATTR_FILTER_TYPE           "type_filter"
 #define XML_ATTR_FILTER_ID             "id_filter"




------------------------------

Message: 4
Date: Fri,  5 May 2006 07:08:49 -0600 (MDT)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: crm by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : crm

Dir     : linux-ha/crm/crmd


Modified Files:
        lrm.c 


Log Message:
* Default to short resource names
  - calculate both and supply both the TE/CRMd
  - the CRMd will look for either form in the LRM and if neither are found
    will use the short version
* Fix cloned groups
  - call the internal_constraints() for each child resource
  - make sure the long resource name is calculated before the child has
    finished begin created
* Dont create recurring actions for nodes that are offline
  - less clutter in the PE output
* Create cancel operations with a key that includes "cancel" and the
  recurring interval (rather than re-use the key from the operation being
  cancelled).  We can do this because the CRMd now calculates the key based
  on the form of the resource id it found.
* Update test cases

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/crmd/lrm.c,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -3 -r1.190 -r1.191
--- lrm.c       23 Apr 2006 18:13:28 -0000      1.190
+++ lrm.c       5 May 2006 13:08:49 -0000       1.191
@@ -60,7 +60,7 @@
 gboolean process_lrm_event(lrm_op_t *op);
 
 enum crmd_fsa_input do_lrm_rsc_op(
-       lrm_rsc_t *rsc, char *rid, const char *operation,
+       lrm_rsc_t *rsc, const char *operation,
        crm_data_t *msg, HA_Message *request);
 
 enum crmd_fsa_input do_fake_lrm_op(gpointer data);
@@ -507,7 +507,7 @@
 #endif
                args_xml = create_xml_node(args_parent, XML_TAG_PARAMS);
                g_hash_table_foreach(op->params, hash2field, args_xml);
-               filter_action_parameters(args_xml);
+               filter_action_parameters(args_xml, caller_version);
                digest = calculate_xml_digest(args_xml, TRUE);
                crm_xml_add(xml_op, XML_LRM_ATTR_OP_DIGEST, digest);
                if(args_parent == NULL) {
@@ -729,25 +729,67 @@
        }
 }
 
-/*
-static gboolean
-is_active(const char *rsc_id) 
+static lrm_rsc_t *
+get_lrm_resource(crm_data_t *resource, crm_data_t *param_list, gboolean 
do_create)
 {
-       char *stop_id = NULL;
-       const char *last_op = NULL;
-       gboolean is_active = TRUE;      
-
-       last_op = g_hash_table_lookup(resources, rsc_id);
-       stop_id = generate_op_key(rsc_id, CRMD_ACTION_STOP, 0);
-                       
-       if(safe_str_eq(last_op, stop_id)) {
-               is_active = FALSE;
+       char rid[64];
+       lrm_rsc_t *rsc = NULL;
+       const char *short_id = ID(resource);
+       const char *long_id = crm_element_value(resource, XML_ATTR_ID_LONG);
+               
+       crm_debug_2("Retrieving %s from the LRM.", short_id);
+       CRM_CHECK(short_id != NULL, return NULL);
+       
+       if(rsc == NULL) {
+               /* check if its already there (short name) */
+               strncpy(rid, short_id, 64);
+               rid[63] = 0;
+               rsc = fsa_lrm_conn->lrm_ops->get_rsc(fsa_lrm_conn, rid);
        }
+       if(rsc == NULL && long_id != NULL) {
+               /* try the long name instead */
+               strncpy(rid, long_id, 64);
+               rid[63] = 0;
+               rsc = fsa_lrm_conn->lrm_ops->get_rsc(fsa_lrm_conn, rid);
+       }
+
+       if(rsc == NULL && do_create) {
+               /* add it to the LRM */
+               const char *type = crm_element_value(resource, XML_ATTR_TYPE);
+               const char *class = crm_element_value(resource, 
XML_AGENT_ATTR_CLASS);
+               const char *provider = crm_element_value(resource, 
XML_AGENT_ATTR_PROVIDER);
+               GHashTable *params = xml2list(param_list);
+
+               CRM_CHECK(class != NULL, return NULL);
+               CRM_CHECK(type != NULL, return NULL);
+
+               crm_debug("Adding rsc %s before operation", short_id);
+               strncpy(rid, short_id, 64);
+               rid[63] = 0;
 
-       crm_free(stop_id);
-       return is_active;
+#if CRM_DEPRECATED_SINCE_2_0_3
+               if(param_list != NULL) {
+                       if(g_hash_table_lookup(
+                                  params, XML_ATTR_CRM_VERSION) == NULL) {
+                               g_hash_table_destroy(params);
+                               params = xml2list_202(param_list);
+                       }
+               }
+#endif
+               fsa_lrm_conn->lrm_ops->add_rsc(
+                       fsa_lrm_conn, rid, class, type, provider, params);
+               
+               rsc = fsa_lrm_conn->lrm_ops->get_rsc(fsa_lrm_conn, rid);
+               g_hash_table_destroy(params);
+
+               if(rsc == NULL) {
+                       fsa_data_t *msg_data = NULL;
+                       crm_err("Could not add resource %s to LRM", rid);
+                       register_fsa_error(C_FSA_INTERNAL, I_FAIL, NULL);
+               }
+       }
+       return rsc;
 }
-*/
 
 /*      A_LRM_INVOKE   */
 enum crmd_fsa_input
@@ -813,44 +855,31 @@
                            fsa_our_uuid, NULL, NULL, CRM_OP_PROBED, probed);
 
        } else if(operation != NULL) {
-               char rid[64];
                lrm_rsc_t *rsc = NULL;
-               const char *id_from_cib = NULL;
+               crm_data_t *params = NULL;
                crm_data_t *xml_rsc = find_xml_node(
                        input->xml, XML_CIB_TAG_RESOURCE, TRUE);
 
-               CRM_DEV_ASSERT(xml_rsc != NULL);
-               if(crm_assert_failed) {
-                       crm_log_xml_err(input->xml, "Bad resource");
-                       return I_NULL;
-               }
-               
-               id_from_cib = crm_element_value(xml_rsc, XML_ATTR_ID);
-               CRM_DEV_ASSERT(id_from_cib != NULL);
-               if(crm_assert_failed) {
-                       crm_err("No value for %s in %s",
-                               XML_ATTR_ID, crm_element_name(xml_rsc));
-                       crm_log_xml_err(input->xml, "Bad command");
-                       return I_NULL;
-               }
+               CRM_CHECK(xml_rsc != NULL, return I_NULL);
                
                /* only the first 16 chars are used by the LRM */
-               strncpy(rid, id_from_cib, 64);
-               rid[63] = 0;
 
-               crm_debug_2("Retrieving %s from the LRM.", rid);
-               rsc = fsa_lrm_conn->lrm_ops->get_rsc(fsa_lrm_conn, rid);
+               params  = find_xml_node(input->xml, XML_TAG_ATTRS,TRUE);
+               rsc = get_lrm_resource(xml_rsc, params, TRUE);
+
+               if(rsc == NULL) {
+                       crm_err("Invalid resource definition");
+                       crm_log_xml_err(input->xml, "Bad command");
 
-               if(safe_str_eq(operation, CRMD_ACTION_CANCEL)) {
+               } else if(safe_str_eq(operation, CRMD_ACTION_CANCEL)) {
                        lrm_op_t* op = NULL;
-                       crm_data_t *params = NULL;
-                       const char *op_key = NULL;
+                       char *op_key = NULL;
                        const char *op_task = NULL;
+                       const char *op_interval = NULL;
 
                        crm_log_xml_debug(input->xml, "CancelOp");
 
-                       op_key  = crm_element_value(xml_rsc, "operation_key");
-                       params  = find_xml_node(input->xml, XML_TAG_ATTRS,TRUE);
+                       op_interval = crm_element_value(params, "interval");
                        
                        if(params != NULL) {
                                op_task = crm_element_value(
@@ -861,60 +890,57 @@
                                }
 #endif
                        }
-                       CRM_CHECK(params != NULL
-                                 && op_task != NULL
-                                 && op_key != NULL,
-                                 return I_NULL);
+                       CRM_CHECK(params != NULL, return I_NULL);
+                       CRM_CHECK(op_task != NULL, return I_NULL);
+                       CRM_CHECK(op_interval != NULL, return I_NULL);
 
-                       op = construct_op(input->xml, id_from_cib, op_task);
-                       
+                       op = construct_op(input->xml, rsc->id, op_task);
                        CRM_ASSERT(op != NULL);
-                       if(op_key == NULL) {
-                               crm_err("No operation to cancel");
-                               crm_log_message(LOG_ERR, input->msg);
-                               
-                       } else if(rsc != NULL) {
-                               cancel_monitor(rsc, op_key);
-                       }
+                       op_key = generate_op_key(
+                               rsc->id,op_task,crm_parse_int(op_interval,"0"));
+
+                       cancel_monitor(rsc, op_key);
                        
                        op->op_status = LRM_OP_DONE;
                        op->rc = EXECRA_OK;
-                       send_direct_ack(from_host, from_sys, op, id_from_cib);
+                       send_direct_ack(from_host, from_sys, op, rsc->id);
+                       crm_free(op_key);
                        free_lrm_op(op);                        
                        
                } else if(safe_str_eq(operation, CRMD_ACTION_DELETE)) {
                        int rc = HA_OK;
                        lrm_op_t* op = NULL;
 
-                       op = construct_op(input->xml, id_from_cib, operation);
+                       op = construct_op(input->xml, rsc->id, operation);
                        CRM_ASSERT(op != NULL);
                        op->op_status = LRM_OP_DONE;
                        op->rc = EXECRA_OK;
 
                        if(rsc == NULL) {
                                crm_debug("Resource %s was already removed",
-                                        id_from_cib);
+                                        rsc->id);
 
                        } else {
                                crm_info("Removing resource %s from the LRM",
                                         rsc->id);
                                rc = fsa_lrm_conn->lrm_ops->delete_rsc(
-                                       fsa_lrm_conn, rid);
+                                       fsa_lrm_conn, rsc->id);
                                if(rc != HA_OK) {
                                        crm_err("Failed to remove resource %s",
-                                               rid);
+                                               rsc->id);
                                        op->op_status = LRM_OP_ERROR;
                                        op->rc = EXECRA_UNKNOWN_ERROR;
                                }
                        }
 
-                       send_direct_ack(from_host, from_sys, op, id_from_cib);
+                       send_direct_ack(from_host, from_sys, op, rsc->id);
                        free_lrm_op(op);                        
                        
-               } else {
+               } else if(rsc != NULL) {
                        next_input = do_lrm_rsc_op(
-                               rsc, rid, operation, input->xml, input->msg);
+                               rsc, operation, input->xml, input->msg);
                }
+               
                lrm_free_rsc(rsc);
                
        } else {
@@ -1069,42 +1095,19 @@
        free_xml(update);
 }
 
+
 enum crmd_fsa_input
-do_lrm_rsc_op(lrm_rsc_t *rsc, char *rid, const char *operation,
+do_lrm_rsc_op(lrm_rsc_t *rsc, const char *operation,
              crm_data_t *msg, HA_Message *request)
 {
        int call_id  = 0;
        char *op_id  = NULL;
        lrm_op_t* op = NULL;
 
-       const char *type = NULL;
-       const char *class = NULL;
-       const char *provider = NULL;
-       const char *transition = NULL;
-       
-       GHashTable *params   = NULL;
        fsa_data_t *msg_data = NULL;
+       const char *transition = NULL;  
 
-       CRM_DEV_ASSERT(rid != NULL);
-       
-       if(rsc != NULL) {
-               class = rsc->class;
-               type = rsc->type;
-
-       } else if(msg != NULL) {
-               crm_data_t *xml_rsc = find_xml_node(
-                       msg, XML_CIB_TAG_RESOURCE, TRUE);
-
-               class = crm_element_value(xml_rsc, XML_AGENT_ATTR_CLASS);
-               CRM_DEV_ASSERT(class != NULL);
-               if(crm_assert_failed) { return I_NULL; }
-               
-               type = crm_element_value(xml_rsc, XML_ATTR_TYPE);
-               CRM_DEV_ASSERT(type != NULL);
-               if(crm_assert_failed) { return I_NULL; }
-
-               provider = crm_element_value(xml_rsc, XML_AGENT_ATTR_PROVIDER);
-       }
+       CRM_CHECK(rsc != NULL, return I_NULL);
        
        if(msg != NULL) {
                transition = crm_element_value(msg, XML_ATTR_TRANSITION_KEY);
@@ -1114,37 +1117,6 @@
                }
        }
 
-       if(rsc == NULL) {
-               /* check if its already there */
-               rsc = fsa_lrm_conn->lrm_ops->get_rsc(fsa_lrm_conn, rid);
-       }
-
-       if(rsc == NULL) {
-               /* add it to the list */
-               crm_debug("adding rsc %s before operation", rid);
-               if(msg != NULL) {
-                       params = xml2list(msg);
-#if CRM_DEPRECATED_SINCE_2_0_3
-                       if(g_hash_table_lookup(
-                                  params, XML_ATTR_CRM_VERSION) == NULL) {
-                               g_hash_table_destroy(params);
-                               params = xml2list_202(msg);
-                       }
-#endif
-               }
-               fsa_lrm_conn->lrm_ops->add_rsc(
-                       fsa_lrm_conn, rid, class, type, provider, params);
-               
-               rsc = fsa_lrm_conn->lrm_ops->get_rsc(fsa_lrm_conn, rid);
-               g_hash_table_destroy(params);
-       }
-       
-       if(rsc == NULL) {
-               crm_err("Could not add resource %s to LRM", rid);
-               register_fsa_error(C_FSA_INTERNAL, I_FAIL, NULL);
-               return I_NULL;
-       }
-
        /* stop the monitor before stopping the resource */
        if(safe_str_eq(operation, CRMD_ACTION_STOP)) {
                g_hash_table_foreach(monitors, stop_recurring_action, rsc);
@@ -1155,13 +1127,13 @@
        /* now do the op */
        op = construct_op(msg, rsc->id, operation);
        crm_info("Performing op %s on %s (interval=%dms, key=%s)",
-                operation, rid, op->interval, transition);
+                operation, rsc->id, op->interval, transition);
 
        if((AM_I_DC == FALSE && fsa_state != S_NOT_DC)
           || (AM_I_DC && fsa_state != S_TRANSITION_ENGINE)) {
                if(safe_str_neq(operation, CRMD_ACTION_STOP)) {
                        crm_info("Discarding attempt to perform action %s on %s"
-                                " in state %s", operation, rid,
+                                " in state %s", operation, rsc->id,
                                 fsa_state2string(fsa_state));
                        op->rc = 99;
                        op->op_status = LRM_OP_ERROR;
@@ -1187,7 +1159,8 @@
        call_id = rsc->ops->perform_op(rsc, op);
 
        if(call_id <= 0) {
-               crm_err("Operation %s on %s failed: %d",operation,rid,call_id);
+               crm_err("Operation %s on %s failed: %d",
+                       operation, rsc->id, call_id);
                register_fsa_error(C_FSA_INTERNAL, I_FAIL, NULL);
 
        } else if(op->interval > 0) {




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 30, Issue 10
********************************************

Reply via email to