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 PROP1=VAL1 [PROP2=VAL2 ...] [OPTIONS]
46
Sends SOAP message with WS-MAN PUT 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 at least one property-value pair.
50
Enclose the value in double quotes when the value contains space.
53
-filter "CQL" - Apply CQL statement filter to enumeration
54
-fragment - Perform a fragment put, applies to only one property
55
-ns NAMESPACE - Explicitly add the NAMESPACE selector
57
For array properties, specify prop=value for each index.
72
while [ ! -z "$1" ]; do
76
-f|-filter ) shift; CQL="$1"
78
-F|-fragment ) FRAGMENT=1
80
-n|-ns ) shift; WSNS="$1"
82
* ) NameList[$index]=$(echo "$1" | cut -d '=' -f1 )
83
ValueList[$index]=$(echo "$1" | cut -d '=' -f2- )
95
[ ! -z "${CQL}" ] && CQLQUERY="<wsman:Filter Dialect='http://schemas.dmtf.org/wbem/cql/1/dsp0202.pdf'>${CQL}</wsman:Filter>"
97
if [ ! -z "${WSNS}" ]; then
98
REQSELECTORS=`cat <<EOF
100
<wsman:Selector Name="__cimnamespace">${WSNS}</wsman:Selector>
108
cat <<EOF >${REQUESTFILE}
111
<wsa:Action s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</wsa:Action>
113
<wsman:ResourceURI s:mustUnderstand="true">${CLASS}</wsman:ResourceURI>
114
<wsa:MessageID s:mustUnderstand="true">${UUID}</wsa:MessageID>
116
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
121
<wsen:EnumerationContext>${CONTEXT}</wsen:EnumerationContext>
127
fNormalizeXML ${REQUESTFILE}
130
fNormalizeXML ${RESPONSEFILE}
131
unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE}
132
grep 'PullResponse' ${RESPONSEFILE} 2>&1 >/dev/null
139
cat <<EOF >${REQUESTFILE}
142
<wsa:Action s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</wsa:Action>
144
<wsman:ResourceURI s:mustUnderstand="true">${CLASS}</wsman:ResourceURI>
145
<wsa:MessageID s:mustUnderstand="true">${UUID}</wsa:MessageID>
147
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
153
${WSENUMOPTIMIZEDSTR}
161
fNormalizeXML ${REQUESTFILE}
164
fNormalizeXML ${RESPONSEFILE}
165
unset CONTEXT ; fGetFlatValueOfSingle ${RESPONSEFILE} N "EnumerationContext" ; export CONTEXT=${PVALUE}
166
grep 'EnumerateResponse' ${RESPONSEFILE} 2>&1 >/dev/null
172
[ ${OUTLEVEL} -ge 3 ] && ( $WSCOLORRSP; [ ${STAT} -ne 0 ] && $WSCOLORERR ; cat ${RESPONSEFILE} ; $WSCOLORNORM )
173
while [ ! -z "${CONTEXT}" ]; do
175
[ ${OUTLEVEL} -ge 3 ] && ( $WSCOLORRSP; [ ${STAT} -ne 0 ] && $WSCOLORERR ; cat ${RESPONSEFILE} ; $WSCOLORNORM )
183
cat <<EOF >${REQUESTFILE}
186
<wsa:Action s:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</wsa:Action>
188
<wsman:ResourceURI s:mustUnderstand="true">${RURI}</wsman:ResourceURI>
189
<wsa:MessageID s:mustUnderstand="true">${UUID}</wsa:MessageID>
192
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
201
fNormalizeXML ${REQUESTFILE}
204
fNormalizeXML ${RESPONSEFILE}
205
grep "_OUTPUT" ${RESPONSEFILE} 2>&1 >/dev/null
209
[ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Enumerate operation may take time to reply."
211
EPR="<wsman:EnumerationMode>EnumerateObjectAndEPR</wsman:EnumerationMode>"
217
FileObjEpr="${RESPONSEFILE}"
219
if [ ${STAT} -eq 0 ]; then
220
fGetEPRSELECTOR ${FileObjEpr}
221
if [ -z "${RCLASS}" ]; then
222
echo "Failed to extract ResourceURI from the response, verify class name and filter if any."
225
if [ ! -z "${FRAGMENT}" ]; then
226
FRAGMENTXFER="<wsman:FragmentTransfer s:mustUnderstand=\"true\">${NameList[0]}</wsman:FragmentTransfer>"
227
PUTPAYLOAD="<wsman:XmlFragment>"
228
for (( index = 0; index < ${#NameList[@]}; index++ )); do
229
Name=${NameList[$index]}
230
Value=${ValueList[$index]}
231
PUTPAYLOAD="${PUTPAYLOAD}<${Name}>${Value}</${Name}>"
233
PUTPAYLOAD="${PUTPAYLOAD}</wsman:XmlFragment>"
235
FileInstanceonly="${OUTPREFIX}/tmpinstanceonly.xml"
236
fGetInstanceToFile ${FileObjEpr} ${RCLASS} ${FileInstanceonly}
237
PUTPAYLOAD="<${NSPREFIX}:${RCLASS} xmlns:${NSPREFIX}=\"${RURI}\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
239
while read -e line ; do
240
if [ $index -lt ${#NameList[@]} ]; then
241
Name=${NameList[$index]}
242
if [ ` echo "${line}" | grep ":${Name}" ` ]; then
243
Value=${ValueList[$index]}
244
PUTPAYLOAD="${PUTPAYLOAD}<${NSPREFIX}:${Name}>${Value}</${NSPREFIX}:${Name}>"
249
PUTPAYLOAD="${PUTPAYLOAD}${line}"
250
done < "${FileInstanceonly}"
251
PUTPAYLOAD="${PUTPAYLOAD}</${NSPREFIX}:${RCLASS}>"
254
[ ${OUTLEVEL} -ge 3 ] && echo "NOTE: Invoke operation may take time to reply."
258
fDisplayResponse ${RESPONSEFILE}
260
/bin/cp ${RESPONSEFILE} ${RETURNFILE}
261
[ ${OUTLEVEL} -ge 3 ] && echo "Output is saved to ${RETURNFILE}"
264
# ###########################################################################
266
# ###########################################################################