Exemplo n.º 1
0
def process(workbook: Any, content: str, array_names: dict) -> None:
    """Process MirrorView-S worksheet

    :param workbook:
    :param content:
    :param array_names:
    """
    worksheet = workbook.get_sheet_by_name('MirrorView-S')

    headers = get_parser_header(MIRROR_VIEW_S_TMPL)

    RowTuple = namedtuple('RowTuple', headers)  # pylint: disable=invalid-name

    build_header(worksheet, headers)

    cmd_mirror_view_s_out = check_empty_arrays(
        take_array_names(array_names,
                         run_parser_over(content, MIRROR_VIEW_S_TMPL)))

    rows = unique(cmd_mirror_view_s_out, key=itemgetter(0))
    final_col, final_row = 0, 0
    for row_n, row_tuple in enumerate(map(RowTuple._make, rows), 2):
        for col_n, col_value in \
                enumerate(row_tuple._asdict().values(), ord('A')):
            cell = worksheet['{}{}'.format(chr(col_n), row_n)]
            cell.value = str.strip(col_value)
            style_value_cell(cell)
            set_cell_to_number(cell)
            final_col = col_n
        final_row = row_n

    sheet_process_output(worksheet, 'MirrorViewSTable', 'MirrorView-S',
                         final_col, final_row)
Exemplo n.º 2
0
def process(workbook: Any, content: str) -> None:
    """Process Software-Packages worksheet

    :param workbook:
    :param content:
    """
    worksheet_name = 'Software-Packages'
    worksheet = workbook.get_sheet_by_name(worksheet_name)

    headers = get_parser_header(NDU_TMPL)
    RowTuple = namedtuple('RowTuple', headers)

    build_header(worksheet, headers)

    cmd_ndu_out = run_parser_over(content, NDU_TMPL)
    cmd_ndu_out = check_empty_arrays(
        list(unique(cmd_ndu_out, key=itemgetter(0, 1))))
    final_col, final_row = 0, 0
    for row_n, row_tuple in enumerate(map(RowTuple._make, cmd_ndu_out), 2):
        for col_n, col_value in \
                enumerate(row_tuple._asdict().values(), ord('A')):
            cell = worksheet['{}{}'.format(chr(col_n), row_n)]
            cell.value = str.strip(col_value)
            if cell.value != '-':
                cell.value = str.strip(col_value, '-')
            style_value_cell(cell)
            set_cell_to_number(cell)
            final_col = col_n
        final_row = row_n

    sheet_process_output(worksheet, 'SoftwarePackagesTable',
                         'Software-Packages', final_col, final_row)
Exemplo n.º 3
0
def process(workbook: Any, content: str) -> tuple:
    """Process Storage-Array-Summary worksheet

    Also returns a list of array names used in other sheets

    :param workbook:
    :param content:
    :return:
    """
    worksheet = workbook.get_sheet_by_name('Storage-Array-Summary')

    headers = list(concat([
        get_parser_header(ARRAY_NAME_TMPL),
        get_parser_header(GET_ARRAY_UID_TMPL),
        get_parser_header(GET_AGENT_TMPL)
    ]))
    RowTuple = namedtuple('RowTuple', headers)   # pylint: disable=invalid-name

    build_header(worksheet, headers)

    cmd_arrayname_out = run_parser_over(content, ARRAY_NAME_TMPL)
    cmd_getarrayuid_out = run_parser_over(content, GET_ARRAY_UID_TMPL)
    cmd_getagent_out = run_parser_over(content, GET_AGENT_TMPL)

    # noinspection PyTypeChecker
    cmd_out = map(compose(
        list,
        concat),
        zip(
            cmd_arrayname_out,
            cmd_getarrayuid_out,
            cmd_getagent_out))

    array_names = defaultdict(str)    # type: defaultdict
    rows = check_empty_arrays(list(unique(cmd_out, key=itemgetter(0, 1))))
    final_col, final_row = 0, 0
    for row_n, row_tuple in enumerate(map(RowTuple._make, rows), 2):
        for col_n, col_value in \
                enumerate(row_tuple._asdict().values(), ord('A')):
            cell = worksheet['{}{}'.format(chr(col_n), row_n)]
            cell.value = str.strip(col_value)
            style_value_cell(cell)
            set_cell_to_number(cell)
            final_col = col_n
        array_names[worksheet['Q{}'.format(row_n)].value] = \
            worksheet['A{}'.format(row_n)].value
        final_row = row_n

    sheet_process_output(
        worksheet,
        'StorageArraySummaryTable',
        'Storage-Array-Summary',
        final_col,
        final_row)

    array_models = groupby(itemgetter(12), rows)
    array_revisions = groupby(itemgetter(10), rows)
    return array_names, array_models, array_revisions
