mgr/dashboard: added CLI commands to set SSL certificate and key

Fixes: https://tracker.ceph.com/issues/39123

Signed-off-by: Ricardo Dias <rdias@suse.com>
This commit is contained in:
Ricardo Dias 2019-04-09 13:42:57 +01:00
parent 4e2288c661
commit 7648d294bf
No known key found for this signature in database
GPG Key ID: 74390C579BD37B68

View File

@ -14,7 +14,7 @@ import threading
import time
from uuid import uuid4
from OpenSSL import crypto, SSL
from mgr_module import MgrModule, MgrStandbyModule, Option
from mgr_module import MgrModule, MgrStandbyModule, Option, CLIWriteCommand
from mgr_util import get_default_addr
try:
@ -405,6 +405,30 @@ class Module(MgrModule, CherryPyConfig):
logger.info('Stopping engine...')
self.shutdown_event.set()
@CLIWriteCommand("dashboard set-ssl-certificate",
"name=mgr_id,type=CephString,req=false")
def set_ssl_certificate(self, mgr_id=None, inbuf=None):
if inbuf is None:
return -errno.EINVAL, '',\
'Please specify the certificate file with "-i" option'
if mgr_id is not None:
self.set_store('{}/crt'.format(mgr_id), inbuf)
else:
self.set_store('crt', inbuf)
return 0, 'SSL certificate updated', ''
@CLIWriteCommand("dashboard set-ssl-certificate-key",
"name=mgr_id,type=CephString,req=false")
def set_ssl_certificate_key(self, mgr_id=None, inbuf=None):
if inbuf is None:
return -errno.EINVAL, '',\
'Please specify the certificate key file with "-i" option'
if mgr_id is not None:
self.set_store('{}/key'.format(mgr_id), inbuf)
else:
self.set_store('key', inbuf)
return 0, 'SSL certificate key updated', ''
def handle_command(self, inbuf, cmd):
# pylint: disable=too-many-return-statements
res = handle_option_command(cmd)