From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15088 invoked by alias); 3 Sep 2009 12:34:02 -0000 Received: (qmail 15082 invoked by alias); 3 Sep 2009 12:34:02 -0000 X-SWARE-Spam-Status: No, hits=0.6 required=5.0 tests=AWL,BAYES_20,J_CHICKENPOX_31,J_CHICKENPOX_72,J_CHICKENPOX_73,SPF_HELO_PASS,ZMIde_GENERICSPAM1 X-Spam-Status: No, hits=0.6 required=5.0 tests=AWL,BAYES_20,J_CHICKENPOX_31,J_CHICKENPOX_72,J_CHICKENPOX_73,SPF_HELO_PASS,ZMIde_GENERICSPAM1 X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - config: preliminary support for config validation To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: 77d871cbdd4722f91a50b374dccf6e39a3b3c9e7 X-Git-Newrev: 8a7f5a96f6838df9b862f741559dc58d0675adc2 From: "Fabio M. Di Nitto" Message-Id: <20090903123309.0AF9A1201A8@lists.fedorahosted.org> Date: Thu, 03 Sep 2009 12:34:00 -0000 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 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: 2009-q3/txt/msg00291.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=8a7f5a96f6838df9b862f741559dc58d0675adc2 Commit: 8a7f5a96f6838df9b862f741559dc58d0675adc2 Parent: 77d871cbdd4722f91a50b374dccf6e39a3b3c9e7 Author: Fabio M. Di Nitto AuthorDate: Thu Sep 3 14:29:35 2009 +0200 Committer: Fabio M. Di Nitto CommitterDate: Thu Sep 3 14:29:35 2009 +0200 config: preliminary support for config validation add ccs_config_dump tool. It prints the current config as stored in the objdb in XML format. add ccs_config_validate tool to perform XML <-> RelaxNG schema check. rename cluster.rng into cluster.rng.in for future. It simplifies the Makefile and makes it ready for automatic generation at build time. add new install/uninstall target for files in ${sharedir} Signed-off-by: Fabio M. Di Nitto --- config/tools/xml/Makefile | 39 +- config/tools/xml/ccs_config_dump.c | 78 + config/tools/xml/ccs_config_validate.in | 23 + config/tools/xml/cluster.rng | 2806 ------------------------------- config/tools/xml/cluster.rng.in | 2806 +++++++++++++++++++++++++++++++ make/install.mk | 4 + make/uninstall.mk | 3 + 7 files changed, 2945 insertions(+), 2814 deletions(-) diff --git a/config/tools/xml/Makefile b/config/tools/xml/Makefile index b301eae..31a2aab 100644 --- a/config/tools/xml/Makefile +++ b/config/tools/xml/Makefile @@ -1,14 +1,37 @@ include ../../../make/defines.mk -TARGET = cluster.rng +TARGET1 = ccs_config_dump +TARGET2 = ccs_config_validate +TARGET3 = cluster.rng -all: +SBINDIRT = $(TARGET1) $(TARGET2) +SHAREDIRT = $(TARGET3) -clean: +all: $(TARGET1) $(TARGET2) $(TARGET3) -install: - install -d ${sharedir} - install -m644 ${TARGET} ${sharedir} +include $(OBJDIR)/make/cobj.mk +include $(OBJDIR)/make/clean.mk +include $(OBJDIR)/make/install.mk +include $(OBJDIR)/make/uninstall.mk -uninstall: - ${UNINSTALL} ${TARGET} ${sharedir} +OBJS = ccs_config_dump.o + +CFLAGS += -I${corosyncincdir} +CFLAGS += -I${incdir} + +LDFLAGS += -L${corosynclibdir} -lconfdb +LDFLAGS += -L${libdir} + +${TARGET1}: ${OBJS} + $(CC) -o $@ $^ $(LDFLAGS) + +${TARGET2}: $(S)/${TARGET2}.in + cat $(S)/$(TARGET2).in | sed \ + -e 's#@SBINDIR@#${sbindir}#g' \ + -e 's#@SHAREDIR@#${sharedir}#g' \ + > $(TARGET2) + +${TARGET3}: $(S)/${TARGET3}.in + cp $(S)/${TARGET3}.in ${TARGET3} + +clean: generalclean diff --git a/config/tools/xml/ccs_config_dump.c b/config/tools/xml/ccs_config_dump.c new file mode 100644 index 0000000..7723c40 --- /dev/null +++ b/config/tools/xml/ccs_config_dump.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include + +static confdb_callbacks_t callbacks = {}; + +static int dump_objdb_buff(confdb_handle_t dump_handle, hdb_handle_t cluster_handle, + hdb_handle_t parent_object_handle) +{ + hdb_handle_t object_handle; + char object_name[PATH_MAX], key_name[PATH_MAX], key_value[PATH_MAX]; + size_t key_value_len = 0, key_name_len = 0, object_name_len = 0; + + if (confdb_key_iter_start(dump_handle, parent_object_handle) != CS_OK) + return -1; + + while (confdb_key_iter(dump_handle, parent_object_handle, key_name, + &key_name_len, key_value, + &key_value_len) == CS_OK) { + key_name[key_name_len] = '\0'; + key_value[key_value_len] = '\0'; + printf(" %s=\"%s\"", key_name, key_value); + } + + if (parent_object_handle > 0) + printf(">\n"); + + if (confdb_object_iter_start(dump_handle, parent_object_handle) != CS_OK) + return -1; + + while (confdb_object_iter(dump_handle, parent_object_handle, + &object_handle, object_name, + &object_name_len) == CS_OK) { + hdb_handle_t parent; + + if (confdb_object_parent_get(dump_handle, object_handle, &parent) != CS_OK) + return -1; + + object_name[object_name_len] = '\0'; + printf("<%s", object_name); + + if(dump_objdb_buff(dump_handle, cluster_handle, object_handle)) + return -1; + + if (object_handle != parent_object_handle) + printf("\n", object_name); + else + printf(">\n"); + } + return 0; +} + +int main(void) { + confdb_handle_t handle = 0; + hdb_handle_t cluster_handle; + + if (confdb_initialize(&handle, &callbacks) != CS_OK) + return -1; + + if (confdb_object_find_start(handle, OBJECT_PARENT_HANDLE) != CS_OK) + return -1; + + if (confdb_object_find(handle, OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &cluster_handle) != CS_OK) + return -1; + + printf("\n\n"); + + if (confdb_finalize(handle) != CS_OK) + return -1; + + return 0; +} diff --git a/config/tools/xml/ccs_config_validate.in b/config/tools/xml/ccs_config_validate.in new file mode 100644 index 0000000..6891cd4 --- /dev/null +++ b/config/tools/xml/ccs_config_validate.in @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +# rpm based distros +if [ -d /etc/sysconfig ]; then + [ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster + [ -f /etc/sysconfig/cman ] && . /etc/sysconfig/cman +fi + +# deb based distros +if [ -d /etc/default ]; then + [ -f /etc/default/cluster ] && . /etc/default/cluster + [ -f /etc/default/cman ] && . /etc/default/cman +fi + +[ -z "$CONFIG_LOADER" ] && CONFIG_LOADER=xmlconfig +export COROSYNC_DEFAULT_CONFIG_IFACE=$CONFIG_LOADER:cmanpreconfig + +ccs_config_dump | xmllint \ + --relaxng @SHAREDIR@/cluster.rng \ + - >/dev/null +exit $? diff --git a/config/tools/xml/cluster.rng b/config/tools/xml/cluster.rng deleted file mode 100644 index 318afd6..0000000 --- a/config/tools/xml/cluster.rng +++ /dev/null @@ -1,2806 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/config/tools/xml/cluster.rng.in b/config/tools/xml/cluster.rng.in new file mode 100644 index 0000000..318afd6 --- /dev/null +++ b/config/tools/xml/cluster.rng.in @@ -0,0 +1,2806 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/make/install.mk b/make/install.mk index f493f07..5bd30d6 100644 --- a/make/install.mk +++ b/make/install.mk @@ -78,3 +78,7 @@ ifdef PKGCONF install -d ${pkgconfigdir} install -m644 ${PKGCONF} ${pkgconfigdir} endif +ifdef SHAREDIRT + install -d ${sharedir} + install -m644 ${SHAREDIRT} ${sharedir} +endif diff --git a/make/uninstall.mk b/make/uninstall.mk index 49e47bb..396e61f 100644 --- a/make/uninstall.mk +++ b/make/uninstall.mk @@ -47,3 +47,6 @@ endif ifdef PKGCONF ${UNINSTALL} ${PKGCONF} ${pkgconfigdir} endif +ifdef SHAREDIRT + ${UNINSTALL} ${SHAREDIRT} ${sharedir} +endif