def verify_show_platform_fan_output(duthost, raw_output_lines): """ @summary: Verify output of `show platform fan`. Expected output is "Fan Not detected" or a table of fan status data conaining expect number of columns. """ # workaround to make this test compatible with 201911 and master if parse_version(duthost.kernel_version) > parse_version('4.9.0'): NUM_EXPECTED_COLS = 8 else: NUM_EXPECTED_COLS = 6 pytest_assert( len(raw_output_lines) > 0, "There must be at least one line of output") if len(raw_output_lines) == 1: pytest_assert( raw_output_lines[0].encode('utf-8').strip() == "Fan Not detected", "Unexpected fan status output") else: pytest_assert( len(raw_output_lines) > 2, "There must be at least two lines of output if any fan is detected" ) second_line = raw_output_lines[1] field_ranges = util.get_field_range(second_line) pytest_assert( len(field_ranges) == NUM_EXPECTED_COLS, "Output should consist of {} columns".format(NUM_EXPECTED_COLS))
def verify_show_platform_temperature_output(raw_output_lines, hostname): """ @summary: Verify output of `show platform temperature`. Expected output is "Thermal Not detected" or a table of thermal status data with 8 columns. """ NUM_EXPECTED_COLS = 8 pytest_assert( len(raw_output_lines) > 0, "There must be at least one line of output on '{}'".format(hostname)) if len(raw_output_lines) == 1: pytest_assert( raw_output_lines[0].encode( 'utf-8').strip() == "Thermal Not detected", "Unexpected thermal status output on '{}'".format(hostname)) else: pytest_assert( len(raw_output_lines) > 2, "There must be at least two lines of output if any thermal is detected on '{}'" .format(hostname)) second_line = raw_output_lines[1] field_ranges = util.get_field_range(second_line) pytest_assert( len(field_ranges) == NUM_EXPECTED_COLS, "Output should consist of {} columns on '{}'".format( NUM_EXPECTED_COLS, hostname))
def verify_show_platform_fan_output(duthost, raw_output_lines): """ @summary: Verify output of `show platform fan`. Expected output is "Fan Not detected" or a table of fan status data conaining expect number of columns. """ # workaround to make this test compatible with 201911 and master if parse_version(duthost.kernel_version) > parse_version('4.9.0'): NUM_EXPECTED_COLS = 8 else: NUM_EXPECTED_COLS = 6 fans = {} pytest_assert(len(raw_output_lines) > 0, "There must be at least one line of output on '{}'".format(duthost.hostname)) if len(raw_output_lines) == 1: pytest_assert(raw_output_lines[0].encode('utf-8').strip() == "Fan Not detected", "Unexpected fan status output on '{}'".format(duthost.hostname)) else: pytest_assert(len(raw_output_lines) > 2, "There must be at least two lines of output if any fan is detected on '{}'".format(duthost.hostname)) second_line = raw_output_lines[1] field_ranges = util.get_field_range(second_line) field_names = util.get_fields(raw_output_lines[0], field_ranges) pytest_assert(len(field_ranges) == NUM_EXPECTED_COLS, "Output should consist of {} columns on '{}'".format(NUM_EXPECTED_COLS, duthost.hostname)) fan_num = 0 for line in raw_output_lines[2:]: field_values = util.get_fields(line, field_ranges) fans['fan' + str(fan_num)] = {} for field_index, a_field in enumerate(field_names): fans['fan' + str(fan_num)][a_field] = field_values[field_index] fan_num += 1 return fans
def verify_show_platform_firmware_status_output(raw_output_lines, hostname): """ @summary: Verify output of `show platform firmware status`. Expected output is a table of firmware data conaining 5 columns. """ NUM_EXPECTED_COLS = 5 pytest_assert(len(raw_output_lines) > 2, "There must be at least two lines of output on '{}'".format(hostname)) second_line = raw_output_lines[1] field_ranges = util.get_field_range(second_line) pytest_assert(len(field_ranges) == NUM_EXPECTED_COLS, "Output should consist of {} columns on '{}'".format(NUM_EXPECTED_COLS, hostname))
def parse_chassis_module(output, expected_headers): assert len(output) > 2 f_ranges = get_field_range(output[1]) headers = get_fields(output[0], f_ranges) for header_v in expected_headers: pytest_assert(header_v in headers, "Missing header {}".format(header_v)) result = {} for a_line in output[2:]: field_val = get_fields(a_line, f_ranges) mod_idx = field_val[0] result[mod_idx] = {} cur_field = 1 for a_header in headers[1:]: result[mod_idx][a_header] = field_val[cur_field] cur_field += 1 return result
def verify_show_platform_fan_output(raw_output_lines): """ @summary: Verify output of `show platform fan`. Expected output is "Fan Not detected" or a table of fan status data conaining 8 columns. """ NUM_EXPECTED_COLS = 8 pytest_assert( len(raw_output_lines) > 0, "There must be at least one line of output") if len(raw_output_lines) == 1: pytest_assert( raw_output_lines[0].encode('utf-8').strip() == "Fan Not detected", "Unexpected fan status output") else: pytest_assert( len(raw_output_lines) > 2, "There must be at least two lines of output if any fan is detected" ) second_line = raw_output_lines[1] field_ranges = util.get_field_range(second_line) pytest_assert( len(field_ranges) == NUM_EXPECTED_COLS, "Output should consist of {} columns".format(NUM_EXPECTED_COLS))