(file) Return to CreateDmtfSchema CVS log (file) (dir) Up to [Pegasus] / pegasus / mak

File: [Pegasus] / pegasus / mak / CreateDmtfSchema (download)
Revision: 1.1, Sun Jan 20 17:41:16 2008 UTC (16 years, 4 months ago) by karl
Branch: MAIN
CVS Tags: TASK_PEP328_SOLARIS_NEVADA_PORT, TASK-PEP328_SOLARIS_NEVADA_PORT_v2-root, TASK-PEP328_SOLARIS_NEVADA_PORT_v2-branch, TASK-PEP328_SOLARIS_NEVADA_PORT-root, TASK-PEP328_SOLARIS_NEVADA_PORT-branch, TASK-PEP328_SOLARIS_IX86_CC_PORT-root, TASK-PEP328_SOLARIS_IX86_CC_PORT-branch-v2, TASK-PEP328_SOLARIS_IX86_CC_PORT-branch, TASK-PEP311_WSMan-root, TASK-PEP311_WSMan-branch, RELEASE_2_9_0-FC, RELEASE_2_8_2-RC1, RELEASE_2_8_2, RELEASE_2_8_1-RC1, RELEASE_2_8_1, RELEASE_2_8_0_BETA, RELEASE_2_8_0-RC2, RELEASE_2_8_0-RC1, RELEASE_2_8_0-FC, RELEASE_2_8_0, RELEASE_2_8-root, RELEASE_2_8-branch, Makefile
BUG#: 7266
TITLE: Add CIM217 to repository
DESCRIPTION: Add CreateDmtfSchema script that creaes new schema and
connecting files to Pegasus

#!/bin/bash
###########################################################################
##
## createschema script to create CIM Schema "interface" files:
##
## This script was used starting when CIM Schema Version 2.11 was
## installed because the new DMTF distribution is different that
## the file structure used by the Pegasus repository build functions. 
## It is not intended for general use. It is available here as 
## further documentation of the CIM Schema install process and for 
## future reference when new CIM Schema versions are installed.
##
## This bash shell script file creates "interface" files for the new 
## DMTF CIM Schema Version 2.11 and later to make them compatible with the 
## OpenPegasus build enviroment that has been used for previous versions.
##              
##
## The following files are needed and will each include the appropriate 
## DMTF files. 
## In Schemas/CIMxxx where xxx is the schema directory
##      CIM_Schema.mof
##      CIM_Event.mof
##      CIM_Core.mof
##      Core_Qualifiers.mof
##      CIM_Interop.mof
##
##      CIM_Physical.mof
##      CIM_Schema.mof
##
## The original DMTF CIM schema files are installed in Schemas/CIMxxx/DMTF
##
## To use this script:
##    1. Download the CIM schema MOF zip file from the DMTF web site
##    2. Insure that $PEGASUS_ROOT is set
##    3. run the script with the following options
##        a.  parameter 1 the schema version (ex. 214)
##        b.  parameter 2 is the location of the downloaded zip file.
##
##   NOTE: If the Schema directory already exists the user is offered
##         the option to replace the enitre directory.
##
##   CURRENT ISSUES AND LIMITATIONS
##   1. Intended for use with FINAL mof files.  It does not make any
##      provisions for the experimental mof.
##   2. This is a bash script and intended to be used only on systems
##      with the bash shell.
##   3. Does not test to determne if the input schema version is valid
##########################################################################

##########################################################################
##
## FUNCTION DEFINITIONS
##
##########################################################################

function usage {
    printf "\nUsage: %s <cim version> <DMTF CIM mof zip file>\n" $0 >&2
    printf "    Example: %s 214 ~/cimv214Final-MOFs.zip\n" $0 >&2
}

## INSERT_LICENSE ()
## Insert the current Pegasus License into a new file
## used for the new files we create to link the schema
## This function creates the file.
##
function INSERT_LICENSE {
    FILE=$1 ;
    cat "${PEGASUS_ROOT}/doc/license.txt" > ${FILE} ;
}

## INSERT_BLANK_LINE ()
## $1 filename w/o extensions
function INSERT_BLANK_LINE {
    FILE=$1 ;
    echo " " >> ${FILE}.mof ;
}

## INSERT_LINE ()
## Parameter 1 File to target w/o extension
## Parameter 2 Text for line to insert
##
function INSERT_LINE {
    FILE=$1 ;
    echo "$2" >> ${FILE}.mof ;
}

## INSERT_EXTRACTED_INCLUDES ()
##
## copy all include lines for this file from $CIMSCHEMAVERSION.mof 
## changing them to add the DMTF directory. 
##
## IE: The following line for the CIM_Core.mof file 
##
##    #pragma include ("Core\CIM_ManagedElement.mof")
##
##     gets changed to the following:
##
##    #pragma include ("DMTF/Core\CIM_ManagedElement.mof")
## Parameters
##  $1   CIM version number for DMTF schema File to grep 
##  $2   Output to build w/o extension
##
function INSERT_EXTRACTED_INCLUDES
{
    FILE=$1 ;
    NAME=$2 ;

    grep "(\"${NAME}" DMTF/cimv${CIM_SCHEMA_VER}.mof | \
        sed 's/include ("/include ("DMTF\//' >> ${FILE}.mof ;
    return 0 ;
}

