예제 #1
0
    def restore_interfaces_linux(self):
        """
        Restore Linux interfaces.
        """
        for port in self.ports_info:
            pci_bus = port['pci']
            pci_id = port['type']
            # get device driver
            driver = settings.get_nic_driver(pci_id)
            if driver is not None:
                # unbind device driver
                addr_array = pci_bus.split(':')
                domain_id = addr_array[0]
                bus_id = addr_array[1]
                devfun_id = addr_array[2]

                port = GetNicObj(self, domain_id, bus_id, devfun_id)

                self.send_expect(
                    'echo %s > /sys/bus/pci/devices/%s\:%s\:%s/driver/unbind' %
                    (pci_bus, domain_id, bus_id, devfun_id), '# ')
                # bind to linux kernel driver
                self.send_expect('modprobe %s' % driver, '# ')
                self.send_expect(
                    'echo %s > /sys/bus/pci/drivers/%s/bind' %
                    (pci_bus, driver), '# ')
                itf = port.get_interface_name()
                self.send_expect("ifconfig %s up" % itf, "# ")
            else:
                self.logger.info("NOT FOUND DRIVER FOR PORT (%s|%s)!!!" %
                                 (pci_bus, pci_id))
예제 #2
0
 def __init__(self, crb, domain_id, bus_id, devfun_id):
     if not isinstance(crb, Crb):
         raise Exception("  Please input the instance of Crb!!!")
     self.crb = crb
     self.domain_id = domain_id
     self.bus_id = bus_id
     self.devfun_id = devfun_id
     self.pci = domain_id + ':' + bus_id + ':' + devfun_id
     self.pci_id = get_pci_id(crb, domain_id, bus_id, devfun_id)
     self.default_driver = settings.get_nic_driver(self.pci_id)
     self.intf_name = 'N/A'
     self.intf2_name = None
     self.get_interface_name()
예제 #3
0
 def stop_ports(self):
     """
     After all execution done, some special nic like fm10k should be stop
     """
     for (pci_bus, pci_id) in self.pci_devices_info:
         driver = settings.get_nic_driver(pci_id)
         if driver is not None:
             # unbind device driver
             addr_array = pci_bus.split(':')
             domain_id = addr_array[0]
             bus_id = addr_array[1]
             devfun_id = addr_array[2]
             port = GetNicObj(self, domain_id, bus_id, devfun_id)
             port.stop()
예제 #4
0
    def __init__(self, crb_object, domain_id, bus_id, devfun_id):
        if not isinstance(crb_object, crb.Crb):
            raise Exception("  Please input the instance of Crb!!!")
        self.crb = crb_object
        self.domain_id = domain_id
        self.bus_id = bus_id
        self.devfun_id = devfun_id
        self.pci = domain_id + ':' + bus_id + ':' + devfun_id
        self.pci_id = get_pci_id(self.crb, domain_id, bus_id, devfun_id)
        self.default_driver = settings.get_nic_driver(self.pci_id)

        if self.nic_is_pf():
            self.default_vf_driver = ''

        self.intf_name = 'N/A'
        self.intf2_name = None
        self.get_interface_name()
        self.socket = self.get_nic_socket()
예제 #5
0
 def restore_interfaces_domu(self):
     """
     Restore Linux interfaces.
     """
     for port in self.ports_info:
         pci_bus = port['pci']
         pci_id = port['type']
         driver = settings.get_nic_driver(pci_id)
         if driver is not None:
             addr_array = pci_bus.split(':')
             domain_id = addr_array[0]
             bus_id = addr_array[1]
             devfun_id = addr_array[2]
             port = GetNicObj(self, domain_id, bus_id, devfun_id)
             itf = port.get_interface_name()
             self.send_expect("ifconfig %s up" % itf, "# ")
             time.sleep(30)
             print self.send_expect("ip link ls %s" % itf, "# ")
         else:
             self.logger.info(
                 "NOT FOUND DRIVER FOR PORT (%s|%s)!!!" % (pci_bus, pci_id))