diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-02-12 02:10:12 -0700 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2009-02-17 16:03:10 -0500 |
commit | 4ab133c3cb8fa9a9aff2b7e5d1c53a0feb164f3f (patch) | |
tree | 5e1989c8c054b05876a86ed81ebb6dea6f66b033 /ipalib/plugins/cert.py | |
parent | e0fe7323187df205c0994cc3fa4e0ee0b6445788 (diff) | |
download | freeipa-4ab133c3cb8fa9a9aff2b7e5d1c53a0feb164f3f.tar.gz freeipa-4ab133c3cb8fa9a9aff2b7e5d1c53a0feb164f3f.tar.xz freeipa-4ab133c3cb8fa9a9aff2b7e5d1c53a0feb164f3f.zip |
Implemented more elegant way for entire plugin module to be conditionally skipped; updated cert.py and ra.py modules to use this
Diffstat (limited to 'ipalib/plugins/cert.py')
-rw-r--r-- | ipalib/plugins/cert.py | 150 |
1 files changed, 77 insertions, 73 deletions
diff --git a/ipalib/plugins/cert.py b/ipalib/plugins/cert.py index 22ec4c6a0..96e2667bc 100644 --- a/ipalib/plugins/cert.py +++ b/ipalib/plugins/cert.py @@ -22,110 +22,114 @@ Command plugins for IPA-RA certificate operations. """ -from ipalib import api +from ipalib import api, SkipPluginModule -if api.env.enable_ra: - from ipalib import Command, Str, Int +if api.env.enable_ra is not True: + raise SkipPluginModule(reason='env.enable_ra=%r' % (api.env.enable_ra,)) - class cert_request(Command): - """ - Submit a certificate singing request. - """ +from ipalib import Command, Str, Int - takes_args = ('csr',) +assert False - takes_options = ( - Str('request_type', default=u'pkcs10', autofill=True), - ) +class cert_request(Command): + """ + Submit a certificate singing request. + """ - def execute(self, csr, **options): - return self.Backend.ra.request_certificate(csr, **options) + takes_args = ('csr',) - def output_for_cli(self, textui, result, *args, **options): - if isinstance(result, dict) and len(result) > 0: - textui.print_entry(result, 0) - else: - textui.print_plain('Failed to submit a certificate request.') + takes_options = ( + Str('request_type', default=u'pkcs10', autofill=True), + ) - api.register(cert_request) + def execute(self, csr, **options): + return self.Backend.ra.request_certificate(csr, **options) + def output_for_cli(self, textui, result, *args, **options): + if isinstance(result, dict) and len(result) > 0: + textui.print_entry(result, 0) + else: + textui.print_plain('Failed to submit a certificate request.') - class cert_status(Command): - """ - Check status of a certificate signing request. - """ +api.register(cert_request) - takes_args = ['request_id'] +class cert_status(Command): + """ + Check status of a certificate signing request. + """ - def execute(self, request_id, **options): - return self.Backend.ra.check_request_status(request_id) + takes_args = ['request_id'] - def output_for_cli(self, textui, result, *args, **options): - if isinstance(result, dict) and len(result) > 0: - textui.print_entry(result, 0) - else: - textui.print_plain('Failed to retrieve a request status.') - api.register(cert_status) + def execute(self, request_id, **options): + return self.Backend.ra.check_request_status(request_id) + def output_for_cli(self, textui, result, *args, **options): + if isinstance(result, dict) and len(result) > 0: + textui.print_entry(result, 0) + else: + textui.print_plain('Failed to retrieve a request status.') - class cert_get(Command): - """ - Retrieve an existing certificate. - """ +api.register(cert_status) - takes_args = ['serial_number'] - def execute(self, serial_number): - return self.Backend.ra.get_certificate(serial_number) +class cert_get(Command): + """ + Retrieve an existing certificate. + """ - def output_for_cli(self, textui, result, *args, **options): - if isinstance(result, dict) and len(result) > 0: - textui.print_entry(result, 0) - else: - textui.print_plain('Failed to obtain a certificate.') + takes_args = ['serial_number'] - api.register(cert_get) + def execute(self, serial_number): + return self.Backend.ra.get_certificate(serial_number) + def output_for_cli(self, textui, result, *args, **options): + if isinstance(result, dict) and len(result) > 0: + textui.print_entry(result, 0) + else: + textui.print_plain('Failed to obtain a certificate.') - class cert_revoke(Command): - """ - Revoke a certificate. - """ +api.register(cert_get) - takes_args = ['serial_number'] - # FIXME: The default is 0. Is this really an Int param? - takes_options = [Int('revocation_reason?', default=0)] +class cert_revoke(Command): + """ + Revoke a certificate. + """ + takes_args = ['serial_number'] - def execute(self, serial_number, **options): - return self.Backend.ra.revoke_certificate(serial_number, **options) + # FIXME: The default is 0. Is this really an Int param? + takes_options = [Int('revocation_reason?', default=0)] - def output_for_cli(self, textui, result, *args, **options): - if isinstance(result, dict) and len(result) > 0: - textui.print_entry(result, 0) - else: - textui.print_plain('Failed to revoke a certificate.') - api.register(cert_revoke) + def execute(self, serial_number, **options): + return self.Backend.ra.revoke_certificate(serial_number, **options) + def output_for_cli(self, textui, result, *args, **options): + if isinstance(result, dict) and len(result) > 0: + textui.print_entry(result, 0) + else: + textui.print_plain('Failed to revoke a certificate.') - class cert_remove_hold(Command): - """ - Take a revoked certificate off hold. - """ +api.register(cert_revoke) - takes_args = ['serial_number'] - def execute(self, serial_number, **options): - return self.Backend.ra.take_certificate_off_hold(serial_number) +class cert_remove_hold(Command): + """ + Take a revoked certificate off hold. + """ - def output_for_cli(self, textui, result, *args, **options): - if isinstance(result, dict) and len(result) > 0: - textui.print_entry(result, 0) - else: - textui.print_plain('Failed to take a revoked certificate off hold.') + takes_args = ['serial_number'] - api.register(cert_remove_hold) + def execute(self, serial_number, **options): + return self.Backend.ra.take_certificate_off_hold(serial_number) + + def output_for_cli(self, textui, result, *args, **options): + if isinstance(result, dict) and len(result) > 0: + textui.print_entry(result, 0) + else: + textui.print_plain('Failed to take a revoked certificate off hold.') + +api.register(cert_remove_hold) |