[PATCH 0 of 3] #2 Add automated base schema installation

Changes since last time are almost exclusively to the installation script

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1197066416 28800 # Node ID 588daf25941e36b540689209bf0c76b1ce08cb32 # Parent 0f3d28e6d2ed153c5b610b103687dc7f6faf6d30 Add base schema support files for automated installation Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 0f3d28e6d2ed -r 588daf25941e base_schema/cimv216-interop_mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base_schema/cimv216-interop_mof Fri Dec 07 14:26:56 2007 -0800 @@ -0,0 +1,15 @@ +#pragma locale ("en_US") +#pragma include ("qualifiers.mof") +#pragma include ("qualifiers_optional.mof") +#pragma include ("Core/CIM_ManagedElement.mof") +#pragma include ("Core/CIM_ManagedSystemElement.mof") +#pragma include ("Core/CIM_LogicalElement.mof") +#pragma include ("Core/CIM_EnabledLogicalElement.mof") +#pragma include ("Core/CIM_System.mof") +#pragma include ("System/CIM_ComputerSystem.mof") +#pragma include ("Interop/CIM_RegisteredProfile.mof") +#pragma include ("Interop/CIM_RegisteredSubProfile.mof") +#pragma include ("Core/CIM_Dependency.mof") +#pragma include ("Interop/CIM_ElementConformsToProfile.mof") +#pragma include ("Interop/CIM_ReferencedProfile.mof") +#pragma include ("Interop/CIM_SubProfileRequiresProfile.mof") diff -r 0f3d28e6d2ed -r 588daf25941e base_schema/fix_schema.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base_schema/fix_schema.patch Fri Dec 07 14:26:56 2007 -0800 @@ -0,0 +1,22 @@ +--- cimv216.mof 2007-08-30 16:19:12.000000000 -0700 ++++ cimv216-new.mof 2007-12-05 12:45:56.000000000 -0800 +@@ -505,7 +505,7 @@ + #pragma include ("Policy/CIM_PolicySetValidityPeriod.mof") + #pragma include ("Policy/CIM_PublicPrivateKeyAuthentication.mof") + #pragma include ("Policy/CIM_SharedSecretAuthentication.mof") +-#pragma include ("Security/CIM_SecurityIndication.mof") ++//#pragma include ("Security/CIM_SecurityIndication.mof") + #pragma include ("Support/PRS_Activity.mof") + #pragma include ("Support/PRS_ActivityResource.mof") + #pragma include ("Support/PRS_ActivityTransaction.mof") +@@ -726,8 +726,8 @@ + #pragma include ("Policy/CIM_PolicyActionStructure.mof") + #pragma include ("Policy/CIM_PolicyConditionInPolicyCondition.mof") + #pragma include ("Policy/CIM_PolicyConditionInPolicyRule.mof") +-#pragma include ("Security/CIM_IPNetworkSecurityIndication.mof") +-#pragma include ("Security/CIM_IPPacketFilterIndication.mof") ++//#pragma include ("Security/CIM_IPNetworkSecurityIndication.mof") ++//#pragma include ("Security/CIM_IPPacketFilterIndication.mof") + #pragma include ("Support/PRS_ActivityContact.mof") + #pragma include ("Support/PRS_AdminAssociation.mof") + #pragma include ("Support/PRS_AdministrativeContact.mof")

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1197066990 28800 # Node ID 0d80882209b4002da9283e4cfe17d48cb1155d45 # Parent 588daf25941e36b540689209bf0c76b1ce08cb32 Add base schema installation script Changes: - Removed explicit -x - Added optional -x and debug dump based on environment variable - Fixed cimv*.mof ambiguity Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 588daf25941e -r 0d80882209b4 base_schema/install_base_schema.sh.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base_schema/install_base_schema.sh.in Fri Dec 07 14:36:30 2007 -0800 @@ -0,0 +1,102 @@ +#!/bin/bash + +DATA="$1" +NS=@CIM_VIRT_NS@ +CIMOM=@CIMSERVER@ + +TMPDIR=$(mktemp -d /tmp/cim_schema.XXXXX) + +if [ ! -z "$CIM_DEBUG" ]; then + set -x + DEBUG="$TMPDIR/log" +else + DEBUG="/dev/null" +fi + +unpack_schema() { + cd ${TMPDIR} && unzip ${DATA}/cimv*-MOFs.zip +} + +fix_schema() { + (cd ${TMPDIR} && patch -p0 < ${DATA}/fix_schema.patch) + cp -a ${DATA}/cimv216-interop_mof ${TMPDIR}/cimv216-interop.mof +} + +detect_peg_repo() { + dirs="$PEGASUS_HOME /var/lib/Pegasus /var/lib/pegasus /usr/local/var/lib/pegasus /var/local/lib/pegasus /var/opt/tog-pegasus" + + for d in $dirs; do + if [ -d "$d" ]; then + echo $d + return + fi + done +} + +detect_sfcb_dir() { + dirs="SFCB_DIR /usr/local/share/sfcb /usr/share/sfcb" + + for d in $dirs; do + if [ -d "$d" ]; then + echo $d; + return + fi + done +} + +install_schema_pegasus() { + local repo=$(detect_peg_repo) + + if [ -z "$repo" ]; then + echo "Unable to determine Pegasus repository path" + echo "set PEGASUS_HOME" + return + fi + + cd ${TMPDIR} + + cimmofl -uc -aEV -R$repo -n $NS cimv???.mof + cimmofl -uc -aEV -R$repo -n $NS qualifiers.mof + cimmofl -uc -aEV -R$repo -n $NS qualifiers_optional.mof + cimmofl -uc -aEV -R$repo -n /root/interop cimv???-interop.mof +} + +install_schema_sfcb() { + local dir=$(detect_sfcb_dir) + + if [ ! mkdir ${dir}/CIM ]; then + echo "Unable to determine SFCB directory" + echo "set SFCB_DIR" + return + fi + + mv ${TMPDIR}/cimv???.mof ${TMPDIR}/CIM_Schema.mof + cp -ra ${TMPDIR}/* ${dir} + sfcbrepos +} + +if [ -z "$1" ]; then + echo "Usage: $0 [source_dir]" + exit 1 +fi + +(unpack_schema) >>$DEBUG 2>&1 +(fix_schema) >>$DEBUG 2>&1 + +case "$CIMOM" in + sfcb) + (install_schema_sfcb) >>$DEBUG 2>&1 + ;; + pegasus) + (install_schema_pegasus) >>$DEBUG 2>&1 + ;; + *) + echo ERROR: Unknown CIMOM: $CIMOM + ;; +esac + +if [ -f "$DEBUG" ]; then + echo "-- base schema install log begin --" + cat $DEBUG + echo "-- base schema install log end --" +fi \ No newline at end of file

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1197066990 28800 # Node ID 0d80882209b4002da9283e4cfe17d48cb1155d45 # Parent 588daf25941e36b540689209bf0c76b1ce08cb32 Add base schema installation script
Great work :). I tested the processes with sfcbd and found some minor things. After updating them, everything worked fine :). Thanks. Somehow the "if [ ! mkdir ${dir}/CIM ]; then" in install_schema_sfcb() seem to do not work. I completely removed the CIM directory by hand, did "make preinstall" but no new one was created. The script does now creating the directory and testing for existence afterwards and this seems to work. I have only some experiences with scripts and don't know the reason for this behavior. The schema files need to be copied to SFCB_DIR/CIM and sfcbrepos must be started with -f to avoid the question to the user for acceptance. Added a line to remove the schema files from /tmp. diff -r ae7fb433a73a base_schema/install_base_schema.sh.in --- a/base_schema/install_base_schema.sh.in Fri Dec 07 14:36:34 2007 -0800 +++ b/base_schema/install_base_schema.sh.in Mon Dec 10 14:00:37 2007 +0100 @@ -64,15 +64,18 @@ install_schema_sfcb() { install_schema_sfcb() { local dir=$(detect_sfcb_dir) - if [ ! mkdir ${dir}/CIM ]; then + mkdir ${dir}/CIM + if [ -z ${dir}/CIM ]; then echo "Unable to determine SFCB directory" echo "set SFCB_DIR" return fi mv ${TMPDIR}/cimv???.mof ${TMPDIR}/CIM_Schema.mof - cp -ra ${TMPDIR}/* ${dir} - sfcbrepos + cp -ra ${TMPDIR}/* ${dir}/CIM + sfcbrepos -f + + rm -rf ${TMPDIR} } if [ -z "$1" ]; then -- Regards Heidi Eckhart Software Engineer Linux Technology Center - Open Hypervisor heidieck@linux.vnet.ibm.com ************************************************** IBM Deutschland Entwicklung GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschaeftsfuehrung: Herbert Kircher Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

