Beispiel #1
0
def to_html(results):
    PREAMBLE_FILE = os.getenv('LSM_PREAMBLE_FILE', "")
    preamble = ""
    methods = [
        'capabilities', 'systems', 'plugin_info', 'pools', 'job_status',
        'job_free', 'iscsi_chap_auth', 'volumes', 'volume_create',
        'volume_delete', 'volume_resize', 'volume_replicate',
        'volume_replicate_range_block_size', 'volume_replicate_range',
        'volume_enable', 'volume_disable', 'disks', 'target_ports',
        'volume_mask', 'volume_unmask', 'volume_child_dependency',
        'volume_child_dependency_rm', 'access_groups',
        'access_groups_granted_to_volume', 'access_group_create',
        'access_group_delete', 'volumes_accessible_by_access_group',
        'access_groups_granted_to_volume', 'access_group_initiator_add',
        'access_group_initiator_delete', 'fs', 'fs_create', 'fs_delete',
        'fs_resize', 'fs_clone', 'fs_file_clone', 'fs_snapshots',
        'fs_snapshot_create', 'fs_snapshot_delete', 'fs_snapshot_restore',
        'fs_child_dependency', 'fs_child_dependency_rm', 'export_auth',
        'exports', 'export_fs', 'export_remove'
    ]

    ch = []
    row_data = []

    if os.path.isfile(PREAMBLE_FILE):
        with open(PREAMBLE_FILE, 'r') as pm:
            preamble = pm.read()

    #Build column header
    for r in results:
        ch.append(r['SYSTEM']['ID'])

    # Add overall pass/fail for unit tests
    pass_fail = ['Overall Pass/Fail result']
    for r in results:
        if r['META']['ec'] == '0':
            pass_fail.append('P')
        else:
            pass_fail.append('F')
    row_data.append(pass_fail)

    # Append on link for error log
    error_log = ['Error log (click +)']
    for r in results:
        error_log.append('<a href="%s">+</a>' %
                         ('./' + os.path.basename(r['META']['error_file'])))
    row_data.append(error_log)

    for m in methods:
        row = [m]

        for r in results:
            row.append(get_result(r, m))

        row_data.append(row)

    # Build HTML
    text = '<!DOCTYPE html>'
    text += str(
        html(
            head(
                link(rel="stylesheet", type="text/css", href="../../test.css"),
                title("libStorageMgmt test results"),
            ),
            body(
                HTML(
                    h1("%s Results generated @ %s") %
                    (preamble, time.strftime("%c"))),
                div(table(_table_header(ch), _table_body(row_data)),
                    _class="angled_table"),
                div(
                    pre("                  Legend\n"
                        "                  P = Pass (Method called and returned without error)\n"
                        "                  F = Fail (Method call returned an error)\n"
                        "                  U = Unsupported or unable to test due to other errors\n"
                        "                  * = Unable to connect to array or provider totally unsupported\n"
                        "                  + = hyper link to error log")))))

    return bs(text).prettify()
def to_html(results):
    PREAMBLE_FILE = os.getenv('LSM_PREAMBLE_FILE', "")
    preamble = ""
    methods = ['capabilities',
               'systems', 'plugin_info', 'pools', 'job_status', 'job_free',
               'iscsi_chap_auth',
               'volumes', 'volume_create', 'volume_delete', 'volume_resize',
               'volume_replicate', 'volume_replicate_range_block_size',
               'volume_replicate_range', 'volume_enable', 'volume_disable',
               'disks', 'target_ports',
               'volume_mask',
               'volume_unmask',
               'volume_child_dependency',
               'volume_child_dependency_rm',
               'access_groups',
               'access_groups_granted_to_volume',
               'access_group_create',
               'access_group_delete',
               'volumes_accessible_by_access_group',
               'access_groups_granted_to_volume',
               'access_group_initiator_add',
               'access_group_initiator_delete',
               'fs',
               'fs_create',
               'fs_delete',
               'fs_resize',
               'fs_clone',
               'fs_file_clone',
               'fs_snapshots',
               'fs_snapshot_create',
               'fs_snapshot_delete',
               'fs_snapshot_restore',
               'fs_child_dependency',
               'fs_child_dependency_rm',
               'export_auth',
               'exports',
               'export_fs',
               'export_remove'
               ]

    ch = []
    row_data = []

    if os.path.isfile(PREAMBLE_FILE):
        with open(PREAMBLE_FILE, 'r') as pm:
            preamble = pm.read()

    #Build column header
    for r in results:
        ch.append(r['SYSTEM']['ID'])

    # Add overall pass/fail for unit tests
    pass_fail = ['Overall Pass/Fail result']
    for r in results:
        if r['META']['ec'] == '0':
            pass_fail.append('P')
        else:
            pass_fail.append('F')
    row_data.append(pass_fail)

    # Append on link for error log
    error_log = ['Error log (click +)']
    for r in results:
        error_log.append('<a href="%s">+</a>' %
                         ('./' + os.path.basename(r['META']['error_file'])))
    row_data.append(error_log)

    for m in methods:
        row = [m]

        for r in results:
            row.append(get_result(r, m))

        row_data.append(row)

    # Build HTML
    text = '<!DOCTYPE html>'
    text += str(html(
                head(link(rel="stylesheet", type="text/css",
                          href="../../test.css"),
                title("libStorageMgmt test results"), ),
                body(
                    HTML(h1("%s Results generated @ %s") % (preamble, time.strftime("%c"))),
                    div(table(_table_header(ch), _table_body(row_data)),
                         _class="angled_table"),
                    div(pre(
                           "                  Legend\n"
                           "                  P = Pass (Method called and returned without error)\n"
                           "                  F = Fail (Method call returned an error)\n"
                           "                  U = Unsupported or unable to test due to other errors\n"
                           "                  * = Unable to connect to array or provider totally unsupported\n"
                           "                  + = hyper link to error log\n\n\n",
                           HTML('                  Source code for plug-in for this test run <a href=./smis.py.html>is here. </a>'))))
                ))

    return bs(text).prettify()