2
0
mirror of https://github.com/openkmip/pykmip synced 2026-01-04 01:23:25 +00:00

Add offset and maximum item filtering for the Locate operation

This change updates Locate operation support in the PyKMIP server,
allowing users to filter objects using the offset and maximum item
constraints. The offset constraint tells the server how many
matching items should be skipped before results are returned. The
maximum items constraint tells the server how many matching items
should be returned. 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 offset and maximum item filtering. Simply use the
"--offset-items" and "--maximum-items" flags to specify offset and
maximum item values for the Locate script to filter on.

Fixes #562
This commit is contained in:
Peter Hamilton
2019-08-09 16:37:39 -04:00
committed by Peter Hamilton
parent 4938f82772
commit 4a6a2eccc1
9 changed files with 210 additions and 8 deletions

View File

@@ -32,6 +32,8 @@ if __name__ == '__main__':
opts, args = parser.parse_args(sys.argv[1:])
config = opts.config
offset_items = opts.offset_items
maximum_items = opts.maximum_items
name = opts.name
initial_dates = opts.initial_dates
state = opts.state
@@ -43,6 +45,13 @@ if __name__ == '__main__':
attribute_factory = AttributeFactory()
if offset_items and (offset_items < 0):
logger.error("Invalid offset items value provided.")
sys.exit(-1)
if maximum_items and (maximum_items < 0):
logger.error("Invalid maximum items value provided.")
sys.exit(-1)
# Build attributes if any are specified
attributes = []
if name:
@@ -159,7 +168,11 @@ if __name__ == '__main__':
config_file=opts.config_file
) as client:
try:
uuids = client.locate(attributes=attributes)
uuids = client.locate(
attributes=attributes,
offset_items=offset_items,
maximum_items=maximum_items
)
logger.info("Located uuids: {0}".format(uuids))
except Exception as e:
logger.error(e)