Ejemplo n.º 1
0
    def disablePacketAging(self, duthost, stopServices):
        """
            disable packet aging on DUT host

            Args:
                duthost (AnsibleHost): Device Under Test (DUT)
                stopServices (Fxiture): stopServices fixture is required to run prior to disabling packet aging

            Returns:
                None
        """
        if isMellanoxDevice(duthost):
            logger.info("Disable Mellanox packet aging")
            duthost.copy(src="qos/files/mellanox/packets_aging.py",
                         dest="/tmp")
            duthost.command("docker cp /tmp/packets_aging.py syncd:/")
            duthost.command(
                "docker exec syncd python /packets_aging.py disable")

        yield

        if isMellanoxDevice(duthost):
            logger.info("Enable Mellanox packet aging")
            duthost.command(
                "docker exec syncd python /packets_aging.py enable")
            duthost.command("docker exec syncd rm -rf /packets_aging.py")
Ejemplo n.º 2
0
 def __handleMellanoxDut(self):
     '''
     Handle Mellanox DUT reboot when upgrading from SONiC-OS-201803 to SONiC-OS-201811
     '''
     if self.newSonicImage is not None and \
        self.rebootType == 'fast-reboot' and \
        isMellanoxDevice(self.duthost):
         logger.info('Handle Mellanox platform')
         nextImage = self.duthost.shell('sonic_installer list | grep Next | cut -f2 -d " "')['stdout']
         if 'SONiC-OS-201803' in self.currentImage and 'SONiC-OS-201811' in nextImage:
             self.__runScript(['upgrade_mlnx_fw.sh'], self.duthost)
Ejemplo n.º 3
0
    def dutConfig(self, request, duthost):
        """
            Build DUT host config pertaining to QoS SAI tests

            Args:
                request (Fixture): pytest request object
                duthost (AnsibleHost): Device Under Test (DUT)

            Returns:
                dutConfig (dict): Map of DUT config containing dut interfaces, test port IDs, test port IPs, and
                    test ports
        """
        dutLagInterfaces = []
        mgFacts = duthost.minigraph_facts(
            host=duthost.hostname)["ansible_facts"]

        for _, lag in mgFacts["minigraph_portchannels"].items():
            for intf in lag["members"]:
                dutLagInterfaces.append(
                    mgFacts["minigraph_port_indices"][intf])

        testPortIds = set(mgFacts["minigraph_port_indices"][port]
                          for port in mgFacts["minigraph_ports"].keys())
        testPortIds -= set(dutLagInterfaces)
        if isMellanoxDevice(duthost):
            # The last port is used for up link from DUT switch
            testPortIds -= {len(mgFacts["minigraph_port_indices"]) - 1}
        testPortIds = sorted(testPortIds)

        # get current DUT port IPs
        dutPortIps = {}
        for portConfig in mgFacts["minigraph_interfaces"]:
            if ipaddress.ip_interface(portConfig['peer_addr']).ip.version == 4:
                portIndex = mgFacts["minigraph_port_indices"][
                    portConfig["attachto"]]
                if portIndex in testPortIds:
                    dutPortIps.update({portIndex: portConfig["peer_addr"]})

        testPortIps = self.__assignTestPortIps(mgFacts)
        # restore currently assigned IPs
        testPortIps.update(dutPortIps)

        testPorts = self.__buildTestPorts(request, testPortIds, testPortIps)
        yield {
            "dutInterfaces": {
                index: port
                for port, index in mgFacts["minigraph_port_indices"].items()
            },
            "testPortIds": testPortIds,
            "testPortIps": testPortIps,
            "testPorts": testPorts,
        }