Ejemplo n.º 1
0
def generate_self_signed_cert(cert_name):
    home = fileoperations.get_home()
    cert_dir = os.path.join(home, '.ssl')
    privatekey_filename = cert_name + '-privatekey.pem'
    privatekey_dir = os.path.join(cert_dir, privatekey_filename)
    sign_request_filename = cert_name + '-csr.pem'
    sign_request_dir = os.path.join(cert_dir, sign_request_filename)
    server_cert_filename = cert_name + '.crt'
    server_cert_dir = os.path.join(cert_dir, server_cert_filename)

    if not os.path.isdir(cert_dir):
        os.mkdir(cert_dir)

    io.log_warning('Generating a self-signed certificate. '
                   'To provide an already created certificate, '
                   'use the command options.'
                   '\nSee "eb labs setup-ssl --help" for more info.')

    if not fileoperations.program_is_installed('openssl'):
        raise CommandError('This command requires openssl to be '
                           'installed on the PATH')

    if not os.path.isfile(privatekey_dir):
        utils.exec_cmd_quiet(['openssl', 'genrsa', '-out', privatekey_dir])

    if not os.path.isfile(sign_request_dir):
        io.echo()
        subprocess.check_call([
            'openssl', 'req', '-new', '-key', privatekey_dir, '-out',
            sign_request_dir
        ])
        io.echo()

    if not os.path.isfile(server_cert_dir):
        utils.exec_cmd_quiet([
            'openssl', 'x509', '-req', '-days', '365', '-in', sign_request_dir,
            '-signkey', privatekey_dir, '-out', server_cert_dir
        ])

    return privatekey_dir, server_cert_dir
Ejemplo n.º 2
0
def _run_quiet(args):
    try:
        return utils.exec_cmd_quiet(args)
    except CommandError as e:
        _handle_command_error(e)
Ejemplo n.º 3
0
def _boot2docker_ip():
    args = ['boot2docker', 'ip']
    return utils.exec_cmd_quiet(args).strip()
Ejemplo n.º 4
0
def _init_boot2docker():
    utils.exec_cmd_quiet(['boot2docker', 'init'])
Ejemplo n.º 5
0
def _start_boot2docker():
    utils.exec_cmd_quiet(['boot2docker', 'start'])
Ejemplo n.º 6
0
def _get_boot2docker_status():
    return utils.exec_cmd_quiet(['boot2docker', 'status']).strip()