schema: Add known_fingerprints option to schema command

When client requests schema it can list fingerprints of cached schemas
and server responds with SchemaUpToDate exception specifying fingeprint
of schema to use.

https://fedorahosted.org/freeipa/ticket/4739

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
David Kupka
2016-06-21 14:21:22 +02:00
committed by Jan Cholasta
parent 034a111972
commit 4b97cabb52
5 changed files with 39 additions and 3 deletions

View File

@@ -695,6 +695,13 @@ class output_find(BaseParamSearch):
class schema(Command):
NO_CLI = True
takes_options = (
Str(
'known_fingerprints*',
label=_("Fingerprint of schema cached by client")
),
)
@staticmethod
def _calculate_fingerprint(data):
"""
@@ -748,4 +755,10 @@ class schema(Command):
schema['fingerprint'] = schema_fp
schema['ttl'] = SCHEMA_TTL
if schema['fingerprint'] in kwargs.get('known_fingerprints', []):
raise errors.SchemaUpToDate(
fingerprint=schema['fingerprint'],
ttl=schema['ttl'],
)
return dict(result=schema)