コード例 #1
0
    def test_get_system_eeprom_info(self, duthost, localhost, platform_api_conn):
        ''' Test that we can retrieve sane system EEPROM info from the DUT via the platform API
        '''
        # OCP ONIE TlvInfo EEPROM type codes defined here: https://opencomputeproject.github.io/onie/design-spec/hw_requirements.html
        VALID_ONIE_TLVINFO_TYPE_CODES_LIST = [
            ONIE_TLVINFO_TYPE_CODE_PRODUCT_NAME,
            ONIE_TLVINFO_TYPE_CODE_PART_NUMBER,
            ONIE_TLVINFO_TYPE_CODE_SERIAL_NUMBER,
            ONIE_TLVINFO_TYPE_CODE_BASE_MAC_ADDR,
            ONIE_TLVINFO_TYPE_CODE_MFR_DATE,
            ONIE_TLVINFO_TYPE_CODE_DEVICE_VERSION,
            ONIE_TLVINFO_TYPE_CODE_LABEL_REVISION,
            ONIE_TLVINFO_TYPE_CODE_PLATFORM_NAME,
            ONIE_TLVINFO_TYPE_CODE_ONIE_VERSION,
            ONIE_TLVINFO_TYPE_CODE_NUM_MACS,
            ONIE_TLVINFO_TYPE_CODE_MANUFACTURER,
            ONIE_TLVINFO_TYPE_CODE_COUNTRY_CODE,
            ONIE_TLVINFO_TYPE_CODE_VENDOR,
            ONIE_TLVINFO_TYPE_CODE_DIAG_VERSION,
            ONIE_TLVINFO_TYPE_CODE_SERVICE_TAG,
            ONIE_TLVINFO_TYPE_CODE_VENDOR_EXT,
            ONIE_TLVINFO_TYPE_CODE_CRC32
        ]

        MINIMUM_REQUIRED_TYPE_CODES_LIST = [
            ONIE_TLVINFO_TYPE_CODE_SERIAL_NUMBER,
            ONIE_TLVINFO_TYPE_CODE_BASE_MAC_ADDR,
            ONIE_TLVINFO_TYPE_CODE_CRC32
        ]

        syseeprom_info_dict = chassis.get_system_eeprom_info(platform_api_conn)
        pytest_assert(syseeprom_info_dict is not None, "Failed to retrieve system EEPROM data")
        pytest_assert(isinstance(syseeprom_info_dict, dict), "System EEPROM data is not in the expected format")

        syseeprom_type_codes_list = syseeprom_info_dict.keys()

        # Ensure that all keys in the resulting dictionary are valid ONIE TlvInfo type codes
        pytest_assert(set(syseeprom_type_codes_list) <= set(VALID_ONIE_TLVINFO_TYPE_CODES_LIST), "Invalid TlvInfo type code found")

        # Ensure that we were able to obtain the minimum required type codes
        pytest_assert(set(MINIMUM_REQUIRED_TYPE_CODES_LIST) <= set(syseeprom_type_codes_list), "Minimum required TlvInfo type codes not provided")

        # Ensure the base MAC address is sane
        base_mac = syseeprom_info_dict[ONIE_TLVINFO_TYPE_CODE_BASE_MAC_ADDR]
        pytest_assert(base_mac is not None, "Failed to retrieve base MAC address")
        pytest_assert(re.match(REGEX_MAC_ADDRESS, base_mac), "Base MAC address appears to be incorrect")

        # Ensure the serial number is sane
        serial = syseeprom_info_dict[ONIE_TLVINFO_TYPE_CODE_SERIAL_NUMBER]
        pytest_assert(serial is not None, "Failed to retrieve serial number")
        pytest_assert(re.match(REGEX_SERIAL_NUMBER, serial), "Serial number appears to be incorrect")

        self.compare_value_with_device_facts('syseeprom_info', syseeprom_info_dict)
