850d78517e8b19fda2ac84e8346df88e156360ce
[bottlenecks.git] / vstf / vstf / agent / env / driver_plugins / origin_driver.py
1 """
2 Created on 2015-10-12
3
4 @author: y00228926
5 """
6 from vstf.agent.env.driver_plugins import model
7 from vstf.common.utils import check_and_rmmod, check_call
8
9
10 class OriginDriverPlugin(model.DriverPlugin):
11     """
12     implement for operating linux origin driver modules.
13     """
14
15     def __init__(self):
16         """
17         list all origin drivers in self.origin_drivers
18         """
19         self.origin_drivers = ['ixgbe', 'bnx2x', 'i40e', 'be2net', 'vhost_net']
20
21     def clean(self):
22         """clean drivers list in self.origin_drivers.
23         
24         """
25         for mod in self.origin_drivers:
26             check_and_rmmod(mod)
27
28         check_and_rmmod('tun')
29         return True
30
31     def load(self, drivers):
32         """insmod drivers
33         
34         :param list    drivers:list of drivers link ['ixgbe','vhost_net']
35         """
36         # load implicit 'tun' module dependency for vhost_net
37         if 'vhost_net' in drivers:
38             check_call("modprobe tun", shell=True)
39
40         for drv in drivers:
41             check_call("modprobe %s" % drv, shell=True)
42
43         return True
44
45     def get_supported_drivers(self):
46         return self.origin_drivers