Exemplo n.º 4
0
def process(workbook: Any, content: str, sg_data: list) -> list:
    """Process LUNs worksheet

    :param workbook:
    :param content:
    :param sg_data:
    """
    worksheet_name = 'LUNs'
    worksheet = workbook.get_sheet_by_name(worksheet_name)

    headers = get_parser_header(GETLUN_TMPL)
    RowTuple = namedtuple('RowTuple', headers)

    build_header(worksheet, headers)

    cmd_getlun_out = run_parser_over(content, GETLUN_TMPL)
    cmd_getlun_out = check_empty_arrays(
        list(unique(cmd_getlun_out, key=itemgetter(0, 1))))

    expanded_luns = [[*entry[:-1], get_luns(entry[-1])] for entry in sg_data]

    sg_dict = {}  # type: dict
    for entry in expanded_luns:
        for lun in entry[-1]:
            sg_dict[entry[0], lun[1]] = entry[1], lun[0]

    for row in cmd_getlun_out:
        if (row[0], row[1]) in sg_dict.keys():
            row[3], row[4] = sg_dict[row[0], row[1]][0], \
                             sg_dict[row[0], row[1]][1]
        else:
            row[3], row[4] = ('No Storage Group Found', '')
        row[12] = capacity_conversion(row[11])

    final_col, final_row = 0, 0
    for row_n, row_tuple in enumerate(map(RowTuple._make, cmd_getlun_out), 2):
        for col_n, col_value in \
                enumerate(row_tuple._asdict().values(), ord('A')):
            cell = worksheet['{}{}'.format(chr(col_n), row_n)]
            cell.value = str.strip(col_value)
            style_value_cell(cell)
            if chr(col_n) == 'K':
                set_cell_to_number(cell, '0.00000')
            else:
                set_cell_to_number(cell)
            final_col = col_n
        final_row = row_n

    sheet_process_output(worksheet, 'LUNSTable', 'LUNs', final_col, final_row)

    return cmd_getlun_out
Exemplo n.º 5
0
def process(workbook: Any, content: str) -> list:
    """Process Disks worksheet

    :param workbook:
    :param content:
    """
    worksheet_name = 'Disks'
    worksheet = workbook.get_sheet_by_name(worksheet_name)

    headers = get_parser_header(GETDISK_TMPL)
    RowTuple = namedtuple('RowTuple', headers)

    build_header(worksheet, headers)

    cmd_disks_out = run_parser_over(content, GETDISK_TMPL)
    cmd_disks_out = check_empty_arrays(
        list(unique(cmd_disks_out, key=itemgetter(0, 1, 2, 3))))

    for row in cmd_disks_out:
        row[7] = capacity_conversion(row[6])

    final_col, final_row = 0, 0
    for row_n, row_tuple in enumerate(map(RowTuple._make, cmd_disks_out), 2):
        for col_n, col_value in \
                enumerate(row_tuple._asdict().values(), ord('A')):
            cell = worksheet['{}{}'.format(chr(col_n), row_n)]
            if isinstance(col_value, str):
                cell.value = str.strip(col_value)
            else:
                cell.alignment = Alignment(wrapText=True)
                cell.value = str.strip('\n'.join(col_value))
            style_value_cell(cell)
            if chr(col_n) == 'H':
                set_cell_to_number(cell, '0.00000')
            else:
                set_cell_to_number(cell)
            final_col = col_n
        final_row = row_n

    sheet_process_output(
        worksheet,
        'DisksTable',
        'Disks',
        final_col,
        final_row)

    return cmd_disks_out
