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: include by andrew from
([email protected])
2. Linux-HA CVS: lib by andrew from
([email protected])
3. Linux-HA CVS: crm by andrew from
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Fri, 4 Aug 2006 03:47:21 -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:
Utility function for finding all XML nodes matching the supplied criteria
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/crm/common/xml.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -3 -r1.49 -r1.50
--- xml.h 18 Jul 2006 06:16:09 -0000 1.49
+++ xml.h 4 Aug 2006 09:47:21 -0000 1.50
@@ -1,4 +1,4 @@
-/* $Id: xml.h,v 1.49 2006/07/18 06:16:09 andrew Exp $ */
+/* $Id: xml.h,v 1.50 2006/08/04 09:47:21 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
*
@@ -236,7 +236,9 @@
extern gboolean update_xml_child(crm_data_t *child, crm_data_t *to_update);
-extern gboolean find_xml_child(crm_data_t *child, const char *tag, const char
*id);
+extern int find_xml_children(
+ crm_data_t **children, crm_data_t *root,
+ const char *tag, const char *field, const char *value);
/*
*
------------------------------
Message: 2
Date: Fri, 4 Aug 2006 03:47:22 -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:
Utility function for finding all XML nodes matching the supplied criteria
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/crm/common/xml.c,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -3 -r1.101 -r1.102
--- xml.c 18 Jul 2006 06:16:09 -0000 1.101
+++ xml.c 4 Aug 2006 09:47:21 -0000 1.102
@@ -1,4 +1,4 @@
-/* $Id: xml.c,v 1.101 2006/07/18 06:16:09 andrew Exp $ */
+/* $Id: xml.c,v 1.102 2006/08/04 09:47:21 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
*
@@ -2096,31 +2096,32 @@
}
-gboolean
-find_xml_child(crm_data_t *child, const char *tag, const char *id)
+int
+find_xml_children(crm_data_t **children, crm_data_t *root,
+ const char *tag, const char *field, const char *value)
{
- gboolean match_found = TRUE;
+ int match_found = 0;
- CRM_CHECK(child != NULL, return FALSE);
+ CRM_CHECK(root != NULL, return FALSE);
+ CRM_CHECK(children != NULL, return FALSE);
- if(safe_str_neq(tag, crm_element_name(child))) {
- match_found = FALSE;
+ if(tag != NULL && safe_str_neq(tag, crm_element_name(root))) {
- } else if(safe_str_neq(id, ID(child))) {
- match_found = FALSE;
+ } else if(value != NULL
+ && safe_str_neq(value, crm_element_value(root, field))) {
- } else if(match_found) {
- crm_err("Update match found for <%s id=%s.../>", tag, id);
- crm_log_xml_debug(child, __FUNCTION__);
+ } else {
+ if(*children == NULL) {
+ *children = create_xml_node(NULL, __FUNCTION__);
+ }
+ add_node_copy(*children, root);
+ match_found = 1;
}
xml_child_iter(
- child, child_of_child,
- /* only find the first one */
- if(match_found) {
- break;
- }
- match_found = find_xml_child(child_of_child, tag, id);
+ root, child,
+ match_found += find_xml_children(
+ children, child, tag, field, value);
);
return match_found;
------------------------------
Message: 3
Date: Fri, 4 Aug 2006 03:50:02 -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/admin
Modified Files:
crm_resource.c
Log Message:
If at all possible, figure out which resource attribute entry the user is
trying to change.
If there are multiple matches, display those that match and optionally include
suggestions for what to do next.
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/admin/crm_resource.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -3 -r1.44 -r1.45
--- crm_resource.c 18 Jul 2006 06:15:54 -0000 1.44
+++ crm_resource.c 4 Aug 2006 09:50:02 -0000 1.45
@@ -1,4 +1,4 @@
-/* $Id: crm_resource.c,v 1.44 2006/07/18 06:15:54 andrew Exp $ */
+/* $Id: crm_resource.c,v 1.45 2006/08/04 09:50:02 andrew Exp $ */
/*
* Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
@@ -207,12 +207,18 @@
cib_t *cib, pe_working_set_t *data_set)
{
int rc = cib_ok;
+ int matches = 0;
int cib_options = cib_sync_call;
+
+ char *local_attr_id = NULL;
+ char *local_attr_set = NULL;
+
crm_data_t *xml_top = NULL;
crm_data_t *xml_obj = NULL;
+ crm_data_t *nv_children = NULL;
+ crm_data_t *set_children = NULL;
+
resource_t *rsc = pe_find_resource(data_set->resources, rsc_id);
- char *local_attr_id = NULL;
- char *local_attr_set = NULL;
if(do_force) {
crm_debug("Forcing...");
@@ -223,25 +229,105 @@
return cib_NOTEXISTS;
}
- if(attr_set == NULL) {
- local_attr_set = crm_strdup(rsc->id);
- attr_set = local_attr_set;
+ /* filter by set name */
+ if(attr_set != NULL) {
+ matches = find_xml_children(
+ &set_children, rsc->xml,
+ XML_TAG_ATTR_SETS, XML_ATTR_ID, attr_set);
+ crm_log_xml_debug(set_children, "search by set:");
}
+ matches = 0;
if(attr_id == NULL) {
- local_attr_id = crm_concat(attr_set, attr_name, '-');
- attr_id = local_attr_id;
+ matches = find_xml_children(
+ &nv_children, set_children?set_children:rsc->xml,
+ XML_CIB_TAG_NVPAIR, XML_NVPAIR_ATTR_NAME, attr_name);
+ crm_log_xml_debug(nv_children, "search by name:");
+
+ } else if(attr_id != NULL) {
+ matches = find_xml_children(
+ &nv_children, set_children?set_children:rsc->xml,
+ XML_CIB_TAG_NVPAIR, XML_ATTR_ID, attr_id);
+ crm_log_xml_debug(nv_children, "search by id:");
}
+
+
+ if(matches > 1) {
+ fprintf(stderr, "Multiple attributes match name=%s for the
resource %s:\n",
+ attr_name, rsc->id);
+
+ if(set_children == NULL) {
+ free_xml(set_children);
+ set_children = NULL;
+ find_xml_children(
+ &set_children, rsc->xml,
+ XML_TAG_ATTR_SETS, NULL, NULL);
+ xml_child_iter(
+ set_children, set,
+ free_xml(nv_children);
+ nv_children = NULL;
+ find_xml_children(
+ &nv_children, set,
+ XML_CIB_TAG_NVPAIR,
XML_NVPAIR_ATTR_NAME, attr_name);
+ xml_child_iter(
+ nv_children, child,
+ fprintf(stderr," Set: %s,\tValue:
%s,\tID: %s\n",
+ ID(set),
+ crm_element_value(child,
XML_NVPAIR_ATTR_VALUE),
+ ID(child));
+ );
+ );
+
+ } else {
+ xml_child_iter(
+ nv_children, child,
+ fprintf(stderr," ID: %s, Value: %s\n",
ID(child),
+ crm_element_value(child,
XML_NVPAIR_ATTR_VALUE));
+ );
+ }
+
+ if(BE_QUIET == FALSE) {
+ fprintf(stderr, "\nThe following text can be suppressed
with the -Q option:\n");
+ if(attr_set == NULL) {
+ fprintf(stderr, " * To choose an existing
entry to change, please supply one of the set names above using the -s
option.\n");
+ } else {
+ fprintf(stderr, " * To choose an existing
entry to change, please supply one of the IDs above using the -i option.\n");
+ }
+ fprintf(stderr, " * To create a new value with a
default ID, please supply a different set name using the -s option.\n");
+
+ fprintf(stderr, "You can also use --query-xml to
display the complete resource definition.\n");
+ }
+
+ return cib_unknown;
+
+ } else if(matches == 0) {
+ if(attr_set == NULL) {
+ local_attr_set = crm_strdup(rsc->id);
+ attr_set = local_attr_set;
+ }
+ if(attr_id == NULL) {
+ local_attr_id = crm_concat(attr_set, attr_name, '-');
+ attr_id = local_attr_id;
+ }
+
+ xml_top = create_xml_node(NULL, crm_element_name(rsc->xml));
+ crm_xml_add(xml_top, XML_ATTR_ID, rsc->id);
+
+ xml_obj = create_xml_node(xml_top, XML_TAG_ATTR_SETS);
+ crm_xml_add(xml_obj, XML_ATTR_ID, attr_set);
+
+ xml_obj = create_xml_node(xml_obj, XML_TAG_ATTRS);
+ xml_obj = create_xml_node(xml_obj, XML_CIB_TAG_NVPAIR);
- xml_top = create_xml_node(NULL, crm_element_name(rsc->xml));
- crm_xml_add(xml_top, XML_ATTR_ID, rsc->id);
-
- xml_obj = create_xml_node(xml_top, XML_TAG_ATTR_SETS);
- crm_xml_add(xml_obj, XML_ATTR_ID, attr_set);
-
- xml_obj = create_xml_node(xml_obj, XML_TAG_ATTRS);
-
- xml_obj = create_xml_node(xml_obj, XML_CIB_TAG_NVPAIR);
+ } else {
+ if(attr_id == NULL) {
+ /* extract it */
+ xml_child_iter(nv_children, child, attr_id = ID(child));
+ }
+ xml_obj = create_xml_node(NULL, XML_CIB_TAG_NVPAIR);
+ xml_top = xml_obj;
+ }
+
crm_xml_add(xml_obj, XML_ATTR_ID, attr_id);
crm_xml_add(xml_obj, XML_NVPAIR_ATTR_NAME, attr_name);
crm_xml_add(xml_obj, XML_NVPAIR_ATTR_VALUE, attr_value);
------------------------------
_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
End of Linux-ha-cvs Digest, Vol 33, Issue 3
*******************************************