mirror of https://github.com/OpenKMIP/PyKMIP.git
Stub out server side locate operation.
This commit is contained in:
parent
a2b71a1f1c
commit
aa300b256c
|
@ -85,8 +85,21 @@ class Name(Struct):
|
|||
self.__validate()
|
||||
|
||||
def __validate(self):
|
||||
# TODO (peter-hamilton) Finish implementation.
|
||||
pass
|
||||
name = self.__class__.__name__
|
||||
if self.name_value and \
|
||||
not isinstance(self.name_value, Name.NameValue) and \
|
||||
not isinstance(self.name_value, str):
|
||||
member = 'name_value'
|
||||
raise TypeError(msg.format('{}.{}'.format(name, member),
|
||||
'name_value', type(Name.NameValue),
|
||||
type(name_type)))
|
||||
if self.name_type and \
|
||||
not isinstance(self.name_type, Name.NameType) and \
|
||||
not isinstance(self.name_type, str):
|
||||
member = 'name_type'
|
||||
raise TypeError(msg.format('{}.{}'.format(name, member),
|
||||
'name_type', type(Name.NameType),
|
||||
type(self.name_type)))
|
||||
|
||||
@classmethod
|
||||
def create(cls, name_value, name_type):
|
||||
|
@ -94,11 +107,13 @@ class Name(Struct):
|
|||
value = name_value
|
||||
elif isinstance(name_value, str):
|
||||
value = cls.NameValue(name_value)
|
||||
# else: the __validate function will throw TypeError
|
||||
|
||||
if isinstance(name_type, Name.NameType):
|
||||
n_type = name_type
|
||||
elif isinstance(name_type, Enum):
|
||||
n_type = cls.NameType(name_type)
|
||||
# else: the __validate function will throw TypeError
|
||||
|
||||
return Name(name_value=value,
|
||||
name_type=n_type)
|
||||
|
|
|
@ -48,7 +48,4 @@ class MemRepo(ManagedObjectRepo):
|
|||
|
||||
def locate(self, maximum_items, storage_status_mask,
|
||||
object_group_member, attributes):
|
||||
# TODO - search objects, find one with matching attrs
|
||||
if "1" in self.repo:
|
||||
return [self.repo["1"]]
|
||||
return None
|
||||
raise NotImplementedError
|
||||
|
|
|
@ -260,9 +260,16 @@ class KMIPImpl(KMIP):
|
|||
self.logger.debug('locate() called')
|
||||
msg = 'locating object(s) from repo'
|
||||
self.logger.debug(msg)
|
||||
try:
|
||||
uuids = self.repo.locate(maximum_items, storage_status_mask,
|
||||
object_group_member, attributes)
|
||||
return LocateResult(ResultStatus(RS.SUCCESS), uuids=uuids)
|
||||
except NotImplementedError:
|
||||
msg = ResultMessage('Locate Operation Not Supported'))
|
||||
reason = ResultReason(ResultReasonEnum.OPERATION_NOT_SUPPORTED)
|
||||
return LocateResult(ResultStatus(RS.OPERATION_FAILED),
|
||||
result_reason=reason,
|
||||
result_message=msg)
|
||||
|
||||
def _validate_req_field(self, attrs, name, expected, msg, required=True):
|
||||
self.logger.debug('Validating attribute %s' % name)
|
||||
|
|
Loading…
Reference in New Issue