2015-07-04 21:47:57 +02:00
|
|
|
"""
|
2016-12-14 18:29:04 +01:00
|
|
|
.. module: lemur.plugins.bases.destination
|
2015-07-04 21:47:57 +02:00
|
|
|
:platform: Unix
|
2018-05-29 19:18:16 +02:00
|
|
|
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
|
2015-07-04 21:47:57 +02:00
|
|
|
:license: Apache, see LICENSE for more details.
|
|
|
|
|
|
|
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
|
|
|
"""
|
2017-06-26 21:03:24 +02:00
|
|
|
from lemur.plugins.base import Plugin, plugins
|
2015-07-04 21:47:57 +02:00
|
|
|
|
2015-07-21 22:06:13 +02:00
|
|
|
|
2015-07-04 21:47:57 +02:00
|
|
|
class DestinationPlugin(Plugin):
|
2015-07-11 02:06:57 +02:00
|
|
|
type = 'destination'
|
2016-07-05 00:30:20 +02:00
|
|
|
requires_key = True
|
2015-07-11 02:06:57 +02:00
|
|
|
|
2016-12-14 22:42:29 +01:00
|
|
|
def upload(self, name, body, private_key, cert_chain, options, **kwargs):
|
|
|
|
raise NotImplementedError
|
2017-06-26 21:03:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ExportDestinationPlugin(DestinationPlugin):
|
|
|
|
default_options = [
|
|
|
|
{
|
|
|
|
'name': 'exportPlugin',
|
|
|
|
'type': 'export-plugin',
|
|
|
|
'required': True,
|
|
|
|
'helpMessage': 'Export plugin to use before sending data to destination.'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
@property
|
|
|
|
def options(self):
|
2017-10-06 02:27:45 +02:00
|
|
|
return self.default_options + self.additional_options
|
2017-06-26 21:03:24 +02:00
|
|
|
|
|
|
|
def export(self, body, private_key, cert_chain, options):
|
|
|
|
export_plugin = self.get_option('exportPlugin', options)
|
|
|
|
|
|
|
|
if export_plugin:
|
|
|
|
plugin = plugins.get(export_plugin['slug'])
|
|
|
|
extension, passphrase, data = plugin.export(body, cert_chain, private_key, export_plugin['plugin_options'])
|
|
|
|
return [(extension, passphrase, data)]
|
|
|
|
|
|
|
|
data = body + '\n' + cert_chain + '\n' + private_key
|
|
|
|
return [('.pem', '', data)]
|
|
|
|
|
|
|
|
def upload(self, name, body, private_key, cert_chain, options, **kwargs):
|
|
|
|
raise NotImplementedError
|