def install(ctx, config, template, update, no_capture, ssh_key_file):
    """Install CSE on vCloud Director."""
    if no_capture and ssh_key_file is None:
        click.echo('Must provide ssh-key file (using --ssh-key OR -k) if '
                   '--no-capture is True, or else temporary vm will '
                   'be inaccessible')
        return

    ssh_key = None
    if ssh_key_file is not None:
        ssh_key = ssh_key_file.read()
    try:
        install_cse(ctx,
                    config_file_name=config,
                    template_name=template,
                    update=update,
                    no_capture=no_capture,
                    ssh_key=ssh_key)
    except (EntityNotFoundException, NotAcceptableException, VcdException,
            ValueError, KeyError, TypeError) as err:
        click.secho(str(err), fg='red')
    except AmqpConnectionError as err:
        click.secho(str(err), fg='red')
        click.secho("check config file amqp section.", fg='red')
    except requests.exceptions.ConnectionError:
        click.secho("Cannot connect to vCD host (check config file vCD host).",
                    fg='red')
    except vim.fault.InvalidLogin:
        click.secho(
            "vCenter login failed (check config file vCenter "
            "username/password).",
            fg='red')
Example #2
0
def install(ctx, config, skip_template_creation, force_update,
            retain_temp_vapp, ssh_key_file):
    """Install CSE on vCloud Director."""
    try:
        check_python_version(ConsoleMessagePrinter())
    except Exception as err:
        click.secho(str(err), fg='red')
        sys.exit(1)

    if retain_temp_vapp and not ssh_key_file:
        click.echo('Must provide ssh-key file (using --ssh-key OR -k) if '
                   '--no-capture is True, or else temporary vm will '
                   'be inaccessible')
        return

    ssh_key = None
    if ssh_key_file is not None:
        ssh_key = ssh_key_file.read()
    try:
        install_cse(ctx, config_file_name=config,
                    skip_template_creation=skip_template_creation,
                    force_update=force_update, ssh_key=ssh_key,
                    retain_temp_vapp=retain_temp_vapp,
                    msg_update_callback=ConsoleMessagePrinter())
    except (EntityNotFoundException, NotAcceptableException, VcdException,
            ValueError, KeyError, TypeError) as err:
        click.secho(str(err), fg='red')
    except AmqpConnectionError as err:
        click.secho(str(err), fg='red')
        click.secho("check config file amqp section.", fg='red')
    except requests.exceptions.ConnectionError as err:
        click.secho(f"Cannot connect to {err.request.url}.", fg='red')
    except vim.fault.InvalidLogin:
        click.secho("vCenter login failed (check config file vCenter "
                    "username/password).", fg='red')
def install(ctx, config, pks_config, skip_config_decryption,
            skip_template_creation, force_update, retain_temp_vapp,
            ssh_key_file):
    """Install CSE on vCloud Director."""
    if skip_config_decryption:
        password = None
    else:
        password = os.getenv('CSE_CONFIG_PASSWORD') or prompt_text(
            PASSWORD_FOR_CONFIG_DECRYPTION_MSG, color='green', hide_input=True)
    try:
        check_python_version(ConsoleMessagePrinter())
    except Exception as err:
        click.secho(str(err), fg='red')
        sys.exit(1)

    if retain_temp_vapp and not ssh_key_file:
        click.echo('Must provide ssh-key file (using --ssh-key OR -k) if '
                   '--retain-temp-vapp is provided, or else temporary vm will '
                   'be inaccessible')
        sys.exit(1)

    ssh_key = None
    if ssh_key_file is not None:
        ssh_key = ssh_key_file.read()

    try:
        install_cse(config_file_name=config,
                    pks_config_file_name=pks_config,
                    skip_template_creation=skip_template_creation,
                    force_update=force_update,
                    ssh_key=ssh_key,
                    retain_temp_vapp=retain_temp_vapp,
                    skip_config_decryption=skip_config_decryption,
                    decryption_password=password,
                    msg_update_callback=ConsoleMessagePrinter())
    except (EntityNotFoundException, NotAcceptableException, VcdException,
            ValueError, KeyError, TypeError) as err:
        click.secho(str(err), fg='red')
    except AmqpConnectionError as err:
        click.secho(str(err), fg='red')
        click.secho("check config file amqp section.", fg='red')
    except requests.exceptions.ConnectionError as err:
        click.secho(f"Cannot connect to {err.request.url}.", fg='red')
    except vim.fault.InvalidLogin:
        click.secho(
            "vCenter login failed (check config file vCenter "
            "username/password).",
            fg='red')
    except cryptography.fernet.InvalidToken:
        click.secho(CONFIG_DECRYPTION_ERROR_MSG, fg='red')
def install(ctx, config, template, update, no_capture, ssh_key_file,
            ext_install):
    """Install CSE on vCloud Director."""
    if no_capture and ssh_key_file is None:
        click.echo('Must provide ssh-key file (using --ssh-key OR -k) if '
                   '--no-capture is True, or else temporary vm will '
                   'be inaccessible')
    else:
        ssh_key = None
        if ssh_key_file is not None:
            ssh_key = ssh_key_file.read()
        install_cse(ctx,
                    config_file_name=config,
                    template_name=template,
                    update=update,
                    no_capture=no_capture,
                    ssh_key=ssh_key,
                    ext_install=ext_install)