コード例 #2
0
    def test_get_system_eeprom_info(self, duthosts,
                                    enum_rand_one_per_hwsku_hostname,
                                    localhost, platform_api_conn):
        ''' Test that we can retrieve sane system EEPROM info from the DUT via the platform API
        '''
        # OCP ONIE TlvInfo EEPROM type codes defined here: https://opencomputeproject.github.io/onie/design-spec/hw_requirements.html
        VALID_ONIE_TLVINFO_TYPE_CODES_LIST = [
            ONIE_TLVINFO_TYPE_CODE_PRODUCT_NAME,
            ONIE_TLVINFO_TYPE_CODE_PART_NUMBER,
            ONIE_TLVINFO_TYPE_CODE_SERIAL_NUMBER,
            ONIE_TLVINFO_TYPE_CODE_BASE_MAC_ADDR,
            ONIE_TLVINFO_TYPE_CODE_MFR_DATE,
            ONIE_TLVINFO_TYPE_CODE_DEVICE_VERSION,
            ONIE_TLVINFO_TYPE_CODE_LABEL_REVISION,
            ONIE_TLVINFO_TYPE_CODE_PLATFORM_NAME,
            ONIE_TLVINFO_TYPE_CODE_ONIE_VERSION,
            ONIE_TLVINFO_TYPE_CODE_NUM_MACS,
            ONIE_TLVINFO_TYPE_CODE_MANUFACTURER,
            ONIE_TLVINFO_TYPE_CODE_COUNTRY_CODE, ONIE_TLVINFO_TYPE_CODE_VENDOR,
            ONIE_TLVINFO_TYPE_CODE_DIAG_VERSION,
            ONIE_TLVINFO_TYPE_CODE_SERVICE_TAG,
            ONIE_TLVINFO_TYPE_CODE_VENDOR_EXT, ONIE_TLVINFO_TYPE_CODE_CRC32
        ]

        MINIMUM_REQUIRED_TYPE_CODES_LIST = [
            ONIE_TLVINFO_TYPE_CODE_SERIAL_NUMBER,
            ONIE_TLVINFO_TYPE_CODE_BASE_MAC_ADDR, ONIE_TLVINFO_TYPE_CODE_CRC32
        ]

        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        syseeprom_info_dict = chassis.get_system_eeprom_info(platform_api_conn)
        # Convert all keys of syseeprom_info_dict into lower case
        syseeprom_info_dict = {
            k.lower(): v
            for k, v in syseeprom_info_dict.items()
        }
        pytest_assert(syseeprom_info_dict is not None,
                      "Failed to retrieve system EEPROM data")
        pytest_assert(isinstance(syseeprom_info_dict, dict),
                      "System EEPROM data is not in the expected format")

        # case sensitive,so make all characters lowercase
        syseeprom_type_codes_list = [
            key.lower() for key in syseeprom_info_dict.keys()
        ]
        VALID_ONIE_TLVINFO_TYPE_CODES_LIST = [
            key.lower() for key in VALID_ONIE_TLVINFO_TYPE_CODES_LIST
        ]
        MINIMUM_REQUIRED_TYPE_CODES_LIST = [
            key.lower() for key in MINIMUM_REQUIRED_TYPE_CODES_LIST
        ]

        # Ensure that all keys in the resulting dictionary are valid ONIE TlvInfo type codes
        pytest_assert(
            set(syseeprom_type_codes_list) <=
            set(VALID_ONIE_TLVINFO_TYPE_CODES_LIST),
            "Invalid TlvInfo type code found")

        # Ensure that we were able to obtain the minimum required type codes
        pytest_assert(
            set(MINIMUM_REQUIRED_TYPE_CODES_LIST) <=
            set(syseeprom_type_codes_list),
            "Minimum required TlvInfo type codes not provided")

        # Ensure the base MAC address is sane
        base_mac = syseeprom_info_dict[ONIE_TLVINFO_TYPE_CODE_BASE_MAC_ADDR]
        pytest_assert(base_mac is not None,
                      "Failed to retrieve base MAC address")
        pytest_assert(re.match(REGEX_MAC_ADDRESS, base_mac),
                      "Base MAC address appears to be incorrect")

        # Ensure the serial number is sane
        serial = syseeprom_info_dict[ONIE_TLVINFO_TYPE_CODE_SERIAL_NUMBER]
        pytest_assert(serial is not None, "Failed to retrieve serial number")
        pytest_assert(re.match(REGEX_SERIAL_NUMBER, serial),
                      "Serial number appears to be incorrect")
        host_vars = get_host_visible_vars(self.inv_files, duthost.hostname)
        expected_syseeprom_info_dict = host_vars.get('syseeprom_info')
        # Ignore case of keys in syseeprom_info
        expected_syseeprom_info_dict = {
            k.lower(): v
            for k, v in expected_syseeprom_info_dict.items()
        }

        for field in expected_syseeprom_info_dict:
            pytest_assert(
                field in syseeprom_info_dict,
                "Expected field '{}' not present in syseeprom on '{}'".format(
                    field, duthost.hostname))
            pytest_assert(
                syseeprom_info_dict[field] ==
                expected_syseeprom_info_dict[field],
                "System EEPROM info is incorrect - for '{}', rcvd '{}', expected '{}' on '{}'"
                .format(field, syseeprom_info_dict[field],
                        expected_syseeprom_info_dict[field], duthost.hostname))