Skip to content

Commit

Permalink
Merge pull request #1037 from pywbem/andy/fix-invoke-method-params
Browse files Browse the repository at this point in the history
(4x) Fixed error when invoking Invokemethod() with keyword params
  • Loading branch information
andy-maier committed Feb 5, 2018
2 parents d58fd13 + fe47b04 commit 816be1c
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pywbem/cim_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,11 +1267,12 @@ def infer_embedded_object(obj):
for p in Params:
if isinstance(p, CIMParameter):
ptuple = (p.name, p.value, p.type, p.embedded_object)
else: # tuple of name, value
else: # p is a tuple of name, value
ptuple = (p[0], p[1], infer_type(p[1]),
infer_embedded_object(p[1]))
ptuples.append(ptuple)
for ptuple in params.items():
for n, v in params.items():
ptuple = (n, v, infer_type(v), infer_embedded_object(v))
ptuples.append(ptuple)

plist = [cim_xml.PARAMVALUE(n, paramvalue(v), t, embedded_object=eo)
Expand Down
75 changes: 73 additions & 2 deletions testsuite/testclient/invokemethod.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: InvokeMethod1
description: Pass two input parameters as list of tuple(name,value), no output parameters
description: Pass two input parameters via Params as list of tuple(name,value), no output parameters
pywbem_request:
url: http://acme.com:80
creds:
Expand Down Expand Up @@ -76,7 +76,7 @@
</CIM>
- name: InvokeMethod2
description: Pass two input parameters as list of CIMParameter objects, no output parameters
description: Pass two input parameters via Params as list of CIMParameter objects, no output parameters
pywbem_request:
url: http://acme.com:80
creds:
Expand Down Expand Up @@ -229,5 +229,76 @@
</MESSAGE>
</CIM>
- name: InvokeMethod4
description: Pass one input parameter via **params as list of tuple(name,value), no output parameters
# Note: We can pass only one parameter because the **kwargs mechanism does not preserve the order
pywbem_request:
url: http://acme.com:80
creds:
- username
- password
namespace: root/cimv2
timeout: 10
debug: true
operation:
pywbem_method: InvokeMethod
MethodName: SendTestIndicationsCount
ObjectName:
pywbem_object: CIMClassName
classname: Test_IndicationProviderClass
host: null
namespace: test/TestProvider
indicationSendCount:
pywbem_object: Uint32
x: 0
pywbem_response:
result:
- 0
- {}
http_request:
verb: POST
url: http://acme.com:80/cimom
headers:
CIMOperation: MethodCall
CIMMethod: SendTestIndicationsCount
CIMObject: test/TestProvider%3ATest_IndicationProviderClass
data: >
<?xml version="1.0" encoding="utf-8" ?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
<MESSAGE ID="1001" PROTOCOLVERSION="1.0">
<SIMPLEREQ>
<METHODCALL NAME="SendTestIndicationsCount">
<LOCALCLASSPATH>
<LOCALNAMESPACEPATH>
<NAMESPACE NAME="test"/>
<NAMESPACE NAME="TestProvider"/>
</LOCALNAMESPACEPATH>
<CLASSNAME NAME="Test_IndicationProviderClass"/>
</LOCALCLASSPATH>
<PARAMVALUE NAME="indicationSendCount" PARAMTYPE="uint32">
<VALUE>0</VALUE>
</PARAMVALUE>
</METHODCALL>
</SIMPLEREQ>
</MESSAGE>
</CIM>
http_response:
status: 200
headers:
CIMOperation: MethodResponse
data: >
<?xml version="1.0" encoding="utf-8" ?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
<MESSAGE ID="1001" PROTOCOLVERSION="1.0">
<SIMPLERSP>
<METHODRESPONSE NAME="SendTestIndicationsCount">
<RETURNVALUE PARAMTYPE="sint32">
<VALUE>0</VALUE>
</RETURNVALUE>
</METHODRESPONSE>
</SIMPLERSP>
</MESSAGE>
</CIM>
# TODO 01/18 AM: Add testcases for namespaces with leading/trailing slashes

0 comments on commit 816be1c

Please sign in to comment.