Skip to contentSkip to conversation

config: add dynamic generation of relaxng schema for config validation

PATCH New Fabio M. Di Nitto 1 participant 1 message Jul 8, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 config: add dynamic generation of relaxng schema for config validation

Add new tool ccs_update_schema
Modify ccs_config_validate to call ccs_update_schema

This feature requires resource-agents 3.9.2 and fence-agents 3.1.5 and xsltproc available on the installed system.

Resolves: rhbz#680930

---
 config/tools/man/Makefile               |    1 +
 config/tools/man/ccs_config_validate.8  |    4 +
 config/tools/man/ccs_update_schema.8    |   29 +
 config/tools/xml/Makefile               |   19 +-
 config/tools/xml/ccs_config_validate.in |   25 +-
 config/tools/xml/ccs_update_schema.in   |  311 +++
 config/tools/xml/cluster.rng.in         | 4309 -------------------------------
 config/tools/xml/cluster.rng.in.head    | 1049 ++++++++
 config/tools/xml/cluster.rng.in.tail    |    1 +
 make/install.mk                         |    8 +
 make/uninstall.mk                       |    6 +
 11 files changed, 1447 insertions(+), 4315 deletions(-)
 create mode 100644 config/tools/man/ccs_update_schema.8
 create mode 100644 config/tools/xml/ccs_update_schema.in
 delete mode 100644 config/tools/xml/cluster.rng.in
 create mode 100644 config/tools/xml/cluster.rng.in.head
 create mode 100644 config/tools/xml/cluster.rng.in.tail
config/tools/man/Makefile +1 -0
index 8674f66..5faaf6b 100644
@@ -1,6 +1,7 @@
 MANTARGET= \
 	ccs_config_dump.8 \
 	ccs_config_validate.8 \
+	ccs_update_schema.8 \
 	ccs_tool.8 \
 	confdb2ldif.8
 
config/tools/man/ccs_config_validate.8 +4 -0
index 8884952..ac78178 100644
@@ -24,6 +24,10 @@ Validate an alternate config file without preloading it with default values.
 Validate an alternate config file with preloading of default values (recommended option).
 .SS "Advanced options:"
 .TP
+\fB\-u\fR
+Do not update relaxng schema (see ccs_update_schema.8)
+.HP
+.TP
 \fB\-r\fR
 Force validation of runtime config
 .HP
config/tools/man/ccs_update_schema.8 new file +29 -0
new file mode 100644
index 0000000..3467c9c
@@ -0,0 +1,29 @@
+.TH "ccs_update_schema" "8" "" "" ""
+.SH "NAME"
+ccs_update_schema \- Tool to generate cluster relaxng schema for cluster config validation.
+
+.SH "SYNOPSIS"
+.B ccs_update_schema
+[\fIOPTION\fR]..
+
+.SH "DESCRIPTION"
+
+\fBccs_update_schema\fP is part of the Cluster Configuration System (CCS).
+It is used to update the cluster relaxng schema that validates cluster.conf.
+
+.SH "OPTIONS"
+.TP 
+\fB\-h\fP
+Help.  Print out the usage.
+.TP 
+\fB\-V\fP
+Print the version information.
+.TP
+\fB\-v\fP
+Be verbose. Mostly for debugging purposes.
+.TP
+\fB\-f\fP
+Ignore local stored cache and regenerate a fresh schema.
+
+.SH "SEE ALSO"
+ccs_config_validate(8), cluster.conf(5)
config/tools/xml/Makefile +14 -5
index a5c5cc7..3c9e97c 100644
@@ -2,12 +2,14 @@ include ../../../make/defines.mk
 
 TARGET1 = ccs_config_dump
 TARGET2 = ccs_config_validate
-TARGET3 = cluster.rng
+TARGET3 = ccs_update_schema
+TARGET4 = cluster.rng
 
-SBINDIRT = $(TARGET1) $(TARGET2)
-SHAREDIRT = $(TARGET3)
+SBINDIRT = $(TARGET1) $(TARGET2) $(TARGET3)
+SHAREDIRSYMT = $(TARGET4)
+RELAXNGDIRT = cluster.rng.in.head cluster.rng.in.tail
 
-all: $(TARGET1) $(TARGET2) $(TARGET3)
+all: $(TARGET1) $(TARGET2) $(TARGET3) $(TARGET4)
 
 include $(OBJDIR)/make/cobj.mk
 include $(OBJDIR)/make/clean.mk
@@ -33,6 +35,13 @@ ${TARGET2}: $(S)/${TARGET2}.in
 	> $(TARGET2)
 
 ${TARGET3}: $(S)/${TARGET3}.in
-	cp $(S)/${TARGET3}.in ${TARGET3}
+	cat $(S)/$(TARGET3).in | sed \
+		-e 's#@SBINDIR@#${sbindir}#g' \
+		-e 's#@SHAREDIR@#${sharedir}#g' \
+		-e 's#@VERSION@#${RELEASE_VERSION}#g' \
+	> $(TARGET3)
+
+${TARGET4}:
+	ln -sf /var/lib/cluster/cluster.rng ${TARGET4}
 
 clean: generalclean
config/tools/xml/ccs_config_validate.in +24 -1
index f7d7c04..6573fef 100644
@@ -42,6 +42,7 @@ print_usage() {
 	echo "  -l configfile    Validate an alternate config file (load test)"
 	echo ""
 	echo "Advanced options:"
+	echo "  -u               Do not update relaxng schema"
 	echo "  -r               Force validation of runtime config"
 	echo "  -C config_loader Override config plugin loader"
 	echo "  -t tempfile      Force temporay file to tempfile"
@@ -135,6 +136,9 @@ check_opts() {
 				exit 255
 			fi
 		;;
+		-u)
+			updaterelaxng=0
+		;;
 		esac
 		shift
 	done
@@ -146,7 +150,7 @@ lecho()
 	return 0
 }
 
-opts=$(getopt t:hVnC:f:l:rR:ovq $@)
+opts=$(getopt t:hVnC:f:l:rR:ovqu $@)
 if [ "$?" != 0 ]; then
 	print_usage >&2
 	exit 255
@@ -182,6 +186,25 @@ else
 fi
 lecho "Configuration stored in temporary file"
 
+lecho "Updating relaxng schema"
+if [ "$updaterelaxng" != 0 ]; then
+	updateerr="$(ccs_update_schema 2>&1)"
+	if [ $? != 0 ]; then
+		echo "Unable to update relaxng schema: $updateerr" >&2
+		exit 255
+	fi
+fi
+
+if [ -f /var/lib/cluster/rng_update.lock ]; then
+	echo "Relax-ng schema update in progress" >&2
+	exit 255
+fi
+
+if [ ! -e @SHAREDIR@/cluster.rng ]; then
+	echo "Unable to verify a configuration without relaxng schema" >&2
+	exit 255
+fi
+
 lecho "Validating.."
 
 xmlout=$(xmllint --noout \
config/tools/xml/ccs_update_schema.in new file +311 -0

311 lines not on this page · raw message

config/tools/xml/cluster.rng.in deleted +0 -4309

2,562 lines not on this page · raw message

config/tools/xml/cluster.rng.in.head new file +1049 -0

1,049 lines not on this page · raw message

config/tools/xml/cluster.rng.in.tail new file +1 -0
new file mode 100644
index 0000000..d4e2278

Lines of this file are not shown. View the raw message.

make/install.mk +8 -0
index e3c1c9d..49ca678 100644

Lines of this file are not shown. View the raw message.

make/uninstall.mk +6 -0
index 6f84727..3ca687f 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.4.4

Part of the diff is not shown here. View the raw message.