Skip to content

Commit

Permalink
Fix issue with cim_opeations.py pull ops and MaxObjectCount
Browse files Browse the repository at this point in the history
Fix issue with MaxoObjectCount on PullInstances and PullInstancePaths
CIM_Operations.py methods.  The MaxObjectCount was defined as a keyword
parameter where it should have been be positional.  This should NOT
impact clients unless they did not supply the parameter at all so that
the result was None which is illegal(Pull... operations MUST include
MaxObjectCount).

Also extends these requests to test the Pull.. methods for valid
MaxObjectCount and context parameters. See issue #656

Adds mock tests for the new limits in the pull... requests and adds
pullinstance.yaml to mock tests.

Finally, changes run_cim_operations.py to use the prefered form for the
MaxObjectCount.

This pr adds a new test file for pullinstances mock tests.
  • Loading branch information
KSchopmeyer committed Jan 16, 2017
1 parent ed6c02b commit ba08669
Show file tree
Hide file tree
Showing 6 changed files with 361 additions and 67 deletions.
8 changes: 8 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Enhancements
Bug fixes
^^^^^^^^^

* Fix issue with MaxoObjectCount on PullInstances and PullInstancePaths
CIM_Operations.py methods. The MaxObjectCount was defined as a keyword
parameter where it should have been be positional. This should NOT impact
clients unless they did not supply the parameter at all so that the result
was None which is illegal(Pull... operations MUST include MaxObjectCount).
Also extends these requests to test the Pull.. methods for valid
MaxObjectCount and context parameters. See issue #656.

Build, test, quality
^^^^^^^^^^^^^^^^^^^^

Expand Down
32 changes: 30 additions & 2 deletions pywbem/cim_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,24 @@ def _validateIterCommonParams(MaxObjectCount, OperationTimeout):
OperationTimeout)


def _validatePullParams(MaxObjectCount, context):
"""
Validate the input paramaters for the PullInstances,
PullInstancesWithPath, and PullInstancePaths.
MaxObjectCount: Must be integer type and ge 0
context: Must be not None and length ge 2
"""
if (not isinstance(MaxObjectCount, six.integer_types) or
MaxObjectCount < 0):
raise ValueError('MaxObjectCount parameter must be integer >= 0 but '
' is %s' % MaxObjectCount)
if context is None or len(context) < 2:
raise ValueError('Pull... Context parameter must be valid tuple %s'
% context)


class WBEMConnection(object): # pylint: disable=too-many-instance-attributes
"""
A client's connection to a WBEM server. This is the main class of the
Expand Down Expand Up @@ -5268,6 +5286,7 @@ def PullInstancesWithPath(self, context, MaxObjectCount,
* If zero, the WBEM server is to return no instances. This may
be used by a client to leave the handling of any returned
instances to a loop of Pull operations.
* None is not allowed for this attribute.
Keyword Arguments:
Expand Down Expand Up @@ -5337,6 +5356,7 @@ def PullInstancesWithPath(self, context, MaxObjectCount,
**extra)

try:
_validatePullParams(MaxObjectCount, context)

namespace = context[1]

Expand All @@ -5362,7 +5382,7 @@ def PullInstancesWithPath(self, context, MaxObjectCount,
self.operation_recorder.record_staged()
return result_tuple

def PullInstancePaths(self, context, MaxObjectCount=None, **extra):
def PullInstancePaths(self, context, MaxObjectCount, **extra):
# pylint: disable=invalid-name

"""
Expand Down Expand Up @@ -5403,6 +5423,7 @@ def PullInstancePaths(self, context, MaxObjectCount=None, **extra):
* If zero, the WBEM server is to return no instances. This may
be used by a client to leave the handling of any returned
instances to a loop of Pull operations.
* None is not allowed for this attribute.
Keyword Arguments:
Expand Down Expand Up @@ -5469,9 +5490,14 @@ def PullInstancePaths(self, context, MaxObjectCount=None, **extra):
**extra)

try:
_validatePullParams(MaxObjectCount, context)

namespace = context[1]

if MaxObjectCount is None or MaxObjectCount < 0:
raise ValueError('MaxObjectCount must be >= 0 but is %s' %
MaxObjectCount)

result = self._imethodcall(
'PullInstancePaths',
namespace=namespace,
Expand All @@ -5494,7 +5520,7 @@ def PullInstancePaths(self, context, MaxObjectCount=None, **extra):
self.operation_recorder.record_staged()
return result_tuple

def PullInstances(self, context, MaxObjectCount=None, **extra):
def PullInstances(self, context, MaxObjectCount, **extra):
# pylint: disable=invalid-name
"""
Retrieve the next set of instances from an open enumeraton
Expand Down Expand Up @@ -5534,6 +5560,7 @@ def PullInstances(self, context, MaxObjectCount=None, **extra):
* If zero, the WBEM server is to return no instances. This may
be used by a client to leave the handling of any returned
instances to a loop of Pull operations.
* None is not allowed for this attribute.
Keyword Arguments:
Expand Down Expand Up @@ -5597,6 +5624,7 @@ def PullInstances(self, context, MaxObjectCount=None, **extra):
**extra)

try:
_validatePullParams(MaxObjectCount, context)

namespace = context[1]

Expand Down
Loading

0 comments on commit ba08669

Please sign in to comment.