From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3661 invoked by alias); 25 Jun 2008 08:28:16 -0000 Received: (qmail 3625 invoked by uid 9702); 25 Jun 2008 08:28:14 -0000 Date: Wed, 25 Jun 2008 08:28:00 -0000 Message-ID: <20080625082814.3608.qmail@sourceware.org> From: fabbione@sourceware.org To: cluster-cvs@sources.redhat.com, cluster-devel@redhat.com Subject: Cluster Project branch, master, updated. cluster-2.99.05-18-g39d39c6 X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: e91380a6f2743ad3ddd6f1fec1cde5a1688f1b0c X-Git-Newrev: 39d39c61e694e7d7f0869c477392e532e8088a1d Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2008-q2/txt/msg00547.txt.bz2 This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Cluster Project". http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=39d39c61e694e7d7f0869c477392e532e8088a1d The branch, master has been updated via 39d39c61e694e7d7f0869c477392e532e8088a1d (commit) via 6f456d1989c82da80d1d028954c2cd9db35e9ccc (commit) via b69b0d50c941306180f00812c38414fe5bb2cfce (commit) from e91380a6f2743ad3ddd6f1fec1cde5a1688f1b0c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 39d39c61e694e7d7f0869c477392e532e8088a1d Author: Fabio M. Di Nitto Date: Wed Jun 25 10:25:57 2008 +0200 [CONFIG] Add cluster.conf direct loader This pluing allows to load cluster.conf directly into the objdb for configuration. With this plugin there is no need to have ccsd running. To use: make sure that all nodes have the same cluster.conf form the cluster with: cman_tool -C xmlconfig join Signed-off-by: Fabio M. Di Nitto commit 6f456d1989c82da80d1d028954c2cd9db35e9ccc Author: Fabio M. Di Nitto Date: Wed Jun 25 10:24:48 2008 +0200 [CONFIG] Make sure to reset xml index in not in list mode Signed-off-by: Fabio M. Di Nitto commit b69b0d50c941306180f00812c38414fe5bb2cfce Author: Fabio M. Di Nitto Date: Wed Jun 25 09:09:41 2008 +0200 [CCS] Remove duplicate header Signed-off-by: Fabio M. Di Nitto ----------------------------------------------------------------------- Summary of changes: ccs/daemon/misc.c | 1 - config/Makefile | 2 +- config/libs/libccsconfdb/libccs.c | 2 + {bindings/perl => config/plugins}/Makefile | 2 +- {ccs/ccsais => config/plugins/xml}/Makefile | 13 +- config/plugins/xml/config.c | 295 +++++++++++++++++++++++++++ 6 files changed, 304 insertions(+), 11 deletions(-) copy {bindings/perl => config/plugins}/Makefile (85%) copy {ccs/ccsais => config/plugins/xml}/Makefile (65%) create mode 100644 config/plugins/xml/config.c diff --git a/ccs/daemon/misc.c b/ccs/daemon/misc.c index 96a7867..57eb601 100644 --- a/ccs/daemon/misc.c +++ b/ccs/daemon/misc.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/config/Makefile b/config/Makefile index b244f90..366c241 100644 --- a/config/Makefile +++ b/config/Makefile @@ -1,4 +1,4 @@ include ../make/defines.mk include $(OBJDIR)/make/passthrough.mk -SUBDIRS=libs tools +SUBDIRS=libs plugins tools diff --git a/config/libs/libccsconfdb/libccs.c b/config/libs/libccsconfdb/libccs.c index 63b65d1..ea67f8b 100644 --- a/config/libs/libccsconfdb/libccs.c +++ b/config/libs/libccsconfdb/libccs.c @@ -594,6 +594,8 @@ int _ccs_get_fullxpath(int desc, const char *query, char **rtn, int list) if (list && !strcmp(query, previous_query)) xmllistindex++; + else + xmllistindex = 0; memset(realquery, 0, PATH_MAX + 16); snprintf(realquery, PATH_MAX + 16 - 1, "/objdbmaindoc%s", query); diff --git a/bindings/perl/Makefile b/config/plugins/Makefile similarity index 85% copy from bindings/perl/Makefile copy to config/plugins/Makefile index 810b2d4..1305555 100644 --- a/bindings/perl/Makefile +++ b/config/plugins/Makefile @@ -1,4 +1,4 @@ include ../../make/defines.mk include $(OBJDIR)/make/passthrough.mk -SUBDIRS= +SUBDIRS=xml diff --git a/ccs/ccsais/Makefile b/config/plugins/xml/Makefile similarity index 65% copy from ccs/ccsais/Makefile copy to config/plugins/xml/Makefile index f3eacc7..9274336 100644 --- a/ccs/ccsais/Makefile +++ b/config/plugins/xml/Makefile @@ -1,30 +1,27 @@ -TARGET= config_ccs.lcrso +TARGET= config_xml.lcrso LCRSOT=$(TARGET) -all: depends ${TARGET} +all: ${TARGET} -include ../../make/defines.mk +include ../../../make/defines.mk include $(OBJDIR)/make/cobj.mk include $(OBJDIR)/make/clean.mk include $(OBJDIR)/make/install.mk include $(OBJDIR)/make/uninstall.mk CFLAGS += -fPIC -CFLAGS += -I$(S)/../libccscompat +CFLAGS += `xml2-config --cflags` CFLAGS += -I${cmanincdir}/../daemon CFLAGS += -I${incdir} -LDFLAGS += -L../libccscompat -lccscompat +LDFLAGS += `xml2-config --libs` OBJS= config.o ${TARGET}: ${OBJS} $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS) -depends: - $(MAKE) -C ../libccscompat all - clean: generalclean -include $(OBJS:.o=.d) diff --git a/config/plugins/xml/config.c b/config/plugins/xml/config.c new file mode 100644 index 0000000..1fd3e69 --- /dev/null +++ b/config/plugins/xml/config.c @@ -0,0 +1,295 @@ +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "logging.h" + +static int xml_readconfig(struct objdb_iface_ver0 *objdb, char **error_string); +static int init_config(struct objdb_iface_ver0 *objdb, char *error_string); +static char error_reason[1024]; +static int xmllistindex = 0; +static char previous_query[PATH_MAX]; + +/* + * Exports the interface for the service + */ + +static struct config_iface_ver0 xmlconfig_iface_ver0 = { + .config_readconfig = xml_readconfig +}; + +static struct lcr_iface ifaces_ver0[2] = { + { + .name = "xmlconfig", + .version = 0, + .versions_replace = 0, + .versions_replace_count = 0, + .dependencies = 0, + .dependency_count = 0, + .constructor = NULL, + .destructor = NULL, + .interfaces = NULL, + } +}; + +static struct lcr_comp xml_comp_ver0 = { + .iface_count = 1, + .ifaces = ifaces_ver0, +}; + +__attribute__ ((constructor)) static void xml_comp_register(void) { + lcr_interfaces_set(&ifaces_ver0[0], &xmlconfig_iface_ver0); + lcr_component_register(&xml_comp_ver0); +}; + +static char *do_xml_query(xmlXPathContextPtr ctx, char *query, int list) { + xmlXPathObjectPtr obj = NULL; + xmlNodePtr node = NULL; + char *rtn = NULL; + int size = 0, nnv = 0; + + if (list && !strcmp(query, previous_query)) + xmllistindex++; + else + xmllistindex = 0; + + obj = xmlXPathEvalExpression((xmlChar *)query, ctx); + if (obj && obj->nodesetval && (obj->nodesetval->nodeNr > 0)) { + if (xmllistindex >= obj->nodesetval->nodeNr) { + xmllistindex = 0; + goto fail; + } + + node = obj->nodesetval->nodeTab[xmllistindex]; + if (!node) + goto fail; + + if (((node->type == XML_ATTRIBUTE_NODE) && strstr(query, "@*")) || + ((node->type == XML_ELEMENT_NODE) && strstr(query, "child::*"))) { + if (node->children && node->children->content) + size = strlen((char *)node->children->content) + + strlen((char *)node->name)+2; + else + size = strlen((char *)node->name)+2; + + nnv = 1; + } else { + if (node->children && node->children->content) + size = strlen((char *)node->children->content)+1; + else + goto fail; + } + + rtn = malloc(size); + if (!rtn) + goto fail; + + if (nnv) + sprintf(rtn, "%s=%s", node->name, node->children ? (char *)node->children->content:""); + else + sprintf(rtn, "%s", node->children ? node->children->content : node->name); + + if(list) + strncpy(previous_query, query, PATH_MAX-1); + } + +fail: + if (obj) + xmlXPathFreeObject(obj); + + return rtn; +} + +static int should_alloc(xmlXPathContextPtr ctx, char *key) +{ + int keyerror = 1, childerr = 1; + char path[256]; + char *str = NULL; + + sprintf(path, "%s/@*", key); + str = do_xml_query(ctx, path, 1); + if (str) { + keyerror = 0; + free(str); + str = NULL; + } + + sprintf(path, "%s/child::*", key); + str = do_xml_query(ctx, path, 1); + if(str) { + childerr = 0; + free(str); + str = NULL; + } + + if (childerr && keyerror) + return 0; + + return 1; +} + +static int read_config_for(xmlXPathContextPtr ctx, struct objdb_iface_ver0 *objdb, unsigned int parent, + char *object, char *key, int always_create) +{ + char *str; + unsigned int object_handle = 0; + char path[256]; + int gotcount = 0; + char *subkeys[52]; + int subkeycount = 0; + int i; + + if (should_alloc(ctx, key) || always_create) { + objdb->object_create(parent, &object_handle, object, strlen(object)); + } + + memset(previous_query, 0, PATH_MAX); + sprintf(path, "%s/@*", key); + /* Get the keys */ + for (;;) + { + char *equal; + + str = do_xml_query(ctx, path, 1); + if (!str) + break; + + equal = strchr(str, '='); + if (equal) + { + *equal = 0; + objdb->object_key_create(object_handle, str, strlen(str), + equal+1, strlen(equal+1)+1); + gotcount++; + } + free(str); + } + + /* Now look for sub-objects. + CCS can't cope with recursive queries so we have to store the result of + the subkey search */ + memset(previous_query, 0, PATH_MAX); + memset(subkeys, 0, sizeof(subkeys)); + sprintf(path, "%s/child::*", key); + for (;;) + { + char *equal; + + str = do_xml_query(ctx, path, 1); + if (!str) + break; + + /* CCS returns duplicate values for the numbered entries we use below. + eg. if there are 4 entries it will return + clusternode= + clusternode= + clusternode= + clusternode= + which is not helpful to us cos we retrieve them as + clusternode[1] + clusternode[2] + clusternode[3] + clusternode[4] + so we just store unique keys. + */ + equal = strchr(str, '='); + if (equal) + *equal = 0; + + if (subkeycount > 0 && strcmp(str, subkeys[subkeycount-1]) == 0) + { + free(str); + break; + } + subkeys[subkeycount++] = str; + } + + for (i=0; i