Exemplo n.º 1
0
    def status():
        eject_info = 'Alces Flight Support: {}'.format(
            _support_coverage_status())
        access_info = 'Alces Flight Support access: {}'.format(
            _support_access_status())
        status = text.join_lines(eject_info, access_info)

        click.echo(status)
Exemplo n.º 2
0
def _eject_failure_message():
    incorrect_code = text.failure('Incorrect eject code given.')
    contact_support = text.line_wrap(
        'Please contact the Alces Flight Support team at '
        '[email protected] if you are encountering difficulty ejecting '
        "your Flight {}.".format(config_utils.appliance_name()))

    return text.join_lines(incorrect_code, contact_support)
Exemplo n.º 3
0
def _eject_success_message():
    success = text.success('Success!')

    message_callback = CONFIG.SUPPORT_EJECT_SUCCESS_MESSAGE_CALLBACK
    appliance_success_message = \
        message_callback(appliance_url=config_utils.appliance_url())

    return text.join_lines(success, appliance_success_message)
Exemplo n.º 4
0
def _eject_confirmation_message():
    info = text.line_wrap(CONFIG.SUPPORT_EJECT_INFO_MESSAGE)
    support_warning = text.line_wrap(
        text.bold('This will opt you out from any obligation for Alces Flight '
                  "Ltd to provide you with support for your Flight {}.".format(
                      config_utils.appliance_name())))
    continue_prompt = text.info('Continue?')

    return text.join_lines(info, support_warning, continue_prompt)
Exemplo n.º 5
0
def _support_eject_success_message(appliance_url=None):
    cli_info = text.line_wrap(
        'You may now log out and in again to gain full command-line access to '
        'the appliance.')

    freeipa_url = appliance_url + '/ipa/ui'
    freeipa_info = text.line_wrap(
        ('You may also visit {} to access your full FreeIPA interface.'
         ).format(freeipa_url))

    return text.join_lines(cli_info, freeipa_info)
def _export_imported_user_passwords(passwords_data):
    unix_timestamp = math.floor(time.time())
    export_filename = 'passwords-{}.tsv'.format(unix_timestamp)
    export_filepath = os.path.join(CONFIG.EXPORT_DIR, export_filename)

    with open(export_filepath, 'w', newline='') as export_file:
        writer = csv.writer(export_file, delimiter='\t')
        for entry in passwords_data:
            writer.writerow(entry)

    download_info = text.line_wrap(
        'The temporary passwords are also available to download in TSV format '
        'at {}.'.format(_export_url(export_filename))) + '\n'

    message = text.join_lines(download_info, _auth_details())
    click.echo(message)
    def pad_value(header, value):
        padding = padding_for(header)

        header_size = len(header) + 1
        header_offset = header_size * ' '

        value_lines = value.split('\n')

        # Values can be multi-line; the first part just needs to be padded
        # appropriately from the header, but any additional lines need
        # additional padding to line up below this.
        additional_value_lines = len(value_lines) - 1
        additional_line_paddings = \
            [header_offset + padding] * additional_value_lines
        value_line_paddings = [padding] + additional_line_paddings

        padded_value_lines = \
            [''.join(parts) for parts in zip(value_line_paddings, value_lines)]
        return text.join_lines(*padded_value_lines)
def _record_export_success_message(export_filepath):
    success = text.success('Success!')

    export_filename = os.path.basename(export_filepath)
    download_info = \
        'Your Directory record is available to download at {}.\n'.format(
            _export_url(export_filename)
        )

    parts = [success, download_info, _auth_details()]

    if not appliance_cli.utils.in_sandbox():
        # As it stands all this functionality is unreachable from within the directory sandbox but
        # if it were to be re-enabled in the sandbox we may not have access to files on the appliance
        # so we don't want to show local access info if not currently in the sandbox
        local_file_info = '\nIt can also be viewed locally at {}.'.format(
            export_filepath)
        parts.append(local_file_info)

    return text.join_lines(*parts)
def list_displayer(headers, data):
    # There should only be exactly one item in the data, and we only want to
    # display that.
    single_item = data[0]

    longest_header_length = len(max(headers, key=len))

    def padding_for(header):
        minimum_gap = 1
        padding_amount = longest_header_length - len(header) + minimum_gap
        return padding_amount * ' '

    def pad_value(header, value):
        padding = padding_for(header)

        header_size = len(header) + 1
        header_offset = header_size * ' '

        value_lines = value.split('\n')

        # Values can be multi-line; the first part just needs to be padded
        # appropriately from the header, but any additional lines need
        # additional padding to line up below this.
        additional_value_lines = len(value_lines) - 1
        additional_line_paddings = \
            [header_offset + padding] * additional_value_lines
        value_line_paddings = [padding] + additional_line_paddings

        padded_value_lines = \
            [''.join(parts) for parts in zip(value_line_paddings, value_lines)]
        return text.join_lines(*padded_value_lines)

    lines = []
    for header, value in zip(headers, single_item):
        line = text.bold(header) + ':' + pad_value(header, value)
        lines.append(line)

    display = text.join_lines(*lines)
    click.echo(display)
Exemplo n.º 10
0
def _disable_confirmation_message():
    info = text.line_wrap(
        'This will disable Alces Flight Support from being able to access '
        'this appliance.')
    continue_prompt = text.info('Continue?')
    return text.join_lines(info, continue_prompt)