2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-15 07:43:26 +00:00

Add Name attribute filtering of locate for server

This commit is contained in:
Hao Shen
2017-06-30 11:56:35 -07:00
parent 4c244a1f6f
commit b55a051b26
2 changed files with 120 additions and 4 deletions

View File

@@ -1332,15 +1332,36 @@ class KmipEngine(object):
@_kmip_version_supported('1.0')
def _process_locate(self, payload):
# TODO Currently the Locate operation will just return all the
# existing managed objects with the restriction of operation
# policy only. Need to implement other filtering logics in the
# SPEC (e.g., attribute, storage status mask and etc..)
# TODO: Need to complete the filtering logic based on all given
# objects in payload.
self._logger.info("Processing operation: Locate")
managed_objects = self._list_objects_with_access_controls(
enums.Operation.LOCATE)
if payload.attributes:
managed_objects_filtered = []
# Filter the objects based on given attributes.
# TODO: Currently will only filter for 'Name'.
# Needs to add other attributes.
for managed_object in managed_objects:
for attribute in payload.attributes:
attribute_name = attribute.attribute_name.value
attribute_value = attribute.attribute_value
attr = self._get_attribute_from_managed_object(
managed_object, attribute_name)
if attribute_name == 'Name':
names = attr
if attribute_value not in names:
break
# TODO: filtering on other attributes
else:
managed_objects_filtered.append(managed_object)
managed_objects = managed_objects_filtered
unique_identifiers = [attributes.UniqueIdentifier(
str(managed_object.unique_identifier))
for managed_object in managed_objects]