HE> - if [ ! mkdir ${dir}/CIM ]; then HE> + mkdir ${dir}/CIM HE> + if [ -z ${dir}/CIM ]; then Ah, yes, this will fail if the CIM directory already exists. HE> - cp -ra ${TMPDIR}/* ${dir} HE> - sfcbrepos HE> + cp -ra ${TMPDIR}/* ${dir}/CIM HE> + sfcbrepos -f Oh yeah, both are good changes. I'll re-send the set with these changes applied. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1197066994 28800 # Node ID 6fae41fcbfbdcdc9c8b205c93df6daf6c4d558a9 # Parent 0d80882209b4002da9283e4cfe17d48cb1155d45 Build support for base schema installation Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 0d80882209b4 -r 6fae41fcbfbd Makefile.am --- a/Makefile.am Fri Dec 07 14:36:30 2007 -0800 +++ b/Makefile.am Fri Dec 07 14:36:34 2007 -0800 @@ -1,5 +1,5 @@ # Copyright IBM Corp. 2007 -SUBDIRS = libxkutil src doc +SUBDIRS = libxkutil src doc base_schema MOFS = \ schema/ComputerSystem.mof \ @@ -89,6 +89,9 @@ EXTRA_DIST = schema $(pkgdata_DATA) $(pk libvirt-cim.spec.in libvirt-cim.spec \ doc/CodingStyle doc/SubmittingPatches +preinstall: + sh -x base_schema/install_base_schema.sh `pwd`/base_schema + # Un/Register the providers and class definitions from/to the current CIMOM. # @CIMSERVER@ is set by the configure script postinstall: diff -r 0d80882209b4 -r 6fae41fcbfbd base_schema/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base_schema/Makefile.am Fri Dec 07 14:36:34 2007 -0800 @@ -0,0 +1,9 @@ +CIM_SCHEMA_VER = 216 +CIM_SCHEMA_REL = $(CIM_SCHEMA_VER)Experimental +CIM_SCHEMA_ZIP = cimv$(CIM_SCHEMA_REL)-MOFs.zip + +dist_pkgdata_DATA = $(CIM_SCHEMA_ZIP) fix_schema.patch cimv216-interop_mof +dist_pkgdata_SCRIPTS = install_base_schema.sh + +$(CIM_SCHEMA_ZIP): + wget http://www.dmtf.org/standards/cim/cim_schema_v$(CIM_SCHEMA_VER)/$(CIM_SCHEMA...) \ No newline at end of file diff -r 0d80882209b4 -r 6fae41fcbfbd configure.ac --- a/configure.ac Fri Dec 07 14:36:30 2007 -0800 +++ b/configure.ac Fri Dec 07 14:36:34 2007 -0800 @@ -87,6 +87,8 @@ AC_PATH_PROG(XSLTPROC, xsltproc, /usr/bi # Autogenerate the Makefile AC_CONFIG_FILES([ + base_schema/install_base_schema.sh + base_schema/Makefile libxkutil/Makefile libxkutil/tests/Makefile src/Makefile diff -r 0d80882209b4 -r 6fae41fcbfbd libvirt-cim.spec.in --- a/libvirt-cim.spec.in Fri Dec 07 14:36:30 2007 -0800 +++ b/libvirt-cim.spec.in Fri Dec 07 14:36:34 2007 -0800 @@ -55,6 +55,8 @@ rm -fr $RPM_BUILD_ROOT %post /sbin/ldconfig +%{_datadir}/%{name}/install_base_schema.sh %{_datadir}/%{name} + %{_datadir}/%{name}/provider-register.sh -t pegasus \ -n /@CIM_VIRT_NS@ \ -r %{REGISTRATION} -m %{SCHEMA} || true @@ -76,7 +78,10 @@ rm -fr $RPM_BUILD_ROOT %{_libdir}/cmpi/lib*.so* %{_datadir}/libvirt-cim/*.sh %{_datadir}/libvirt-cim/*.mof +%{_datadir}/libvirt-cim/cimv*-interop_mof %{_datadir}/libvirt-cim/*.registration +%{_datadir}/libvirt-cim/fix_schema.patch +%{_datadir}/libvirt-cim/cimv*-MOFs.zip %changelog * Fri Oct 26 2007 Daniel Veillard <veillard@redhat.com> - 0.1-1
participants (2)
-
Dan Smith
-
Heidi Eckhart