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):
|
2019-05-16 16:57:02 +02:00
|
|
|
type = "destination"
|
2016-07-05 00:30:20 +02:00
|
|
|
requires_key = True
|
2019-02-22 04:38:50 +01:00
|
|
|
sync_as_source = False
|
2019-05-16 16:57:02 +02:00
|
|
|
sync_as_source_name = ""
|
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 = [
|
|
|
|
{
|
2019-05-16 16:57:02 +02:00
|
|
|
"name": "exportPlugin",
|
|
|
|
"type": "export-plugin",
|
|
|
|
"required": True,
|
|
|
|
"helpMessage": "Export plugin to use before sending data to destination.",
|
2017-06-26 21:03:24 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
@property
|
|
|
|
def options(self):
|
2021-02-19 02:23:02 +01:00
|
|
|
"""
|
|
|
|
Gets/sets options for the plugin.
|
|
|
|
|
|
|
|
:return:
|
|
|
|
"""
|
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):
|
2019-05-16 16:57:02 +02:00
|
|
|
export_plugin = self.get_option("exportPlugin", options)
|
2017-06-26 21:03:24 +02:00
|
|
|
|
|
|
|
if export_plugin:
|
2019-05-16 16:57:02 +02:00
|
|
|
plugin = plugins.get(export_plugin["slug"])
|
|
|
|
extension, passphrase, data = plugin.export(
|
|
|
|
body, cert_chain, private_key, export_plugin["plugin_options"]
|
|
|
|
)
|
2017-06-26 21:03:24 +02:00
|
|
|
return [(extension, passphrase, data)]
|
|
|
|
|
2019-05-16 16:57:02 +02:00
|
|
|
data = body + "\n" + cert_chain + "\n" + private_key
|
|
|
|
return [(".pem", "", data)]
|
2017-06-26 21:03:24 +02:00
|
|
|
|
|
|
|
def upload(self, name, body, private_key, cert_chain, options, **kwargs):
|
|
|
|
raise NotImplementedError
|