def process(workbook: Any, content: list) -> None: """Process Storage Controllers worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Storage Controllers') header = [ 'Name', 'State', 'Product', 'Release', 'Bundle', 'MTM', 'S/N', 'Machine Signature', 'WWNN', 'Number of Frames', 'Processors', 'System Memory (GB)', 'Storage Capacity (TB)', 'Last Power on Time', 'Install Time', 'Power Control Mode' ] build_header(worksheet, header) rows = [] # type: list for csv_file in content: storage_csv = csv.reader(csv_file.split('\n')) rows += get_rows(storage_csv, header) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(rows, 2): for col_n, col_value in \ enumerate(row_tuple, ord('A')): cell = worksheet['{}{}'.format(chr(col_n), row_n)] cell.value = str.strip(col_value) set_cell_to_number(cell) style_value_cell(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'StorageControllersTable', 'Storage Controllers', final_col, final_row)
def process(workbook: Any, nfs_rows: list, smb_rows: list) -> None: """Process File System by Protocol Sheet :param workbook: :param nfs_rows: :param smb_rows: """ worksheet_name = 'File System by Protocol' worksheet = workbook.get_sheet_by_name(worksheet_name) headers = ['Hostname', 'FileSystem', 'Path', 'Type'] RowTuple = namedtuple('RowTuple', headers) build_header(worksheet, headers) key_columns = (0, 1) rows = groupby(itemgetter(*key_columns), nfs_rows + smb_rows) rows = [get_multiprotocol(rows[i]) for i in rows] 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, 'FileSystemProtocolTable', 'File System by Protocol', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process Target Ports worksheet (XtremIO) :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Target Ports') headers = get_parser_header(SHOW_TARGETS_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name build_header(worksheet, headers) show_targets_out = run_parser_over(content, SHOW_TARGETS_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, show_targets_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 = '\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, 'TargetPortsTable', 'Target Ports', final_col, final_row)
def process(workbook: Any, content: list) -> list: """Process Throughput worksheet :param workbook: :param content: :return: """ worksheet = workbook.get_sheet_by_name('Throughput') rows, header = [], [] # type: list, list for csv_file in content: cluster = perf_cluster_name(csv_file) throughput_csv = csv.reader(csv_file.split('\n')[1:]) header = ['Cluster'] + next(throughput_csv) if header == [] else header rows += [[cluster] + csv_row for csv_row in throughput_csv if csv_row not in ([], header[1:])] if header: header[3], header[-2] = header[3] + ' 2', header[-2] + ' 3' build_header(worksheet, header) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(rows, 2): for col_n, col_value in enumerate(row_tuple, ord('A')): cell = worksheet['{}{}'.format(chr(col_n), row_n)] cell.value = str.strip(col_value) set_cell_to_number(cell) style_value_cell(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'ThroughputTable', 'Throughput', final_col, final_row) return rows
def process(workbook: Any, content: list) -> None: """Process Performance Summary worksheet (XtremIO) :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Performance Summary') header = ['Column', 'Avg', '95th', 'Max'] build_header(worksheet, header) final_col, final_row = 0, 0 content += [('Logical capacity exposed:', '', '', '')] for row_n, row_tuple in enumerate(content, 2): for col_n, col_value in \ enumerate(row_tuple, ord('A')): cell = worksheet['{}{}'.format(chr(col_n), row_n)] cell.value = str.strip(col_value) set_cell_to_number(cell) style_value_cell(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'PerformanceSummaryTable', 'Performance Summary', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process Storage Array Summary (3Par) worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Storage Array Summary') headers = get_parser_header(SHOWSYS_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name build_header(worksheet, headers) showsys_out = run_parser_over(content, SHOWSYS_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, showsys_out), 2): for col_n, col_value in \ enumerate(row_tuple._asdict().values(), ord('A')): cell = worksheet['{}{}'.format(column_format(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, 'StorageArraySummaryTable', 'Storage Array Summary', final_col, final_row)
def process(workbook: Any, content: str) -> list: """Process Performance Output worksheet (XtremIO) :param workbook: :param content: :return: """ worksheet = workbook.get_sheet_by_name('Performance Output') perf_csv = csv.reader(content.split('\n')) header = next(perf_csv) header += [ 'Per Interval Read % by throughput', 'Per interval total throughput', 'Per interval write io size', 'per interval read io size', 'Per interval total io size (KB/s)' ] build_header(worksheet, header) # we check for '' in each row to remove blank rows that are in the file # perf_csv is a list of lists containing all the rows of the file rows = filter( lambda x: '' not in x and len(x) > 1 and x != header[:8], perf_csv) summary_data = ([], [], [], [], [], [], [], [], []) # type: tuple final_col, final_row, start_date, end_date = 0, 0, '', '' for row_n, row_tuple in enumerate(rows, 2): start_date = row_tuple[0] if start_date == '' else start_date xls_row = compute_row(row_tuple) summary_data = store_summary(summary_data, xls_row) for col_n, col_value in \ enumerate(xls_row, ord('A')): cell = worksheet['{}{}'.format(chr(col_n), row_n)] cell.value = str.strip(col_value) set_cell_to_number(cell) style_value_cell(cell) final_col = col_n final_row = row_n end_date = row_tuple[0] perf_summary = list() for summary_column, data_origin in zip( summary_data, header[1:5] + header[8:]): perf_summary.append(( data_origin, str(sum(summary_column) / len(summary_column)), str(percentile(summary_column, 0.95)), str(max(summary_column)))) perf_summary += [ ('Perf Collection Beginning Date:', start_date, '', ''), ('Perf Collection End Date:', end_date, '', '') ] sheet_process_output( worksheet, 'PerformanceOutputTable', 'Performance Output', final_col, final_row) return perf_summary
def process(workbook: Any, content: str) -> None: """Process NAS_License worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('NAS_License') headers = get_parser_header(NAS_LICENSE_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name build_header(worksheet, headers) nas_license_out = run_parser_over(content, NAS_LICENSE_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, nas_license_out), 2): for col_n, col_value in \ enumerate(row_tuple._asdict().values(), ord('A')): cell = worksheet['{}{}'.format(column_format(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, 'NASLicenseTable', 'NAS_License', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process NAS Summary worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('NAS Summary') headers = get_parser_header(NAS_SUMMARY_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name build_header(worksheet, headers) nas_summary_out = run_parser_over(content, NAS_SUMMARY_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, nas_summary_out), 2): for col_n, col_value in \ enumerate(row_tuple._asdict().values(), ord('A')): cell = worksheet['{}{}'.format(column_format(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, 'NASSummaryTable', 'NAS Summary', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process dskgrp_summary worksheet :param workbook: :param content: """ worksheet_name = 'dskgrp_summary' worksheet = workbook.get_sheet_by_name(worksheet_name) headers = get_parser_header(DSKRGP_TMPL) RowTuple = namedtuple('RowTuple', headers) headers[5], headers[6], headers[8] = \ 'diskspeed(RPM)', 'disksize(MB)', 'totalcapacity(MB)' build_header(worksheet, headers) worksheet['E1'].comment = Comment(legend, '') dskgrp_summary_out = run_parser_over(content, DSKRGP_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, dskgrp_summary_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) set_cell_to_number(cell) final_col = col_n final_row = row_n sheet_process_output( worksheet, 'DskgrpSummaryTable', 'dskgrp_summary', final_col, final_row)
def process(workbook: Any, contents: list) -> None: """Process Storage Inventory worksheet :param workbook: :param contents: """ worksheet_name = 'Storage Inventory' worksheet = workbook.get_sheet_by_name(worksheet_name) system_excel_header = [ 'SystemObjectName', 'SystemType', 'FirmwareVersion', 'TotalStorageSpace', 'AvailableStorageSpace', 'UsedStorageSpace' ] SystemTuple = namedtuple('SystemTuple', system_excel_header) build_header(worksheet, system_excel_header) system_header = [ 'objectname', 'systemtype', 'firmwareversion', 'totalstoragespace', 'availablestoragespace', 'usedstoragespace' ] system_data = [] # type: list for content in contents: doc = xmltodict.parse(content) system_data += list( ordered_jsons(search_tag_value(doc, 'object'), system_header)) final_col, final_row = write_excel(system_data, worksheet, SystemTuple, 'A') sheet_process_output(worksheet, 'SystemTable', 'Storage Inventory', final_col, final_row)
def process(workbook: Any, content: list) -> None: """Process SAN Hosts worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('SAN Hosts') header = [ 'SystemName', 'WWPN', 'State', 'Host', 'Type', 'Address Mode', 'Volumes', 'Number of Accessible I/O Ports', 'Address Discovery', 'Logical Block Size', 'Host Connect', 'Volume Group' ] build_header(worksheet, header) rows = [] # type: list for csv_file in content: storage_csv = csv.reader(csv_file.split('\n')) system_name = get_rows(storage_csv, ['Name']) san_hosts_rows = get_rows(storage_csv, header[1:]) rows += [system_name[0] + feat_row for feat_row in san_hosts_rows] final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(rows, 2): for col_n, col_value in \ enumerate(row_tuple, ord('A')): cell = worksheet['{}{}'.format(chr(col_n), row_n)] cell.value = str.strip(col_value) set_cell_to_number(cell) style_value_cell(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'SANHostsTable', 'SAN Hosts', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process Disks (3Par) worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Disks') headers = get_parser_header(SHOWPD_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name headers[7], headers[8], headers[11] = 'Total(MB)', 'Free(MB)', 'Cap(GB)' build_header(worksheet, headers) show_pd_out = run_parser_over(content, SHOWPD_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, show_pd_out), 2): for col_n, col_value in \ enumerate(row_tuple._asdict().values(), ord('A')): cell = worksheet['{}{}'.format(column_format(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, 'DisksTable', 'Disks', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process device_name_list worksheet :param workbook: :param content: """ worksheet_name = 'device_name_list' worksheet = workbook.get_sheet_by_name(worksheet_name) headers = get_parser_header(DEVNM_TMPL) RowTuple = namedtuple('RowTuple', headers) build_header(worksheet, headers) device_name_list_out = run_parser_over(content, DEVNM_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate( map(RowTuple._make, device_name_list_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) != 'B': set_cell_to_number(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'DevNameListTable', 'device_name_list', final_col, final_row)
def process(workbook: Any, content: list) -> None: """Process Drives worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Drives') header = [ 'SystemName', 'S/N', 'State', 'Array', 'Drive Capacity (GB)', 'Drive Class', 'Interface', 'Interface Rate (Gbps)', 'Firmware', 'Location', 'WWNN', 'Encryption' ] build_header(worksheet, header) rows = [] # type: list for csv_file in content: storage_csv = csv.reader(csv_file.split('\n')) system_name = get_rows(storage_csv, ['Name']) drives_rows = get_rows(storage_csv, header[1:]) rows += [system_name[0] + feat_row for feat_row in drives_rows] final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(rows, 2): for col_n, col_value in \ enumerate(row_tuple, ord('A')): cell = worksheet['{}{}'.format(chr(col_n), row_n)] cell.value = str.strip(col_value) set_cell_to_number(cell) style_value_cell(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'DrivesTable', 'Drives', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process Disk Groups worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Disk Groups') headers = get_parser_header(DISK_GROUPS_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name build_header(worksheet, headers) disk_groups_out = run_parser_over(content, DISK_GROUPS_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, disk_groups_out), 2): for col_n, col_value in \ enumerate(row_tuple._asdict().values(), ord('A')): cell = worksheet['{}{}'.format(column_format(col_n), row_n)] cell.value = str.strip(col_value) style_value_cell(cell) if chr(col_n) not in ('B', ): set_cell_to_number(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'DiskGroupsTable', 'Disk Groups', final_col, final_row)
def process(workbook: Any, content: list) -> None: """Process Count Modified worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Count Modified') rows, header = [], [] # type: list, list for csv_file in content: cluster = perf_cluster_name(csv_file) count_mod_csv = csv.reader(csv_file.split('\n')[1:]) header = ['Cluster'] + next(count_mod_csv) if header == [] else header rows += [[cluster] + csv_row for csv_row in count_mod_csv if csv_row not in ([], header[1:])] build_header(worksheet, header) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(rows, 2): for col_n, col_value in enumerate(row_tuple, ord('A')): cell = worksheet['{}{}'.format(chr(col_n), row_n)] cell.value = str.strip(col_value) set_cell_to_number(cell) style_value_cell(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'CountModifiedTable', 'Count Modified', final_col, final_row)
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)
def process(workbook: Any, content: str) -> None: """Process list_WWN worksheet :param workbook: :param content: """ worksheet_name = 'list_WWN' worksheet = workbook.get_sheet_by_name(worksheet_name) headers = get_parser_header(LSTWWN_TMPL) RowTuple = namedtuple('RowTuple', headers) build_header(worksheet, headers) list_wwn_out = run_parser_over(content, LSTWWN_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, list_wwn_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) not in ('B', 'F'): set_cell_to_number(cell) final_col = col_n final_row = row_n sheet_process_output( worksheet, 'ListWWNTable', 'list_WWN', final_col, final_row)
def process(workbook: Any, contents: list) -> None: """Process Hosts worksheet :param workbook: :param contents: """ worksheet_name = 'Hosts' worksheet = workbook.get_sheet_by_name(worksheet_name) host_excel_header = [ 'HostName', 'OperationalState', 'OSMode', 'HostType', 'VirtualDiskName' ] HostTuple = namedtuple('HostTuple', host_excel_header) build_header(worksheet, host_excel_header) host_header = [ 'hostname', 'operationalstate', 'osmode', 'hosttype', 'presentation/virtualdiskname' ] disk_data = [] # type: list for content in contents: doc = xmltodict.parse(content) raw_disk_data = [ flatten_dict(det_dict) for det_dict in search_tag_value(doc, 'object') ] disk_data += ordered_jsons(raw_disk_data, host_header) final_col, final_row = write_excel(disk_data, worksheet, HostTuple, 'A') sheet_process_output(worksheet, 'HostsTable', 'Hosts', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process Pools worksheet :param workbook: :param content: """ worksheet_name = 'Pools' worksheet = workbook.get_sheet_by_name(worksheet_name) headers = get_parser_header(POOLS_TMPL) RowTuple = namedtuple('RowTuple', headers) build_header(worksheet, headers) pools_out = run_parser_over(content, POOLS_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, pools_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) set_cell_to_number(cell) final_col = col_n final_row = row_n sheet_process_output( worksheet, 'PoolsTable', 'Pools', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process access_initiator worksheet :param workbook: :param content: """ worksheet_name = 'access_initiator' worksheet = workbook.get_sheet_by_name(worksheet_name) headers = get_parser_header(ACSINIT_TMPL) RowTuple = namedtuple('RowTuple', headers) build_header(worksheet, headers) access_initiator_out = run_parser_over(content, ACSINIT_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate( map(RowTuple._make, access_initiator_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 = '\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, 'AccessInitiatorTable', 'access_initiator', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process Backend Storage SP DETAILS worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Backend Storage SP DETAILS') headers = get_parser_header(BACKEND_DETAILS_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name build_header(worksheet, headers) backend_details_out = run_parser_over(content, BACKEND_DETAILS_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, backend_details_out), 2): for col_n, col_value in \ enumerate(row_tuple._asdict().values(), ord('A')): cell = worksheet['{}{}'.format(column_format(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, 'BackendStorageSPDETAILSTable', 'Backend Storage SP DETAILS', final_col, final_row)
def process(workbook: Any, content: list) -> None: """Process Arrays worksheet :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Arrays') header = [ 'SystemName', 'ID', 'State', 'Pool', 'Storage Type', 'Total Capacity (GiB)', 'Allocated Capacity (GiB)', 'Drive Capacity (GB)' ] build_header(worksheet, header) rows = [] # type: list for csv_file in content: storage_csv = csv.reader(csv_file.split('\n')) system_name = get_rows(storage_csv, ['Name']) arrays_rows = get_rows(storage_csv, header[1:]) rows += [system_name[0] + feat_row for feat_row in arrays_rows] final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(rows, 2): for col_n, col_value in \ enumerate(row_tuple, ord('A')): cell = worksheet['{}{}'.format(chr(col_n), row_n)] cell.value = str.strip(col_value) set_cell_to_number(cell) style_value_cell(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'ArraysTable', 'Arrays', final_col, final_row)
def process(workbook: Any, content: str, array_names: dict) -> None: """Process SnapView worksheet :param workbook: :param content: :param array_names: """ worksheet = workbook.get_sheet_by_name('SnapView') headers = get_parser_header(SNAP_VIEW_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name build_header(worksheet, headers) snap_view_out = check_empty_arrays( take_array_names(array_names, run_parser_over(content, SNAP_VIEW_TMPL))) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, snap_view_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) set_cell_to_number(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'SnapViewTable', 'SnapView', final_col, final_row)
def process(workbook: Any, content: str) -> None: """Process Data Protection Groups worksheet (XtremIO) :param workbook: :param content: """ worksheet = workbook.get_sheet_by_name('Data Protection Groups') headers = get_parser_header(SHOW_DATA_PROTECTION_TMPL) RowTuple = namedtuple('RowTuple', headers) # pylint: disable=invalid-name build_header(worksheet, headers) show_targets_out = run_parser_over(content, SHOW_DATA_PROTECTION_TMPL) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(map(RowTuple._make, show_targets_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) set_cell_to_number(cell) final_col = col_n final_row = row_n sheet_process_output(worksheet, 'DataProtectionGroupsTable', 'Data Protection Groups', final_col, final_row)
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)
def process(workbook: Any, contents: list) -> None: """Process Drive List worksheet :param workbook: :param contents: """ worksheet_name = 'Drive List' worksheet = workbook.get_sheet_by_name(worksheet_name) headers = [ 'hostname', 'cluster', 'lnum', 'baynum', 'lnn', 'purpose_description', 'blocks', 'serial', 'wwn', 'logical_block_length', 'ui_state', 'physical_block_length', 'firmware/desired_firmware', 'firmware/current_firmware', 'id', 'media_type', 'interface_type', 'handle', 'devname', 'chassis', 'purpose', 'y_loc', 'x_loc', 'present', 'locnstr', 'model' ] build_header(worksheet, headers) rows, errors = [], 0 # type: list, int for content in contents: doc = xmltodict.parse(content) component_details = search_tag_value(doc, 'component_details') command_details = search_tag_value(doc, 'command_details') drive_list = [] # type: Iterable host = component_details['hostname'] for entry in command_details: with suppress(TypeError): drives_content = collected_data( entry, 'cmd', 'isi_for_array isi devices list --format?json') drive_list, local_errors = process_drives( drives_content, headers[2:]) if drives_content else [drive_list, 0] errors += local_errors rows += [[host] + row for row in drive_list] if errors != 0: print('{} bad jsons found in {}, ' 'some data will not be found in the output!'.format( errors, worksheet_name)) final_col, final_row = 0, 0 for row_n, row_tuple in enumerate(rows, 2): for col_n, col_value in \ enumerate(row_tuple, ord('A')): cell = worksheet['{}{}'.format(column_format(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, 'DriveListTable', 'Drive List', final_col, final_row)
def process(workbook: Any, contents: list) -> None: """Process Storage Inventory worksheet :param workbook: :param contents: """ worksheet_name = 'Storage Inventory' worksheet = workbook.get_sheet_by_name(worksheet_name) headers = list(concat([ ['Hostname', 'Model', 'OS', 'Nodes'], get_parser_header(DEDUPE_TMPL) ])) RowTuple = namedtuple('RowTuple', headers) build_header(worksheet, headers) rows = [] for content in contents: doc = xmltodict.parse(content) component_details = search_tag_value(doc, 'component_details') command_details = search_tag_value(doc, 'command_details') dedupe, nodes = [], 0 # type: (list, int) for entry in command_details: nodes_content = collected_data( entry, 'cmd', 'isi storagepool nodepools list') nodes = max(map(compose(int, itemgetter(0)), run_parser_over( nodes_content, NODES_TMPL))) if nodes_content else nodes dedupe_content = collected_data(entry, 'cmd', 'isi dedupe stats') dedupe = run_parser_over( dedupe_content, DEDUPE_TMPL) if dedupe_content else dedupe dedupe = dedupe if len(dedupe) > 1 else [['', '', '', '', '', '']] rows.append([ component_details['hostname'], component_details['model'], component_details['os'], str(nodes), *dedupe[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, 'StorageInventoryTable', 'Storage Inventory', final_col, final_row)
def process(workbook: Any, contents: list) -> None: """Process Controller worksheet :param workbook: :param contents: """ worksheet_name = 'Controller' worksheet = workbook.get_sheet_by_name(worksheet_name) excel_header = [ 'controllername', 'datablocksize', 'modelnumber', 'productnumber', 'serialnumber', 'firmwareversion', 'cachecondition', 'readcapacity', 'writecapacity', 'mirrorcapacity', 'portname', 'topology', 'hostportaddress', 'switchtype' ] build_header(worksheet, excel_header) RowTuple = namedtuple('RowTuple', excel_header) header = [ 'controllername', 'datablocksize', 'modelnumber', 'productnumber', 'serialnumber', 'firmwareversion', 'cachememory/cachecondition', 'cachememory/readcapacity', 'cachememory/writecapacity', 'cachememory/mirrorcapacity', 'hostports/hostport/portname', 'hostports/hostport/topology', 'hostports/hostport/hostportaddress', 'deviceports/deviceport/switchtype' ] rows = [] # type: list for content in contents: doc = xmltodict.parse(content) raw_data = [ flatten_dict(det_dict) for det_dict in search_tag_value(doc, 'object') ] for main_dict in raw_data: entry = list(ordered_jsons([main_dict], header[:6])) if entry: main_dict['hostports/hostport'] = merge_dicts( main_dict['hostports/hostport']) main_dict['deviceports/deviceport'] = merge_dicts( main_dict['deviceports/deviceport']) main_dict = flatten_dict(main_dict) rows += ordered_jsons([main_dict], header) 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, 'ControllerTable', 'Controller', final_col, final_row)