Exemplo n.º 6
0
def process(workbook: Workbook, content: str) -> list:
    """Process SP-Frontend-Ports worksheet

    :param workbook:
    :param content:
    :return:
    """
    worksheet_name = 'SP-Frontend-Ports'
    worksheet = workbook.get_sheet_by_name(worksheet_name)

    headers = list(
        concat([
            get_parser_header(PORT_TMPL),
            get_parser_header(SPPORTSPEED_TMPL)[3:],
        ]))
    RowTuple = namedtuple('RowTuple', headers)  # pylint: disable=invalid-name

    build_header(worksheet, headers)

    cmd_port_out = run_parser_over(content, PORT_TMPL)
    cmd_spportspeed_out = run_parser_over(content, SPPORTSPEED_TMPL)

    common_columns = (0, 1, 2)
    common_columns_getter = itemgetter(*common_columns)
    cmd_merged_out = join(common_columns_getter, cmd_port_out,
                          common_columns_getter, cmd_spportspeed_out)

    rows = map(compose(list, concat,
                       juxt(first, compose(drop(3), second))))(cmd_merged_out)
    rows = check_empty_arrays(list(unique(rows, key=common_columns_getter)))

    final_col, final_row = 0, 0
    for row_n, row_tuple in enumerate(map(RowTuple._make, rows), 2):
        for col_n, col_value in \
                enumerate(row_tuple._asdict().values(), ord('A')):
            cell = worksheet['{}{}'.format(chr(col_n), row_n)]
            cell.value = str.strip(col_value)
            style_value_cell(cell)
            set_cell_to_number(cell)
            final_col = col_n
        final_row = row_n

    sheet_process_output(worksheet, 'SPFrontendPortsTable',
                         'SP-Frontend-Ports', final_col, final_row)

    return rows
Exemplo n.º 7
0
def process(workbook: Any, content: str) -> Any:
    """Process Storage-Groups worksheet

    :param workbook:
    :param content:
    :return:
    """

    worksheet_name = 'Storage-Groups'
    worksheet = workbook.get_sheet_by_name(worksheet_name)

    headers = list(concat([
        get_parser_header(PORT_TMPL),
        get_parser_header(STORAGEGROUP_TMPL)[3:],
    ]))
    RowTuple = namedtuple('RowTuple', headers)  # pylint: disable=invalid-name

    build_header(worksheet, headers)

    cmd_storagegroup_out = run_parser_over(content, STORAGEGROUP_TMPL)
    cmd_port_out = run_parser_over(content, PORT_TMPL)

    common_columns = (0, 1)
    server_names_grouped = compose(
        valmap(
            compose(list, set, map(last))),
        groupby(
            itemgetter(*common_columns))
    )(cmd_port_out)

    cmd_port_relevant = map(
        juxt(
            compose(first, first),
            compose(second, first),
            second)
    )(server_names_grouped.items())

    common_columns_getter = itemgetter(*common_columns)
    cmd_merged_out = join(
        common_columns_getter, cmd_port_relevant,
        common_columns_getter, cmd_storagegroup_out)

    cmd_merged_out = sorted(cmd_merged_out)

    rows = list(map(
        compose(
            list,
            concat,
            juxt(
                first,
                compose(
                    drop(3),
                    second)))
    )(cmd_merged_out))

    portcmd = {(array, grp) for array, grp, *other in rows}
    strgp = {(array, grp) for array, grp, *other in cmd_storagegroup_out}
    no_server_groups = strgp - portcmd

    storage_list = list(filter(
        lambda storage_gr: any(
            fnmatch(str((storage_gr[0], storage_gr[1])), str(ctrlServer))
            for ctrlServer in no_server_groups),
        cmd_storagegroup_out))

    storage_list = check_empty_arrays(
        list(unique(storage_list + rows, key=itemgetter(0, 1))))

    final_col, final_row = 0, 0
    for row_n, row_tuple in enumerate(map(RowTuple._make, storage_list), 2):
        for col_n, col_value in \
                enumerate(row_tuple._asdict().values(), ord('A')):
            cell = worksheet['{}{}'.format(chr(col_n), row_n)]
            if isinstance(col_value, str):
                cell.value = str.strip(col_value)
            else:
                cell.alignment = Alignment(wrapText=True)
                cell.value = '\n'.join(col_value)
            style_value_cell(cell)
            set_cell_to_number(cell)
            final_col = col_n
        final_row = row_n

    sheet_process_output(
        worksheet,
        'StorageGroupsTable',
        'Storage-Groups',
        final_col,
        final_row)

    return [[lun_map[0], lun_map[1], lun_map[4]] for lun_map in storage_list]