## CREATE_MOF_FILE 
## Creates the new mof file with name and filename
## and inserts license and descriptive material
## $1 = Name for mof file to create (without extension)
function CREATE_MOF_FILE {
    NAME=$1 ;
    FILE=${NAME}.mof
    local TODAY=$(date '+%m/%d/%Y')
    INSERT_LICENSE ${FILE}
    echo "// ====================================================" >> ${FILE}
    echo "// Title      : ${NAME} MOF" >> ${FILE}
    echo "// Filename   : ${NAME}.mof" >> ${FILE}
    echo "// Version    :" >> ${FILE}
    echo "// Date       : ${TODAY}" >> ${FILE}
    echo "// Description: This file was created by The OpenPegasus Group to" \
         >> ${FILE}
    echo "//              create DMTF CIM Schema Version ${CIM_SCHEMA_VER} " \
         >> ${FILE}
    echo "//              interface filesfiles compatible with OpenPegasus " \
         >> ${FILE}
    echo "//              build enviroment." >> ${FILE}
    echo "//" >> ${FILE}
    echo "//=====================================================" >> ${FILE}

INSERT_BLANK_LINE ${NAME} ;       
}

## Let user make choice.
## called like: chice <prompt>
## Returns: global variable choice with y / n or answer
function choice {
    CHOICE=''
    local prompt="$*"
    local answer
    
    read -p "$prompt" answer
    case "$answer" in
        [yY1] ) CHOICE='y';;
        [nN0] ) CHOICE='n';;
        *     ) CHOICE="$answer";;
    esac
}  # end of choice function

#######################################################################
##
## Execute the script
##
#######################################################################


#######################################################################
## Test and setup variables for this create
## $1 - CIM Schema version to create in the #PEGASUS_ROOT/Schemas
##      directory (ex. 214)
## $2 - Name of the DMTF CIM release zip file to install.
if (( $# < 2 )); then
    usage
    exit 1
fi

CIM_SCHEMA_VER=${1:?"Error. CIM Version parameter required ex. 214"}
ZIP_FILE=${2:?"Error. Location of CIM MOF zip file required"}

SCHEMA_DIR=$PEGASUS_ROOT/Schemas/CIM${CIM_SCHEMA_VER}

## confirm that the zip file exists. Error if not
if [ !  -e "$ZIP_FILE" ]; then
    echo "The input MOF ZIP file $ZIP_FILE does not exist."
    exit 1
fi

## Check with user to be sure input was correct
choice "Create ${SCHEMA_DIR} from input file ${ZIP_FILE} [y/n]?"
if [ "$CHOICE" != "y" ]; then
    echo "Terminating because user elected not to continue."
    exit 1
fi

## if the schema directory exists, ask if we want to redo it.
## Deletes the DMTF subdirectory and mof in the SCHEMA_DIR
if [ -a $SCHEMA_DIR ]; then
    echo Schema directory $SCHEMA_DIR already exists.
    choice "Replace existing Directory ${SCHEMA_DIR} [y/n]?"
    if [ "$CHOICE" = "y" ]; then
        rm -rf "$SCHEMA_DIR"
    else
        echo Terminating without changing Directory $SCHEMA_DIR MOF.
        exit 1
    fi   
fi

mkdir "$SCHEMA_DIR" || { echo Unable to create $SCHEMA_DIR ; exit 4; }   
cd $SCHEMA_DIR

## Create DMTF directory and unzip the CIM release into this directory
mkdir DMTF

echo "Source $ZIP_FILE" >DMTFSchemaInfo.txt

## unzip because DMTF files zipped with pkzip or equivalent
unzip $ZIP_FILE -d DMTF
 
##########################################################################
##
## Create the mof files
##
##########################################################################

#### create  Core_Qualifiers.mof
CREATE_MOF_FILE Core_Qualifiers
INSERT_LINE Core_Qualifiers "#pragma include (\"DMTF/qualifiers.mof\")"
INSERT_LINE Core_Qualifiers "#pragma include (\"DMTF/qualifiers_optional.mof\")"
INSERT_BLANK_LINE Core_Qualifiers ;

#### create CIM_Schema.mof
CREATE_MOF_FILE CIM_Schema
INSERT_LINE CIM_Schema "#pragma include (\"DMTF/cimv${CIM_SCHEMA_VER}.mof\")"
INSERT_BLANK_LINE CIM_Schema ;

#### create CIM_Core.mof
CREATE_MOF_FILE CIM_Core
INSERT_LINE CIM_Core  "#pragma include (\"DMTF/qualifiers.mof\")" ;
INSERT_LINE CIM_Core "#pragma include (\"DMTF/qualifiers_optional.mof\")"
INSERT_BLANK_LINE CIM_Core ;
INSERT_EXTRACTED_INCLUDES CIM_Core Core ;
INSERT_BLANK_LINE CIM_Core ;


#### create CIM_Event.mof
CREATE_MOF_FILE CIM_Event
INSERT_EXTRACTED_INCLUDES CIM_Event Event ;
INSERT_BLANK_LINE CIM_Event ;


#### create CIM_Interop.mof
CREATE_MOF_FILE CIM_Interop
INSERT_EXTRACTED_INCLUDES CIM_Interop Interop ;
INSERT_BLANK_LINE CIM_Interop ;

############################################################
#### The following are required for the make testrepository

#### create CIM_Physical.mof
CREATE_MOF_FILE CIM_Physical
INSERT_EXTRACTED_INCLUDES CIM_Physical Physical ;
INSERT_BLANK_LINE CIM_Physical ;


#### create CIM_System.mof
CREATE_MOF_FILE CIM_System
INSERT_EXTRACTED_INCLUDES CIM_System System ;
INSERT_BLANK_LINE CIM_System ;


No CVS admin address has been configured
Powered by
ViewCVS 0.9.2