1862b08ccc
This new command will create self-signed certificates that can be used for a non-production deployment. Note: self-signed certificates should not be used in production. Change-Id: Id13584aa53d586120d9faba012fee444e6d0e639
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
# Copyright(c) 2018, Oracle and/or its affiliates. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
import logging
|
|
import traceback
|
|
|
|
from cliff.command import Command
|
|
|
|
from kolla_cli.api.client import ClientApi
|
|
import kolla_cli.i18n as u
|
|
|
|
from kolla_cli.commands.exceptions import CommandError
|
|
|
|
CLIENT = ClientApi()
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class CertificateInit(Command):
|
|
"""Generates self-signed certificate"""
|
|
|
|
def take_action(self, parsed_args):
|
|
verbose_level = self.app.options.verbose_level
|
|
|
|
try:
|
|
job = CLIENT.certificate_init(verbose_level)
|
|
|
|
# wait for job to complete
|
|
status = job.wait()
|
|
if verbose_level > 2:
|
|
LOG.info('\n\n' + 80 * '=')
|
|
LOG.info(u._('DEBUG command output:\n{out}')
|
|
.format(out=job.get_console_output()))
|
|
if status == 0:
|
|
LOG.info(u._('Success'))
|
|
else:
|
|
raise CommandError(u._('Job failed:\n{msg}')
|
|
.format(msg=job.get_error_message()))
|
|
|
|
except Exception:
|
|
raise Exception(traceback.format_exc())
|