Exemplo n.º 8
0
def process(workbook: Any, content: str) -> list:
    """Process Storage-Array-Summary worksheet (XtremIO)

    :param workbook:
    :param content:
    :return:
    """
    worksheet = workbook.get_sheet_by_name('Storage-Array-Summary')

    headers = list(
        concat([
            get_parser_header(SHOW_CLUSTERS_TMPL),
            get_parser_header(SHOW_CLUSTERS_INFO_TMPL)[1:],
            get_parser_header(SHOW_X_BRICKS_TMPL)[1:],
            get_parser_header(SHOW_STORAGE_INFO_TMPL)[1:],
            get_parser_header(CLUSTERS_SAVINGS_TMPL)[1:]
        ]))
    RowTuple = namedtuple('RowTuple', headers)  # pylint: disable=invalid-name

    build_header(worksheet, headers)

    show_clusters_out = run_parser_over(content, SHOW_CLUSTERS_TMPL)
    clusters_info_out = run_parser_over(content, SHOW_CLUSTERS_INFO_TMPL)
    show_bricks_out = run_parser_over(content, SHOW_X_BRICKS_TMPL)
    show_storage_out = run_parser_over(content, SHOW_STORAGE_INFO_TMPL)
    clusters_savings_out = run_parser_over(content, CLUSTERS_SAVINGS_TMPL)

    common_columns = (0, )
    # noinspection PyTypeChecker
    bricks = defaultdict(list)  # type: dict
    for cluster, brick in show_bricks_out:
        bricks[cluster].append(brick)

    show_bricks_out = [[key, bricks[key]] for key in bricks]

    storages = defaultdict(list)  # type: dict
    for cluster, *st_info in show_storage_out:
        storages[cluster].append(st_info)

    show_storage_out = []
    idx = 0
    for key in storages:
        show_storage_out.append([key])
        info = zip(*storages[key])
        for val in info:
            show_storage_out[idx].append(val)
        idx += 1

    rows = multiple_join(common_columns, [
        show_clusters_out, clusters_info_out, show_bricks_out,
        show_storage_out, clusters_savings_out
    ])

    rows = unique(rows, key=itemgetter(0))
    final_col, final_row = 0, 0
    for row_n, row_tuple in enumerate(map(RowTuple._make, rows), 2):
        for col_n, col_value in \
                enumerate(row_tuple._asdict().values(), ord('A')):
            cell = worksheet['{}{}'.format(chr(col_n), row_n)]
            if isinstance(col_value, str):
                cell.value = str.strip(col_value)
                if chr(col_n) in ('E', 'F', 'G'):
                    cell.value += 'B'
            else:
                cell.alignment = Alignment(wrapText=True)
                cell.value = '\n'.join(col_value)
            set_cell_to_number(cell)
            style_value_cell(cell)
            final_col = col_n
        final_row = row_n

    clusters = [("Cluster Names:",
                 ", ".join([clusters[0]
                            for clusters in show_clusters_out]), '', '')]

    sheet_process_output(worksheet, 'StorageArraySummaryTable',
                         'Storage-Array-Summary', final_col, final_row)

    return clusters