Exemplo n.º 1
0
def client_setup(runner, ca_certificate):
    """
    initialize qdevice client on local host
    ca_certificate qnetd CA certificate
    """
    client_destroy()
    # save CA certificate, corosync tool only works with files
    ca_file_path = os.path.join(
        settings.corosync_qdevice_net_client_certs_dir,
        settings.corosync_qdevice_net_client_ca_file_name)
    try:
        if not os.path.exists(ca_file_path):
            os.makedirs(settings.corosync_qdevice_net_client_certs_dir,
                        mode=0o700)
        with open(ca_file_path, "wb") as ca_file:
            ca_file.write(ca_certificate)
    except EnvironmentError as e:
        raise LibraryError(
            reports.qdevice_initialization_error(__model, e.strerror))
    # initialize client's certificate storage
    stdout, stderr, retval = runner.run(
        [__qdevice_certutil, "-i", "-c", ca_file_path])
    if retval != 0:
        raise LibraryError(
            reports.qdevice_initialization_error(
                __model, join_multilines([stderr, stdout])))
Exemplo n.º 2
0
def client_setup(runner, ca_certificate):
    """
    initialize qdevice client on local host
    ca_certificate qnetd CA certificate
    """
    client_destroy()
    # save CA certificate, corosync tool only works with files
    ca_file_path = os.path.join(
        settings.corosync_qdevice_net_client_certs_dir,
        settings.corosync_qdevice_net_client_ca_file_name
    )
    try:
        if not os.path.exists(ca_file_path):
            os.makedirs(
                settings.corosync_qdevice_net_client_certs_dir,
                mode=0o700
            )
        with open(ca_file_path, "wb") as ca_file:
            ca_file.write(ca_certificate)
    except EnvironmentError as e:
        raise LibraryError(
            reports.qdevice_initialization_error(__model, e.strerror)
        )
    # initialize client's certificate storage
    output, retval = runner.run([
        __qdevice_certutil, "-i", "-c", ca_file_path
    ])
    if retval != 0:
        raise LibraryError(
            reports.qdevice_initialization_error(__model, output.rstrip())
        )
Exemplo n.º 3
0
def qdevice_setup(runner):
    """
    initialize qdevice on local host
    """
    if qdevice_initialized():
        raise LibraryError(reports.qdevice_already_initialized(__model))

    stdout, stderr, retval = runner.run([__qnetd_certutil, "-i"])
    if retval != 0:
        raise LibraryError(
            reports.qdevice_initialization_error(
                __model, join_multilines([stderr, stdout])))
Exemplo n.º 4
0
def qdevice_setup(runner):
    """
    initialize qdevice on local host
    """
    if external.is_dir_nonempty(
            settings.corosync_qdevice_net_server_certs_dir):
        raise LibraryError(reports.qdevice_already_initialized(__model))

    stdout, stderr, retval = runner.run([__qnetd_certutil, "-i"])
    if retval != 0:
        raise LibraryError(
            reports.qdevice_initialization_error(
                __model, join_multilines([stderr, stdout])))
Exemplo n.º 5
0
def qdevice_setup(runner):
    """
    initialize qdevice on local host
    """
    if external.is_dir_nonempty(settings.corosync_qdevice_net_server_certs_dir):
        raise LibraryError(reports.qdevice_already_initialized(__model))

    output, retval = runner.run([
        __qnetd_certutil, "-i"
    ])
    if retval != 0:
        raise LibraryError(
            reports.qdevice_initialization_error(__model, output.rstrip())
        )
Exemplo n.º 6
0
def client_generate_certificate_request(runner, cluster_name):
    """
    create a certificate request which can be signed by qnetd server
    string cluster_name name of the cluster to which qdevice is being added
    """
    if not client_initialized():
        raise LibraryError(reports.qdevice_not_initialized(__model))
    stdout, stderr, retval = runner.run(
        [__qdevice_certutil, "-r", "-n", cluster_name])
    if retval != 0:
        raise LibraryError(
            reports.qdevice_initialization_error(
                __model, join_multilines([stderr, stdout])))
    return _get_output_certificate(
        stdout, functools.partial(reports.qdevice_initialization_error,
                                  __model))
Exemplo n.º 7
0
def client_generate_certificate_request(runner, cluster_name):
    """
    create a certificate request which can be signed by qnetd server
    string cluster_name name of the cluster to which qdevice is being added
    """
    if not client_initialized():
        raise LibraryError(reports.qdevice_not_initialized(__model))
    output, retval = runner.run([
        __qdevice_certutil, "-r", "-n", cluster_name
    ])
    if retval != 0:
        raise LibraryError(
            reports.qdevice_initialization_error(__model, output.rstrip())
        )
    return _get_output_certificate(
        output,
        functools.partial(reports.qdevice_initialization_error, __model)
    )