mirror of
https://github.com/openkmip/pykmip
synced 2025-12-24 04:04:20 +00:00
Add State filtering support for the Locate operation
This change updates Locate operation support in the PyKMIP server, allowing users to filter objects based on the object's State. Unit tests and integration tests have been added to test and verify the correctness of this feature. Additionally, the Locate demo scripts have also been updated to support State filtering. Simply use the "--state" flag to specify a State enumeration for the Locate script to filter on.
This commit is contained in:
committed by
Peter Hamilton
parent
da284e932b
commit
e5de55c0a8
@@ -1601,6 +1601,10 @@ class KmipEngine(object):
|
||||
managed_objects = self._list_objects_with_access_controls(
|
||||
enums.Operation.LOCATE)
|
||||
|
||||
# TODO (ph) Do a single pass on the provided attributes and preprocess
|
||||
# them as needed (e.g., tracking multiple 'Initial Date' values, etc).
|
||||
# Locate needs to be able to error out if multiple singleton attributes
|
||||
# like 'State' are provided in the same request.
|
||||
if payload.attributes:
|
||||
|
||||
managed_objects_filtered = []
|
||||
@@ -1637,6 +1641,19 @@ class KmipEngine(object):
|
||||
)
|
||||
add_object = False
|
||||
break
|
||||
elif name == enums.AttributeType.STATE.value:
|
||||
value = value.value
|
||||
if value != attribute:
|
||||
self._logger.debug(
|
||||
"Failed match: "
|
||||
"the specified state ({}) does not match "
|
||||
"the object's state ({}).".format(
|
||||
value.name,
|
||||
attribute.name
|
||||
)
|
||||
)
|
||||
add_object = False
|
||||
break
|
||||
elif name == enums.AttributeType.INITIAL_DATE.value:
|
||||
initial_date["value"] = attribute
|
||||
self._track_date_attributes(
|
||||
|
||||
Reference in New Issue
Block a user