./0000775000175000017500000000000012046033327010151 5ustar jaredjared./wsl-0.2.1/0000775000175000017500000000000012046033327011412 5ustar jaredjared./wsl-0.2.1/wxmlgetvalue0000755000175000017500000000152512046033327014065 0ustar jaredjared#!/bin/bash MYNAME=`basename $0` MYPATH=${0%/*} NODATEDUMP=1 . ${MYPATH}/wsl-functions usage() { ${WSCOLORERR} cat < $MYNAME CIM_ComputerSystem > $MYNAME CIM_ComputerSystem -mode epr > $MYNAME CIM_ComputerSystem -filter "select \* from CIM_ComputerSystem where Name='srv:system'" > $MYNAME Dell_BaseServerProfile -ns root/interop -mode epr -references InstanceID=Dell:reg5 EOF $WSCOLORNORM exit 1 } fCheckReqsOrUsage [ $# -lt 1 ] && usage while [ ! -z "$1" ]; do case "$1" in -h|-help|help ) usage ;; -a|-associators ) Assoc=1 ;; -d|-dialect ) shift; Dialect="$1" ;; -e|-ext ) SHOWEXT='' ;; -f|-filter ) shift; QFilter="$1" ;; -i|-inst ) shift; InstanceFile="$1" ;; -m|-mode ) shift; val="$1" [ "${val}" = "epr" ] && EPR='EnumerateEPR' [ "${val}" = "objepr" ] && EPR='EnumerateObjectAndEPR' ;; -n|-ns ) shift; WSNS="$1" ;; -o|-opti ) shift; WSENUMMAXELEM="$1"; WSENUMOPTIMIZE=1 ;; -r|-references ) Assoc=2 ;; * ) echo "$1" | grep "=" >/dev/null if [ $? -eq 0 ]; then Name=$(echo "$1" | cut -d '=' -f1 ) Value=$(echo "$1" | cut -d '=' -f2- ) INSTANCESELECTOR="${INSTANCESELECTOR}${Value}" else CLASS="$1" fi ;; esac shift done # initializations fGetTarget fInitEnum fSetWGET fNormalizeClass [ -z "${Dialect}" ] && Dialect="http://schemas.dmtf.org/wbem/cql/1/dsp0202.pdf" if [ ! -z "${QFilter}" ]; then echo ${Dialect} | grep -i selectorfilter >/dev/null 2>&1 if [ $? -eq 0 ]; then FQUERY="" for item in `echo "${QFilter}" | sed 's/,/ /g'`; do name=$(echo ${item} | cut -d= -f1) value=$(echo ${item} | cut -d= -f2-) FQUERY="${FQUERY}${value}" done FQUERY="${FQUERY}" else FQUERY="${QFilter}" fi fi if [ ! -z "${WSNS}" ]; then REQSELECTORS=`cat < ${WSNS} EOF` fi dopullX() { fGetUUID fReqRspNext cat <${REQUESTFILE} ${WSENVELOPEHEADER} http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull ${WSCOMMONHEADER} ${CLASS} ${UUID} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${CONTEXT} ${WSPULLMAXELEMSTR} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest fNormalizeXML ${RESPONSEFILE} unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE} grep 'PullResponse' ${RESPONSEFILE} 2>&1 >/dev/null export STAT=$? } doenumerateX() { fGetUUID fReqRspNext cat <${REQUESTFILE} ${WSENVELOPEHEADER} http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate ${WSCOMMONHEADER} ${CLASS} ${UUID} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${REQSELECTORS} ${SHOWEXT} ${WSENUMOPTIMIZEDSTR} ${WSENUMMAXELEMSTR} ${EPR} ${FQUERY} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest fNormalizeXML ${RESPONSEFILE} unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE} grep 'EnumerateResponse' ${RESPONSEFILE} 2>&1 >/dev/null export STAT=$? } doenumerate() { doenumerateX fDisplayResponse ${RESPONSEFILE} while [ ! -z "${CONTEXT}" ]; do dopullX fDisplayResponse ${RESPONSEFILE} [ ! -z "${CONTEXT}" ] && [ ${OUTLEVEL} -ge 3 ] && echo "(${CONTEXT})" done } if [ ! -z "${Assoc}" ]; then [ ${Assoc} -eq 1 ] && Assoctype="AssociationInstances" [ ${Assoc} -eq 2 ] && Assoctype="AssociatedInstances" if [ ! -z "${InstanceFile}" ]; then echo "using ${InstanceFile} to extract EPR XML for association filter" fExtractEPRXML ${InstanceFile} vBody="${EPRXML}" else if [ ! -z "${WSNS}" ]; then INSTANCESELECTOR="${INSTANCESELECTOR}${WSNS}" fi vBody=`cat <http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${CLASS} ${INSTANCESELECTOR} EOF` fi FQUERY=`cat < ${vBody} EOF` CLASS="http://schemas.dmtf.org/wbem/wscim/1/*" fi [ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Enumerate operation may take time to reply." doenumerate /bin/cp ${RESPONSEFILE} ${RETURNFILE} [ ${OUTLEVEL} -ge 3 ] && echo "Output is saved to ${RETURNFILE}" exit ${STAT} # ########################################################################### # End of Code # ########################################################################### ./wsl-0.2.1/wslget0000755000175000017500000000751512046033327012653 0ustar jaredjared#!/bin/bash # ########################################################################### # Copyright (c) 2011, Dell Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Dell Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### # Authors: Chris A. Poblete # Version: 1.0.0 # ########################################################################### MYNAME=`basename $0` # source function library . /etc/wsl/wsl-functions usage() { fUsageheader cat <' ${ecnfile} | cut -d'>' -f2 | cut -d ':' -f2 | cut -d'<' -f1 | sort | uniq > ecnfile.xml total=$( cat ecnfile.xml | wc -l ) count=1 fReqRspNext while read -e line ; do echo -en "${count} of ${total} -> " dogetclass "${line}" echo "${line}-def.xml" /bin/mv ${RESPONSEFILE} ${line}-def.xml cat <>${indexfile} ${line}
EOF count=$((count + 1)) done < ecnfile.xml echo "" >>${indexfile} } doecn() { fGetUUID resourceuri="http://schemas.openwsman.org/wbem/wscim/1/intrinsic" cat <${REQUESTFILE} ${resourceuri}/EnumerateClassNames ${WSCOMMONHEADER} ${UUID} ${resourceuri} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest export STAT=$? fNormalizeXML ${RESPONSEFILE} } [ $# -lt 1 ] && usage while [ ! -z "$1" ]; do case "$1" in -h|-help|help|--help ) usage ;; check ) shift; doinit doecn fDisplayResponse ${RESPONSEFILE} /bin/cp ${RESPONSEFILE} ${RETURNFILE} ;; getclass ) shift; [ -z "$1" ] && usage doinit dogetclass "$1" fDisplayResponse ${RESPONSEFILE} /bin/cp ${RESPONSEFILE} ${RETURNFILE} ;; getallclass ) shift; doinit doecn dogetallclass "${RESPONSEFILE}" ;; * ) usage ;; esac shift done [ ${OUTLEVEL} -ge 3 ] && echo "Output is saved to ${RETURNFILE}" exit ${STAT} # ########################################################################### # End of Code # ########################################################################### ./wsl-0.2.1/wsl-functions0000644000175000017500000004773312046033327014164 0ustar jaredjared # ########################################################################### # Copyright (c) 2011, Dell Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Dell Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### # Authors: Chris A. Poblete # Version: 1.0.0 # ########################################################################### # ********************************************************************** # *** *** # *** Define "WSLNOINIT" to source this file without initializations *** # *** *** # ********************************************************************** MYPATH=${0%/*} MYCONFIG=".wsl-config" ENVOUTLEVEL=$OUTLEVEL ENVIPINTERACTIVE=$IPINTERACTIVE [ -e ${MYPATH}/${MYCONFIG} ] && . ${MYPATH}/${MYCONFIG} [ -e ~/${MYCONFIG} ] && . ~/${MYCONFIG} [ -e ./${MYCONFIG} ] && . ./${MYCONFIG} [ ! -z "$ENVOUTLEVEL" ] && OUTLEVEL=$ENVOUTLEVEL [ ! -z "$ENVIPINTERACTIVE" ] && IPINTERACTIVE=$ENVIPINTERACTIVE # ************************************************************** # ***** ***** # ***** User configuration specification ***** # ***** ***** # ************************************************************** if [ ! -e ~/${MYCONFIG} ]; then DRIVER="#USEWGET=true" which curl 2>/dev/null >/dev/null [ $? -ne 0 ] && DRIVER="USEWGET=true" cat < ~/${MYCONFIG} ### NOTE: This is a generated file. See the accompanying README file for more info. ### Comment the line to (1) use the default or (2) set to disabled. ## Timeout in seconds waiting for response. { 1...600} Default is 180. #WGETTIMEOUTSECS=180 ## Number of retry when there is no response. { 1...6 } Default is 1. #WGETTRYNUM=1 ## Use HTTP connection. Default is use HTTPS. Uncomment var for HTTP. #WSNOSSL=true ## Optimized enumeration, required for WSENUMMAXELEM. Default is none specified (none optimized). #WSENUMOPTIMIZE=true ## Max number of instances in a response. { 1...1048576 } Default is 512. #WSENUMMAXELEM=512 ## WSMAN operation timeout in seconds. Default is none specified. #WSOPERATIONTIMEOUT=360 ## WSMAN maximum SOAP envelope size the client is willing to accept. Default is none specified. #WSMAXENVELOPESIZE=32767 ## Schema prefix used for non-DMTF class. Default is "schemas.dell.com" #WSDEFAULTSCHEMA="schemas.dell.com" ## Interactive level: 0=NoAsk, 1=AskIPAddress, 2=AskIPandCredential. Default is 0. #IPINTERACTIVE=1 ## Remember IP address and user credential. Default is keep history. Uncomment var to prevent history use. #KEEPHISTORY=0 ## Show history when asking for an environment variable input. Undefined or 0 = no show, 1 show. Default is no show. #SHOWHISTORY=1 ## Display date-time stamp. Default is disabled. #DATETIMESTAMP=true ## Formatted display of response XML. Default is disabled. #FORMATDISPLAY=true ## Output level: 0=NoOutput, 1=ResponseOnly, 2=AddRequest, 3=AddMore. Default is 1. #OUTLEVEL=2 ## Output directory. Default is current directory. #OUTPREFIX=. ## Log filename. Default is log.txt #LOGFILE="log.txt" ## Result XML filename. Default response.xml #RETURNFILE="response.xml" ## Echo back the command to console for debug purpose. Default is disabled. #ECHOCMD=true ## CURL has HTTP1.1 support while WGET is widely available. Default is CURL ${DRIVER} EOF fi # *********************************************************** # *********************************************************** # ***** ***** # ***** S T O P !! ***** # ***** ***** # ***** DO NOT CHANGE, static values/code ***** # ***** unless you know what you are doing ***** # ***** ***** # *********************************************************** # *********************************************************** # Set defaults MYPNAME1="WSL" MYPNAME2="Wsman Shell commandLine" MYVERSION="0.2.1" [ -z "${OUTLEVEL}" ] && OUTLEVEL=1 [ -z "${KEEPHISTORY}" ] && KEEPHISTORY=1 [ -z "${SHOWHISTORY}" ] && SHOWHISTORY=0 [ -z "${OUTPREFIX}" ] && OUTPREFIX=. [ -z "${LOGFILE}" ] && LOGFILE="log.txt" [ -z "${RETURNFILE}" ] && RETURNFILE="response.xml" [ -z "${WSDEFAULTSCHEMA}" ] && WSDEFAULTSCHEMA="schemas.dell.com" #[ -z "${RTFILEPREFIX}" ] && RTFILEPREFIX="${WSENDPOINT}" export URIDEFAULT="http://${WSDEFAULTSCHEMA}/wbem/wscim/1/cim-schema/2" export URIDMTF="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2" export WSENVELOPEHEADER='' # complete pathfilenames if [ -z "${SETFLAG1}" ]; then export SETFLAG1=1 export LOGFILE="${OUTPREFIX}/${LOGFILE}" export RETURNFILE="${OUTPREFIX}/${RETURNFILE}" export MYENV="${OUTPREFIX}/.wslrun" fi # if defined, add uniqueness in generated files to allow parallel executions in same directory if [ ! -z "${RTFILEPREFIX}" ] && [ -z "${SETFLAG2}" ]; then export SETFLAG2=1 export RTFILEPREFIX="${RTFILEPREFIX}-" export LOGFILE=$( echo ${LOGFILE} | sed -e "s/\(.*\)\//\1\/${RTFILEPREFIX}/" ) export RETURNFILE=$( echo ${RETURNFILE} | sed -e "s/\(.*\)\//\1\/${RTFILEPREFIX}/" ) export MYENV=$( echo ${MYENV} | sed -e "s/\(.*\)\./\.${RTFILEPREFIX}/" ) fi [ ! -z "${DATETIMESTAMP}" ] && [ ${OUTLEVEL} -ge 3 ] && date echo -en | grep '\-en' >/dev/null 2>&1 if [ $? -ne 0 ]; then export WSCOLORCMD="echo -en \\033[0;32m" export WSCOLORREQ="echo -en \\033[0;31m" export WSCOLORRSP="echo -en \\033[0;34m" export WSCOLORWRN="echo -en \\033[0;36m" export WSCOLORERR="echo -en \\033[0;35m" export WSCOLORNORM="echo -en \\033[0;39m" else export WSCOLORCMD="echo -n " export WSCOLORREQ="echo -n " export WSCOLORRSP="echo -n " export WSCOLORWRN="echo -n " export WSCOLORERR="echo -n " export WSCOLORNORM="echo -n " fi fUsageheader() { ${WSCOLORERR} cat </dev/null ; echo $? | grep -v '^0$' ` ]; then WGETTIMEOUTSECS=180 else [ ${WGETTIMEOUTSECS} -lt 1 ] && WGETTIMEOUTSECS=1 [ ${WGETTIMEOUTSECS} -gt 600 ] && WGETTIMEOUTSECS=600 fi if [ -z "${WGETTRYNUM}" ] || [ ` echo "${WGETTRYNUM}" | grep "^[0-9]\{1,\}$" >/dev/null ; echo $? | grep -v '^0$' ` ]; then WGETTRYNUM=1 else [ ${WGETTRYNUM} -lt 1 ] && WGETTRYNUM=1 [ ${WGETTRYNUM} -gt 6 ] && WGETTRYNUM=6 fi unset WSOPT_OPERATIONTIMEOUT if [ ! -z "${WSOPERATIONTIMEOUT}" ]; then WSOPT_OPERATIONTIMEOUT="PT${WSOPERATIONTIMEOUT}.000S" fi unset WSOPT_WSMAXENVELOPESIZE if [ ! -z "${WSMAXENVELOPESIZE}" ]; then WSOPT_WSMAXENVELOPESIZE="${WSMAXENVELOPESIZE}" fi } fInitEnum() { if [ ! -z "${WSENUMMAXELEM}" ]; then if [ ` echo "${WSENUMMAXELEM}" | grep "^[0-9]\{1,\}$" >/dev/null ; echo $? | grep -v 0 ` ]; then WSENUMMAXELEM=512 else [ ${WSENUMMAXELEM} -lt 1 ] && WSENUMMAXELEM=1 [ ${WSENUMMAXELEM} -gt 1048576 ] && WSENUMMAXELEM=1048576 fi fi if [ ! -z "${WSENUMOPTIMIZE}" ]; then WSENUMOPTIMIZEDSTR="" if [ ! -z "${WSENUMMAXELEM}" ]; then WSENUMMAXELEMSTR="${WSENUMMAXELEM}" WSPULLMAXELEMSTR="${WSENUMMAXELEM}" fi fi } [ -z "${WSLNOINIT}" ] && fInitWGET [ -z "${WSLNOINIT}" ] && fInitEnum unset TIMERSTART fTimerInit() { export TIMERSTART=`date +%s` } fTimerPrint() { if [ -z "${TIMERSTART}" ]; then echo "TIMER not initialized" return fi TIMERSTOP=`date +%s` TIMERDIFF=$((TIMERSTOP - TIMERSTART)) ((h=TIMERDIFF/3600)) ((m=TIMERDIFF%3600/60)) ((s=TIMERDIFF%60)) printf "Elapsed time: %dh:%dm:%ds\n" $h $m $s } fPromptUser() { AlwaysAsk="$1" Arg=$2 Question=$3 temp=128 if [ ! -z "$4" ]; then if [ ` echo "$4" | grep "^[0-9]\{1,\}$" >/dev/null ; echo $? | grep 0 ` ]; then temp=$4 else default="$4" fi fi #shell in BSD chokes on -n argument #Len="-n ${temp} -e " Len="-e" temp=$(eval echo \$${Arg}) [ ! -z "${temp}" ] && default=${temp} temp= if [ ! "${AlwaysAsk}" = "0" -o "${default}." = "." ]; then if [ "${default}." = "." -o ! "${WSDONTASK}" = "y" ]; then if [ -e "${MYENV}" ] && [ "1" = "${SHOWHISTORY}" ]; then echo -e "\nPrevious Values:" grep "${Arg}" ${MYENV} | cut -d'=' -f2 | sed 's/"//g' | uniq | sort echo fi while [ "${temp}." = "." ]; do read ${Len} -p "${Question} (ENTER for default: ${default}) ? " temp [ -z "${temp}" ] && temp=${default} done temp=$(echo ${temp} | sed 's/^"//' | sed 's/"$//') export ${Arg}="${temp}" else temp=${default} fi [ "1" = "${KEEPHISTORY}" ] && echo export "${Arg}=\"${temp}\"" >>${MYENV} else temp=${default} fi temp= default= } fGetUUID() { UUID=`uuidgen` } ## NOTES: ## For more restriction, suggest to use the following but will need SUDO access ## dmidecode | grep -i 'uuid:' | cut -d':' -f2 - | sed 's/ //g' ## fCreateCredFile() { credfile="$1" echo "${WSUSER} ${WSPASS}" | gpg --armor -c --batch --passphrase=`uname -n` - >"${credfile}" 2>"${LOGFILE}" } fGetCredFileContents() { credfile="$1" which gpg 2>&1 >/dev/null if [ $? -eq 0 ]; then export CREDPAIR=$(gpg -d --batch --passphrase=`uname -n` "${credfile}" 2>"${LOGFILE}") else $WSCOLORERR; echo "ERROR: can't decode credential, gpg not found"; $WSCOLORNORM usage fi } fSetWGET() { WSIP=${WSENDPOINT} WSCACERT="${WSENDPOINT}.crt" `echo ${WSIP} | grep ':' >/dev/null 2>&1` || WSIP="${WSIP}:443" XPORT="https" CERTCHECK="--no-check-certificate" [ -z "${USEWGET}" ] && CERTCHECK="--insecure" [ -f ${WSCACERT} ] && CERTCHECK="--cacert ${WSCACERT}" [ ! -z "${WSNOSSL}" ] && XPORT="http" && unset CERTCHECK [ -z "${WSENCODE}" ] && WSENCODE="utf-8" export BURL="${XPORT}://${WSIP}/wsman" echo "${WSUSER}" | grep "^FILE:" >/dev/null 2>&1 if [ $? -eq 0 ]; then credfile=$(echo "${WSUSER}" | sed 's/^FILE://') fGetCredFileContents "${credfile}" WSUSER=$(echo "${CREDPAIR}" | awk '{print $1}') WSPASS=$(echo "${CREDPAIR}" | awk '{print $2}') fi export WGOPT="${BURL} ${CERTCHECK} --http-user=${WSUSER} --http-password=${WSPASS} --timeout=${WGETTIMEOUTSECS} --tries=${WGETTRYNUM} --header='Content-Type: application/soap+xml;charset=${WSENCODE}' " if [ -z "${USEWGET}" ]; then export WGOPT="${BURL} ${CERTCHECK} --user ${WSUSER}:${WSPASS} --retry ${WGETTRYNUM} --connect-timeout ${WGETTIMEOUTSECS} -H 'Content-Type: application/soap+xml;charset=${WSENCODE}' " [ ${OUTLEVEL} -ge 3 ] && WGOPT="${WGOPT} -D - " fi unset WSPASS #[ ${OUTLEVEL} -ge 3 ] && echo "using: ${WGOPT}" export WSCOMMONHEADER=`cat <${BURL} ${WSOPT_WSMAXENVELOPESIZE} ${WSOPT_OPERATIONTIMEOUT} EOF` } fSendRequest() { ECHOSUB="${LOGFILE}" [ ${OUTLEVEL} -ge 3 ] && ECHOSUB="/dev/stdout" if [ ! -z "${USEWGET}" ]; then echo "wget ${WGOPT} --post-file=${REQUESTFILE} --output-document=${RESPONSEFILE}" >>${ECHOSUB} bash --norc -c "wget ${WGOPT} --post-file=${REQUESTFILE} --output-document=${RESPONSEFILE} >>${LOGFILE} 2>&1" else echo "curl ${WGOPT} -d @${REQUESTFILE} -o ${RESPONSEFILE}" >>${ECHOSUB} bash --norc -c "curl ${WGOPT} -d @${REQUESTFILE} -o ${RESPONSEFILE} >>${LOGFILE} 2>&1" fi } fReqRspNext() { RRINDEX=$((RRINDEX + 1)) export REQUESTFILE="${OUTPREFIX}/${RTFILEPREFIX}request-${RRINDEX}.xml" export RESPONSEFILE="${OUTPREFIX}/${RTFILEPREFIX}response-${RRINDEX}.xml" cat /dev/null >${REQUESTFILE} cat /dev/null >${RESPONSEFILE} } fDumpRequestFile() { if [ ${OUTLEVEL} -ge 2 ]; then $WSCOLORREQ cat ${REQUESTFILE} $WSCOLORNORM [ ! -z "${DATETIMESTAMP}" ] && [ ${OUTLEVEL} -ge 3 ] && date fi } fSearchValueOf() { file=$1; shift sindex=$1; shift keys="$@" unset PVALUE active=0 found=1 while read -e line ; do if [ ${active} -eq 0 ]; then llower=$(echo "${line}" | awk '{print tolower($0)}') [ ` echo "${llower}" | grep ":body" >/dev/null ; echo $? | grep 0 ` ] && active=1 else flag=1 ; idx=0 for item in ${keys}; do [ ${idx} -eq 0 ] && item=":${item}" && idx=$((idx + 1)) if [ ` echo "${line}" | grep "${item}" >/dev/null ; echo $? | grep -v 0 ` ]; then flag=0 break fi done if [ ${flag} -eq 1 ]; then if [ ${found} -eq ${sindex} -o ${sindex} -eq 0 ]; then export PVALUE=$(echo "${line}" | awk -F'>' '{print $2}' | awk -F"' -f2 | cut -d'<' -f1 ) } fGetValueOf() { file=$1; shift fSearchValueOf ${file} 0 $@ return } fGetInstanceToFile() { file=$1 classname=$2 instfile=$3 [ -z "${instfile}" ] && return echo >${instfile} cstate=0 while read -e line ; do if [ ` echo "${line}" | grep ":${classname}>" >/dev/null ; echo $? | grep 0 ` ]; then cstate=$((cstate + 1)) if [ ${cstate} -eq 2 ]; then break else export NSPREFIX=$(echo ${line} | awk -F':' '{print $1}' | awk -F'<' '{print $2}') fi elif [ ${cstate} -eq 1 ]; then echo "${line}" >>${instfile} fi done < "${file}" } fGetEPRSELECTOR() { file=$1 cstate=0 unset eprstr while read -e line ; do llower=$(echo "${line}" | awk '{print tolower($0)}') if [ ` echo "${llower}" | grep ":referenceparameters" >/dev/null ; echo $? | grep 0 ` ]; then cstate=$((cstate + 1)) if [ ${cstate} -eq 2 ]; then break fi elif [ ${cstate} -eq 1 ]; then if [ ` echo "${llower}" | grep ":resourceuri" >/dev/null ; echo $? | grep 0 ` ]; then export RURI=$(echo "${line}" | awk -F'>' '{print $2}' | awk -F"/dev/null ; echo $? | grep 0 ` ]; then cstate=$((cstate + 1)) if [ ${cstate} -eq 2 ]; then break fi elif [ ${cstate} -eq 1 ]; then eprstr="${eprstr}${line}" fi done < "${file}" export EPRXML="${eprstr}" } fNormalizeXML() { xml="$1" if [ -s "${xml}" ]; then grep 'soap-envelope' ${xml} >/dev/null 2>&1 if [ "$?" -eq "0" ]; then tmp="${OUTPREFIX}/${RTFILEPREFIX}xform.xml" /bin/mv "${xml}" "${tmp}" cat "${tmp}" | xmllint --format - >"${xml}" else echo "file ${xml} is not in SOAP format, check the file and ${LOGFILE}." fi else echo "file ${xml} is empty, verify credentials and check ${LOGFILE}." fi } fNormalizeClass() { echo "${CLASS}" | grep '/' >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "${CLASS}" | grep -i "^cim_" >/dev/null 2>&1 if [ $? -ne 0 ]; then export CLASS="${URIDEFAULT}/${CLASS}" else export CLASS="${URIDMTF}/${CLASS}" fi fi } fCheckReqOrUsage() { name="$1" which ${name} 2>/dev/null >/dev/null [ $? -ne 0 ] && echo -e "Failed to detect ${name}! This is a runtime requirement, verify installation and try again.\n" && usage } fCheckReqsOrUsage() { if [ ! -z "${USEWGET}" ]; then fCheckReqOrUsage wget else fCheckReqOrUsage curl fi fCheckReqOrUsage xmllint } XsLTSTAT=1 ; which xsltproc 2>&1 >/dev/null ; XsLTSTAT=$? fDisplayResponse() { vFile="$1" if [ ${OUTLEVEL} -ge 1 ]; then ISSOAP=1; grep 'soap-envelope' ${vFile} >/dev/null 2>&1 ; ISSOAP=$? $WSCOLORRSP [ ${STAT} -ne 0 ] && $WSCOLORERR if [ -z "${FORMATDISPLAY}" ] || [ ${XsLTSTAT} -ne 0 ] || [ ${ISSOAP} -ne 0 ]; then cat ${vFile} ; echo else cat ${vFile} | sed 's/^\s*//g' | tr -d '\n' | xsltproc ${MYPATH}/wsl-ws2textc.xsl - fi $WSCOLORNORM fi [ ! -z "${DATETIMESTAMP}" ] && [ ${OUTLEVEL} -ge 3 ] && date } fGetTarget() { askA=0 ; askB=0 [ "${IPINTERACTIVE}" = "1" ] && askA=1 [ "${IPINTERACTIVE}" = "2" ] && askA=1 && askB=1 [ ! -z "${WSAUTOMATED}" ] && askA=0 && askB=0 fPromptUser $askA WSENDPOINT "IP address" fPromptUser $askB WSUSER "User name" echo "${WSUSER}" | grep "^FILE:" >/dev/null 2>&1 [ $? -ne 0 ] && fPromptUser $askB WSPASS "User password" } if [ -z "${WSLNOINIT}" ] && [ "1" = "${KEEPHISTORY}" ]; then [ ${OUTLEVEL} -ge 3 ] && [ -e "${MYENV}" ] && echo "using values in ${MYENV}" CWSENDPOINT="${WSENDPOINT}" CWSUSER="${WSUSER}" CWSPASS="${WSPASS}" if [ -e "${MYENV}" ]; then . ${MYENV} cat ${MYENV} | grep -v "^#" | sort | uniq >temp fi echo "##### history ends #####" >>temp /bin/mv temp ${MYENV} [ -z "${CWSENDPOINT}" ] && CWSENDPOINT="${WSENDPOINT}" [ -z "${CWSUSER}" ] && CWSUSER="${WSUSER}" [ -z "${CWSPASS}" ] && CWSPASS="${WSPASS}" cat <>${MYENV} export WSENDPOINT="${CWSENDPOINT}" export WSUSER="${CWSUSER}" export WSPASS="${CWSPASS}" EOF . ${MYENV} fi fMessageThenExit() { message="$1" exitcode=$2 echo -e "${message}" exit ${exitcode} } # ########################################################################### # End of Code # ########################################################################### ./wsl-0.2.1/VERSION0000644000175000017500000000001612046033327012455 0ustar jaredjaredversion=0.2.1 ./wsl-0.2.1/viwsl0000755000175000017500000000013012046033327012474 0ustar jaredjared#!/bin/bash # source function library . ${0%/*}/wsl-functions vi ${HOME}/${MYCONFIG} ./wsl-0.2.1/wslput0000755000175000017500000002064212046033327012700 0ustar jaredjared#!/bin/bash # ########################################################################### # Copyright (c) 2011, Dell Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Dell Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### # Authors: Chris A. Poblete # Version: 1.0.0 # ########################################################################### MYNAME=`basename $0` WSENUMMAXELEM=512 # source function library . /etc/wsl/wsl-functions usage() { fUsageheader cat < ${WSNS} EOF` fi dopullX() { fGetUUID fReqRspNext cat <${REQUESTFILE} ${WSENVELOPEHEADER} http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull ${WSCOMMONHEADER} ${CLASS} ${UUID} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${CONTEXT} ${WSPULLMAXELEMSTR} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest fNormalizeXML ${RESPONSEFILE} unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE} grep 'PullResponse' ${RESPONSEFILE} 2>&1 >/dev/null export STAT=$? } doenumerateX() { fGetUUID fReqRspNext cat <${REQUESTFILE} ${WSENVELOPEHEADER} http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate ${WSCOMMONHEADER} ${CLASS} ${UUID} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${REQSELECTORS} ${WSENUMOPTIMIZEDSTR} ${WSENUMMAXELEMSTR} ${EPR} ${CQLQUERY} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest fNormalizeXML ${RESPONSEFILE} unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE} grep 'EnumerateResponse' ${RESPONSEFILE} 2>&1 >/dev/null export STAT=$? } doenumerate() { doenumerateX [ ${OUTLEVEL} -ge 3 ] && ( $WSCOLORRSP; [ ${STAT} -ne 0 ] && $WSCOLORERR ; cat ${RESPONSEFILE} ; $WSCOLORNORM ) while [ ! -z "${CONTEXT}" ]; do dopullX [ ${OUTLEVEL} -ge 3 ] && ( $WSCOLORRSP; [ ${STAT} -ne 0 ] && $WSCOLORERR ; cat ${RESPONSEFILE} ; $WSCOLORNORM ) echo "(${CONTEXT})" done } doput() { fGetUUID fReqRspNext cat <${REQUESTFILE} ${WSENVELOPEHEADER} http://schemas.xmlsoap.org/ws/2004/09/transfer/Put ${WSCOMMONHEADER} ${RURI} ${UUID} ${FRAGMENTXFER} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${EPRSELECTORSTR} ${PUTPAYLOAD} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest fNormalizeXML ${RESPONSEFILE} grep "_OUTPUT" ${RESPONSEFILE} 2>&1 >/dev/null export STAT=$? } [ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Enumerate operation may take time to reply." EPR="EnumerateObjectAndEPR" WSENUMMAXELEM=256 WSENUMOPTIMIZE=1 fInitEnum doenumerate FileObjEpr="${RESPONSEFILE}" if [ ${STAT} -eq 0 ]; then fGetEPRSELECTOR ${FileObjEpr} if [ -z "${RCLASS}" ]; then echo "Failed to extract ResourceURI from the response, verify class name and filter if any." exit 1 fi if [ ! -z "${FRAGMENT}" ]; then FRAGMENTXFER="${NameList[0]}" PUTPAYLOAD="" for (( index = 0; index < ${#NameList[@]}; index++ )); do Name=${NameList[$index]} Value=${ValueList[$index]} PUTPAYLOAD="${PUTPAYLOAD}<${Name}>${Value}" done PUTPAYLOAD="${PUTPAYLOAD}" else FileInstanceonly="${OUTPREFIX}/tmpinstanceonly.xml" fGetInstanceToFile ${FileObjEpr} ${RCLASS} ${FileInstanceonly} PUTPAYLOAD="<${NSPREFIX}:${RCLASS} xmlns:${NSPREFIX}=\"${RURI}\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" index=0 while read -e line ; do if [ $index -lt ${#NameList[@]} ]; then Name=${NameList[$index]} if [ ` echo "${line}" | grep ":${Name}" ` ]; then Value=${ValueList[$index]} PUTPAYLOAD="${PUTPAYLOAD}<${NSPREFIX}:${Name}>${Value}" index=$((index + 1)) continue fi fi PUTPAYLOAD="${PUTPAYLOAD}${line}" done < "${FileInstanceonly}" PUTPAYLOAD="${PUTPAYLOAD}" fi [ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Invoke operation may take time to reply." doput fi fDisplayResponse ${RESPONSEFILE} /bin/cp ${RESPONSEFILE} ${RETURNFILE} [ ${OUTLEVEL} -ge 3 ] && echo "Output is saved to ${RETURNFILE}" exit ${STAT} # ########################################################################### # End of Code # ########################################################################### ./wsl-0.2.1/wsl-config0000644000175000017500000000262112046033327013404 0ustar jaredjared## NOTE: Sample config file. ## To make use, copy this file to ~/.wsl-config and customize. ## See the accompanying README file for more info. ## Timeout in seconds waiting for response. { 1...600} Default is 60. #WGETTIMEOUTSECS=60 ## Number of retry when there is no response. { 1...6 } Default is 1. #WGETTRYNUM=1 ## Use HTTP connection. Default is use HTTPS. Uncomment var for HTTP. #WSNOSSL=true ## Optimized enumeration, required for WSENUMMAXELEM. Default is optimized. Uncomment var for non-optimized. #WSENUMOPTIMIZE= ## Max number of instances in a response. { 1...1048576 } Default is 512. #WSENUMMAXELEM=512 ## Schema prefix used for non-DMTF class. Default is "schemas.dell.com" #WSDEFAULTSCHEMA="schemas.dell.com" ## Interactive level: 0=NoAsk, 1=AskIPAddress, 2=AskIPandCredential. Default is 0. #IPINTERACTIVE=2 ## Remember IP address and user credential. Default is keep history. Uncomment var to prevent history use. #KEEPHISTORY=0 ## Display date-time stamp. Default is disabled. #DATETIMESTAMP=true ## Formatted display of response XML. Default is disabled. #FORMATDISPLAY=true ## Output level: 0=NoOutput, 1=ResponseOnly, 2=AddRequest, 3=AddMore. Default is 1. #OUTLEVEL=3 ## Output directory. Default is current directory. #OUTPREFIX=. ## Log filename. Default is /log.txt #LOGFILE="$OUTPREFIX/log.txt" ## Result XML filename. Default=/response.xml #RETURNFILE="$OUTPREFIX/response.xml" ./wsl-0.2.1/LICENSE0000644000175000017500000000322112046033327012413 0ustar jaredjared # ########################################################################### # Copyright (c) 2011, Dell Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Dell, Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### ./wsl-0.2.1/wsl-ws2textc.xsl0000644000175000017500000000717612046033327014541 0ustar jaredjared 1 [EMPTY] [EMPTY] * ./wsl-0.2.1/wslinvoke0000755000175000017500000002147512046033327013370 0ustar jaredjared#!/bin/bash # ########################################################################### # Copyright (c) 2011, Dell Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Dell Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### # Authors: Chris A. Poblete # Version: 1.0.0 # ########################################################################### MYNAME=`basename $0` WSENUMMAXELEM=512 # source function library . /etc/wsl/wsl-functions usage() { fUsageheader cat </dev/null 2>&1 if [ $? -eq 0 ]; then filename=$(echo "${Value}" | cut -d ':' -f2- ) echo "using ${filename} to extract EPR XML for parameter ${Name}" Value=$(cat ${filename}) fi fi PARAMLIST="${PARAMLIST}${Value}" fi ;; esac shift done [ ! -z "${PARAMLIST}" ] && [ ${OUTLEVEL} -ge 3 ] && echo -en "## ${PARAMLIST}\n\n" # initializations fGetTarget fSetWGET fNormalizeClass [ ! -z "${CQL}" ] && CQLQUERY="${CQL}" if [ ! -z "${WSNS}" ]; then REQSELECTORS=`cat < ${WSNS} EOF` fi dopullX() { fGetUUID fReqRspNext cat <${REQUESTFILE} ${WSENVELOPEHEADER} http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull ${WSCOMMONHEADER} ${CLASS} ${UUID} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${CONTEXT} ${WSPULLMAXELEMSTR} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest fNormalizeXML ${RESPONSEFILE} unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE} grep 'PullResponse' ${RESPONSEFILE} 2>&1 >/dev/null export STAT=$? } doenumerateX() { fGetUUID fReqRspNext cat <${REQUESTFILE} ${WSENVELOPEHEADER} http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate ${WSCOMMONHEADER} ${CLASS} ${UUID} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${REQSELECTORS} ${WSENUMOPTIMIZEDSTR} ${WSENUMMAXELEMSTR} ${EPR} ${CQLQUERY} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest fNormalizeXML ${RESPONSEFILE} unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE} grep 'EnumerateResponse' ${RESPONSEFILE} 2>&1 >/dev/null export STAT=$? } doenumerate() { doenumerateX [ ${OUTLEVEL} -ge 3 ] && ( $WSCOLORRSP; [ ${STAT} -ne 0 ] && $WSCOLORERR ; cat ${RESPONSEFILE} ; $WSCOLORNORM ) while [ ! -z "${CONTEXT}" ]; do dopullX [ ${OUTLEVEL} -ge 3 ] && ( $WSCOLORRSP; [ ${STAT} -ne 0 ] && $WSCOLORERR ; cat ${RESPONSEFILE} ; $WSCOLORNORM ) echo "(${CONTEXT})" done } doinvoke() { fGetUUID fReqRspNext if [ ! -z "${RAW}" ]; then PARAMBODY=`cat ${RAW}` else PARAMBODY=`cat < ${PARAMLIST} EOF` fi cat <${REQUESTFILE} ${WSENVELOPEHEADER} ${RURI}/${METHOD} ${WSCOMMONHEADER} ${RURI} ${UUID} http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous ${EPRSELECTORSTR} ${PARAMBODY} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest fNormalizeXML ${RESPONSEFILE} grep "_OUTPUT" ${RESPONSEFILE} 2>&1 >/dev/null export STAT=$? } if [ ! -z "${InstanceFile}" ]; then fGetEPRSELECTOR ${InstanceFile} else [ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Enumerate operation may take time to reply." EPR="EnumerateEPR" doenumerate fGetEPRSELECTOR ${RESPONSEFILE} fi if [ ! -z "${EPRSELECTORSTR}" ]; then [ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Invoke operation may take time to reply." doinvoke fi fDisplayResponse ${RESPONSEFILE} /bin/cp ${RESPONSEFILE} ${RETURNFILE} [ ${OUTLEVEL} -ge 3 ] && echo "Output is saved to ${RETURNFILE}" exit ${STAT} # ########################################################################### # End of Code # ########################################################################### ./wsl-0.2.1/wsl.10000755000175000017500000000663412046033327012313 0ustar jaredjared.TH WSL 1 "" "" "User Commands" .SH NAME wsl \- A shell based command line client for WSMAN servers .SH DESCRIPTION \fIwsl\fP (aka "whistle") contains various scripts that serve as a client interface to WSMAN or Web Services for Management protocol based on DMTF standard specification. WSMAN provides standards based messaging for systems management CIM-style objects. .PP To talk to a remote WSMAN service, start with "wsl id check". This command will request the IP address, user name and password for the remote server and populate a file ".wslrun" in the current directory. After the first run, you can use the commands listed below without having to provide IP address, user name and password repeatedly. This is the default behavior. However, you can configure wsl so that it always ask for IP address or IP address and user credential for each command in case you want to work with more than one target. .PP The environmental variables that could affect the behavior of wsl are listed in README file. .PP Help information is provided at different levels. Typing "wsl" provides help information about available commands. Typing "wsl enum" provides help information about enum command and its parameters. Typing "wsl enum help" gives the same information. .PP .SH OPTIONS .TP \fBe\fR|enum|enumerate Sends SOAP message with WS-MAN ENUMERATE command. Equivalent to calling "wslenum" directly. .TP \fBid\fR|identify Sends SOAP message with WS-MAN IDENTIFY command. Equivalent to calling "wslid" directly. .TP \fBi\fR|invoke Sends SOAP message with WS-MAN INVOKE command. Equivalent to callint "wslinvoke" directly. .TP \fBg\fR|get Sends SOAP message with WS-MAN GET command. Equivalent to calling "wslget" directly. .TP \fBp\fR|put Sends SOAP message with WS-MAN PUT command. Equivalent to calling "wslput" directly. .TP \fBs\fR|set See put. .TP \fBxcert\fR Command to extract SSL certificate of the server hosting WSMAN. .TP \fBxclean\fR Command to remove/delete the files generated by this tool. .TP \fBxcred\fR Command to encrypt username and password to a file. The same command can be used for decrypting the same file for verification. Equivalent to calling "wslcred" directly. .PP .SH AUTHENTICATION wsl supports basic and digest authentication mechanism. You will be prompted for user name and password at run time or you can provide their values to environment variables WSUSER and WSPASS. A more secure method is to use the light encryption method provided by wsl. See the xcred command option. It will create a credential file that contains the encrypted form of the user name and password. To use, simply provide the filename to WSUSER prefixed with "FILE:". You do not have to provide WSPASS in this case. .PP .SH FILES .TP \fB~/.wsl-config\fR This file contains custom user-configurable information that could affect the behavior of wsl. If not present, this file is created the firt time wsl is used. Refer to README file for more information. .TP \fB$PWD/.wslrun\fR This file contains environment variables that are populated the first time wsl is run and used on subsequent runs. It includes user password so if security is a concern, try to use the encrypted version (see xcred command) or you may turn off creation of this file using the custom user configuration (see .wsl-config). .SH COPYRIGHT wsl is Copyright (c) 2011, Dell Inc. License: BSD3C or similar .SH AUTHORS Created by Chris A. Poblete . ./wsl-0.2.1/wsl0000755000175000017500000000765612046033327012161 0ustar jaredjared#!/bin/bash # ########################################################################### # Copyright (c) 2011, Dell Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Dell Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### # Authors: Chris A. Poblete # Version: 1.0.0 # ########################################################################### MYNAME=`basename $0` MYPATH=${0%/*} NODATEDUMP=1 KEEPHISTORY=0 # source function library . /etc/wsl/wsl-functions usage() { fUsageheader cat <.crt) PARAMS specification is specific to a COMMAND. ${CommonUsage1} EOF $WSCOLORNORM exit 1 } cleanup() { quiet="$1" $WSCOLORERR cat </dev/null 2>&1 ls -al cd - } getcert() { ipaddress=$1 [ -z "${ipaddress}" ] && ipaddress="${WSENDPOINT}" [ -z "${ipaddress}" ] && usage outfile="${ipaddress}.crt" (echo | openssl s_client -connect ${ipaddress}:443 2>&1 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' 2>&1)|tee ${outfile} } export WSENUMOPTIMIZE=1 export WSENUMMAXELEM=512 [ "${ECHOCMD}" = "true" ] && echo -e "$0 $@" [ $# -lt 1 ] && usage CMD="$1"; shift case "${CMD}" in e|enum|enumerate) ${SHELL} ${MYPATH}/wslenum "$@" ; STAT=$? ;; g|get) ${SHELL} ${MYPATH}/wslget "$@" ; STAT=$? ;; p|s|put|set) ${SHELL} ${MYPATH}/wslput "$@" ; STAT=$? ;; id|identify) ${SHELL} ${MYPATH}/wslid "$@" ; STAT=$? ;; i|invoke) ${SHELL} ${MYPATH}/wslinvoke "$@" ; STAT=$? ;; xclean) cleanup $1 ; STAT=0 ;; xcred) ${SHELL} ${MYPATH}/wslcred "$@" ; STAT=$? ;; xcert) getcert $1 ; STATU=0 ;; *) echo "Unknown command: ${CMD}" ; usage ;; esac exit ${STAT} # ########################################################################### # End of Code # ########################################################################### ./wsl-0.2.1/wslcred0000755000175000017500000000541512046033327013006 0ustar jaredjared#!/bin/bash # ########################################################################### # Copyright (c) 2011, Dell Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Dell Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### # Authors: Chris A. Poblete # Version: 1.0.0 # ########################################################################### MYNAME=`basename $0` MYPATH=${0%/*} KEEPHISTORY=0 # source function library . /etc/wsl/wsl-functions usage() { fUsageheader cat </dev/null 2>&1 if [ $? -eq 0 ]; then fGetCredFileContents "${credfile}" echo "${CREDPAIR}" else echo >${credfile} [ -z "${WSUSER}" ] && fPromptUser 0 WSUSER "User name" [ -z "${WSPASS}" ] && fPromptUser 0 WSPASS "User password" fCreateCredFile ${credfile} fi exit 0 # ########################################################################### # End of Code # ########################################################################### ./wsl-0.2.1/README-wsl0000644000175000017500000000726412046033327013104 0ustar jaredjaredThis file contains summary information about the containing package. WSL = Wsman Shell commandLine a.k.a. "whistle" ============================================================================= REVISION ============================================================================= 0.1.0 - Creation of this package. 0.1.5 - First public release. 0.2.0 - Use curl as defult and wget as alternate ============================================================================= DESCRIPTION ============================================================================= WSL contains various scripts that serve as a client interface to WSMAN or Web Services for Management protocol based on DMTF standard specification. WSMAN provides standards based messaging for systems management CIM-style objects. WSL is "lightweight" because it is composed of scripts (that is no binary) and is dependent on tools that are already present on standard installation or readily available to UNIX-like operating systems. ============================================================================= REQUIREMENTS ============================================================================= The tools in this package requires the following to run: * bash and other GNU core utilities such as sed, awk and grep * curl - utility for getting files from remote (HTTP/HTTS) servers * xmllint - LIBXML2 utility * (optional) xsltproc - LIBXML2 utility for output formatting * (optional) gpg - encryption utility for password * (optional) wget - alternate to curl It may run on Windows operating system by installing CYGWIN or similar port of GNU shell environment and tools. ============================================================================= EXECUTION ============================================================================= Each script shall have its own usage help text. You can customize run-time experience by defining variables in the shell environment or in a "wsl-config" file located in the current or program directory. Connection variables: USEWGET - Use wget for transmission. Default is curl. WGETTIMEOUTSECS - Wget timeout in seconds waiting for response. { 1...600} Default is 60. WGETTRYNUM - Wget number of retry when there is no response. { 1...6 } Default is 1. WSNOSSL - Use HTTP connection. Default is use HTTPS. Wsman options: WSENUMMAXELEM - Max number of instances in a response. { 1...1048576 } Default is 512. WSENUMOPTIMIZE - Optimized enumeration. Default is non-optimized. WSDEFAULTSCHEMA - Schema prefix used for non-DMTF class. Default is "schemas.dell.com" WSOPERATIONTIMEOUT - WSMAN operation timeout in seconds. Default is none specified. WSMAXENVELOPESIZE - Max SOAP envelope size client will accept. Default is none specified. User input: IPINTERACTIVE - Always ask for IP address. Default is use history. KEEPHISTORY - Remember IP address and user credential. Default is keep history. Output behavior: DATETIMESTAMP - Display date-time stamp. Default is disabled. FORMATDISPLAY - Formatted display of response XML. Default is disabled. OUTLEVEL - Output level: 0=NoOutput, 1=AddResponse, 2=AddRequest, 3=AddMore. Default is 1. OUTPREFIX - Output directory. Default is current directory. LOGFILE - Log filename. Default is $OUTPREFIX/log.txt RETURNFILE - Result XML filename. Default=$OUTPREFIX/response.xml ============================================================================= USE AGREEMENT ============================================================================= See accompanying LICENSE file. ============================================================================= [End of Document] ============================================================================= ./wsl-0.2.1/wslid0000755000175000017500000000554512046033327012471 0ustar jaredjared#!/bin/bash # ########################################################################### # Copyright (c) 2011, Dell Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # * Neither the name of Dell Inc. nor the names of its contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT, # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### # Authors: Chris A. Poblete # Version: 1.0.0 # ########################################################################### MYNAME=`basename $0` # source function library . /etc/wsl/wsl-functions usage() { fUsageheader cat <${REQUESTFILE} EOF fNormalizeXML ${REQUESTFILE} fDumpRequestFile fSendRequest export STAT=$? } doidentify fNormalizeXML ${RESPONSEFILE} fDisplayResponse ${RESPONSEFILE} /bin/cp ${RESPONSEFILE} ${RETURNFILE} [ ${OUTLEVEL} -ge 3 ] && echo "Output is saved to ${RETURNFILE}" exit ${STAT} # ########################################################################### # End of Code # ###########################################################################