Merge "Change PTL informatin in INFO"
[bottlenecks.git] / testsuites / vstf / vstf_scripts / vstf / agent / env / driver_plugins / origin_driver.py
1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 from vstf.agent.env.driver_plugins import model
11 from vstf.common.utils import check_and_rmmod, check_call
12
13
14 class OriginDriverPlugin(model.DriverPlugin):
15     """
16     implement for operating linux origin driver modules.
17     """
18
19     def __init__(self):
20         """
21         list all origin drivers in self.origin_drivers
22         """
23         self.origin_drivers = ['ixgbe', 'bnx2x', 'i40e', 'be2net', 'vhost_net']
24
25     def clean(self):
26         """clean drivers list in self.origin_drivers.
27
28         """
29         for mod in self.origin_drivers:
30             check_and_rmmod(mod)
31
32         check_and_rmmod('tun')
33         return True
34
35     def load(self, drivers):
36         """insmod drivers
37
38         :param list    drivers:list of drivers link ['ixgbe','vhost_net']
39         """
40         # load implicit 'tun' module dependency for vhost_net
41         if 'vhost_net' in drivers:
42             check_call("modprobe tun", shell=True)
43
44         for drv in drivers:
45             check_call("modprobe %s" % drv, shell=True)
46
47         return True
48
49     def get_supported_drivers(self):
50         return self.origin_drivers