def dutQosConfig(self, duthost, ingressLosslessProfile, ingressLossyProfile, egressLosslessProfile, egressLossyProfile): """ Prepares DUT host QoS configuration Args: duthost (AnsibleHost): Device Under Test (DUT) ingressLosslessProfile (Fxiture): ingressLosslessProfile fixture is required to run prior to collecting QoS configuration Returns: QoSConfig (dict): Map containing DUT host QoS configuration """ mgFacts = duthost.minigraph_facts( host=duthost.hostname)['ansible_facts'] assert "minigraph_hwsku" in mgFacts, "Could not find DUT SKU" profileName = ingressLosslessProfile["profileName"] m = re.search("^BUFFER_PROFILE\|pg_lossless_(.*)_profile$", profileName) assert m.group(1), "Cannot find port speed/cable length" portSpeedCableLength = m.group(1) qosConfigs = {} with open(r"qos/files/qos.yml") as file: qosConfigs = yaml.load(file, Loader=yaml.FullLoader) vendor = duthost.facts["asic_type"] hostvars = duthost.host.options['variable_manager']._hostvars[ duthost.hostname] dutAsic = None for asic in self.SUPPORTED_ASIC_LIST: vendorAsic = "{0}_{1}_hwskus".format(vendor, asic) if vendorAsic in hostvars.keys( ) and mgFacts["minigraph_hwsku"] in hostvars[vendorAsic]: dutAsic = asic break assert dutAsic, "Cannot identify DUT ASIC type" if isMellanoxDevice(duthost): current_file_dir = os.path.dirname(os.path.realpath(__file__)) sub_folder_dir = os.path.join(current_file_dir, "files/mellanox/") if sub_folder_dir not in sys.path: sys.path.append(sub_folder_dir) import qos_param_generator qpm = qos_param_generator.QosParamMellanox( qosConfigs['qos_params']['mellanox'], dutAsic, portSpeedCableLength, ingressLosslessProfile, ingressLossyProfile, egressLosslessProfile, egressLossyProfile) qosParams = qpm.run() else: qosParams = qosConfigs['qos_params'][dutAsic] yield { "param": qosParams, "portSpeedCableLength": portSpeedCableLength, }
def dutQosConfig(self, duthosts, enum_frontend_asic_index, rand_one_dut_hostname, dutConfig, ingressLosslessProfile, ingressLossyProfile, egressLosslessProfile, egressLossyProfile, sharedHeadroomPoolSize, tbinfo): """ Prepares DUT host QoS configuration Args: duthost (AnsibleHost): Device Under Test (DUT) ingressLosslessProfile (Fxiture): ingressLosslessProfile fixture is required to run prior to collecting QoS configuration Returns: QoSConfig (dict): Map containing DUT host QoS configuration """ duthost = duthosts[rand_one_dut_hostname] dut_asic = duthost.asic_instance(enum_frontend_asic_index) mgFacts = duthost.get_extended_minigraph_facts(tbinfo) pytest_assert("minigraph_hwsku" in mgFacts, "Could not find DUT SKU") profileName = ingressLosslessProfile["profileName"] if self.isBufferInApplDb(dut_asic): profile_pattern = "^BUFFER_PROFILE_TABLE\:pg_lossless_(.*)_profile$" else: profile_pattern = "^BUFFER_PROFILE\|pg_lossless_(.*)_profile" m = re.search(profile_pattern, profileName) pytest_assert(m.group(1), "Cannot find port speed/cable length") portSpeedCableLength = m.group(1) qosConfigs = {} with open(r"qos/files/qos.yml") as file: qosConfigs = yaml.load(file, Loader=yaml.FullLoader) vendor = duthost.facts["asic_type"] hostvars = duthost.host.options['variable_manager']._hostvars[ duthost.hostname] dutAsic = None for asic in self.SUPPORTED_ASIC_LIST: vendorAsic = "{0}_{1}_hwskus".format(vendor, asic) if vendorAsic in hostvars.keys( ) and mgFacts["minigraph_hwsku"] in hostvars[vendorAsic]: dutAsic = asic break pytest_assert(dutAsic, "Cannot identify DUT ASIC type") if isMellanoxDevice(duthost): current_file_dir = os.path.dirname(os.path.realpath(__file__)) sub_folder_dir = os.path.join(current_file_dir, "files/mellanox/") if sub_folder_dir not in sys.path: sys.path.append(sub_folder_dir) import qos_param_generator qpm = qos_param_generator.QosParamMellanox( qosConfigs['qos_params']['mellanox'], dutAsic, portSpeedCableLength, dutConfig, ingressLosslessProfile, ingressLossyProfile, egressLosslessProfile, egressLossyProfile, sharedHeadroomPoolSize) qosParams = qpm.run() else: qosParams = qosConfigs['qos_params'][dutAsic] yield { "param": qosParams, "portSpeedCableLength": portSpeedCableLength, }