2
# ###########################################################################
3
# Copyright (c) 2011, Dell Inc.
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions
10
# * Redistributions of source code must retain the above copyright
11
# notice, this list of conditions and the following disclaimer.
12
# * Redistributions in binary form must reproduce the above copyright
13
# notice, this list of conditions and the following disclaimer in the
14
# documentation and/or other materials provided with the distribution.
15
# * Neither the name of Dell Inc. nor the names of its contributors
16
# may be used to endorse or promote products derived from this software
17
# without specific prior written permission.
19
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
# ARE DISCLAIMED. IN NO EVENT SHALL DELL INC. BE LIABLE FOR ANY DIRECT,
23
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
28
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
# POSSIBILITY OF SUCH DAMAGE.
30
# ###########################################################################
31
# Authors: Chris A. Poblete
33
# ###########################################################################
38
# source function library
39
. /etc/wsl/wsl-functions
44
USAGE: $MYNAME CLASS METHOD [PARAM1=VAL1 PARAM2=VAL2 ...] [OPTIONS]
46
Sends SOAP message with WS-MAN INVOKE command. This script may accept only
47
derived leaf classes unless you provide a CQL filter that can return a
48
single instance. CLASS may be a class name or an absolute class URI.
49
CLASS should be the first input and Method the second input.
50
Enclose the value in double quotes when the value contains space.
53
-filter "CQL" - Apply CQL statement filter to enumeration
54
-inst FILENAME - Contains class instance EPR
55
-ns NAMESPACE - Explicitly add the NAMESPACE selector
56
-raw FILENAME - Use raw input for the method contained in the filename
58
If CLASS has more than one instance, use the -filter option to filter the
59
enumeration to a single instance. Alternatively, use the -inst option to
60
provide the instance EPR in a previous enumeration.
63
If Value is of type EPR (endpoint reference), you can provide a file
64
that contains an instance EPR. An EPR contains EndpointReference
65
element. An example of this is:
66
ManagedElement=FILE:compsys.xml
69
If Value could not be passed through command line perhaps due to special
70
characters of contain line breaks, you can provide it in a file with
71
RFILE prefix. An example of this is a certificate value:
72
Certificate=RFILE:newad.cer
83
while [ ! -z "$1" ]; do
87
-i|-inst ) shift; InstanceFile="$1"
89
-f|-filter ) shift; CQL="$1"
91
-n|ns ) shift; WSNS="$1"
93
-r|-raw ) shift; RAW="$1"
95
* ) echo "$1" | grep '=' >/dev/null 2>&1
97
[ -z "${CLASS}" ] && export CLASS="$1" && shift && continue
98
[ -z "${METHOD}" ] && export METHOD="$1" && shift && continue
100
Name=$(echo "$1" | cut -d '=' -f1 )
101
Value=$(echo "$1" | cut -d '=' -f2- )
102
echo "${Value}" | grep "^FILE:" >/dev/null 2>&1
103
if [ $? -eq 0 ]; then
104
filename=$(echo "${Value}" | cut -d ':' -f2- )
105
echo "using ${filename} to extract EPR XML for parameter ${Name}"
106
fExtractEPRXML ${filename}
109
echo "${Value}" | grep "^RFILE:" >/dev/null 2>&1
110
if [ $? -eq 0 ]; then
111
filename=$(echo "${Value}" | cut -d ':' -f2- )
112
echo "using ${filename} to extract EPR XML for parameter ${Name}"
113
Value=$(cat ${filename})
116
PARAMLIST="${PARAMLIST}<p:${Name}>${Value}</p:${Name}>"
123
[ ! -z "${PARAMLIST}" ] && [ ${OUTLEVEL} -ge 3 ] && echo -en "## ${PARAMLIST}\n\n"
130
[ ! -z "${CQL}" ] && CQLQUERY="<wsman:Filter Dialect='http://schemas.dmtf.org/wbem/cql/1/dsp0202.pdf'>${CQL}</wsman:Filter>"
132
if [ ! -z "${WSNS}" ]; then
133
REQSELECTORS=`cat <<EOF
135
<wsman:Selector Name="__cimnamespace">${WSNS}</wsman:Selector>
143
cat <<EOF >${REQUESTFILE}
146
<wsa:Action s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</wsa:Action>
148
<wsman:ResourceURI s:mustUnderstand="true">${CLASS}</wsman:ResourceURI>
149
<wsa:MessageID s:mustUnderstand="true">${UUID}</wsa:MessageID>
151
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
156
<wsen:EnumerationContext>${CONTEXT}</wsen:EnumerationContext>
162
fNormalizeXML ${REQUESTFILE}
165
fNormalizeXML ${RESPONSEFILE}
166
unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE}
167
grep 'PullResponse' ${RESPONSEFILE} 2>&1 >/dev/null
174
cat <<EOF >${REQUESTFILE}
177
<wsa:Action s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</wsa:Action>
179
<wsman:ResourceURI s:mustUnderstand="true">${CLASS}</wsman:ResourceURI>
180
<wsa:MessageID s:mustUnderstand="true">${UUID}</wsa:MessageID>
182
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
188
${WSENUMOPTIMIZEDSTR}
196
fNormalizeXML ${REQUESTFILE}
199
fNormalizeXML ${RESPONSEFILE}
200
unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE}
201
grep 'EnumerateResponse' ${RESPONSEFILE} 2>&1 >/dev/null
207
[ ${OUTLEVEL} -ge 3 ] && ( $WSCOLORRSP; [ ${STAT} -ne 0 ] && $WSCOLORERR ; cat ${RESPONSEFILE} ; $WSCOLORNORM )
208
while [ ! -z "${CONTEXT}" ]; do
210
[ ${OUTLEVEL} -ge 3 ] && ( $WSCOLORRSP; [ ${STAT} -ne 0 ] && $WSCOLORERR ; cat ${RESPONSEFILE} ; $WSCOLORNORM )
219
if [ ! -z "${RAW}" ]; then
220
PARAMBODY=`cat ${RAW}`
223
<p:${METHOD}_INPUT xmlns:p="${RURI}">
229
cat <<EOF >${REQUESTFILE}
232
<wsa:Action s:mustUnderstand="true">${RURI}/${METHOD}</wsa:Action>
234
<wsman:ResourceURI s:mustUnderstand="true">${RURI}</wsman:ResourceURI>
235
<wsa:MessageID s:mustUnderstand="true">${UUID}</wsa:MessageID>
237
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
246
fNormalizeXML ${REQUESTFILE}
249
fNormalizeXML ${RESPONSEFILE}
250
grep "_OUTPUT" ${RESPONSEFILE} 2>&1 >/dev/null
254
if [ ! -z "${InstanceFile}" ]; then
255
fGetEPRSELECTOR ${InstanceFile}
257
[ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Enumerate operation may take time to reply."
258
EPR="<wsman:EnumerationMode>EnumerateEPR</wsman:EnumerationMode>"
260
fGetEPRSELECTOR ${RESPONSEFILE}
263
if [ ! -z "${EPRSELECTORSTR}" ]; then
264
[ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Invoke operation may take time to reply."
268
fDisplayResponse ${RESPONSEFILE}
270
/bin/cp ${RESPONSEFILE} ${RETURNFILE}
271
[ ${OUTLEVEL} -ge 3 ] && echo "Output is saved to ${RETURNFILE}"
274
# ###########################################################################
276
# ###########################################################################