Merge "Change PTL informatin in INFO"
[bottlenecks.git] / testsuites / vstf / vstf_scripts / vstf / controller / fabricant.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.rpc_frame_work import constant as const
11 import vstf.common.constants as cst
12
13
14 class Fabricant(object):
15
16     def __init__(self, target, conn):
17         self.conn = conn
18         self.target = target
19
20         self.all_commands = self.declare_commands
21         self.instance_commands()
22
23     @property
24     def declare_commands(self):
25         driver = {
26             "install_drivers",
27             "clean_drivers",
28             "autoneg_on",
29             "autoneg_off",
30             "autoneg_query"}
31
32         builder = {"build_env", "clean_env"}
33
34         cpu = {"affctl_load", "affctl_list", "run_cpuwatch", "kill_cpuwatch"}
35
36         perf = {"perf_run", "run_vnstat", "kill_vnstat", "force_clean"}
37
38         device_mgr = {
39             "get_device_detail",
40             "list_nic_devices",
41             "get_device_verbose"}
42
43         netns = {"clean_all_namespace", "config_dev", "recover_dev", "ping"}
44
45         collect = {"collect_host_info"}
46
47         cmdline = {"execute"}
48
49         spirent = {
50             "send_packet",
51             "stop_flow",
52             "mac_learning",
53             "run_rfc2544suite",
54             "run_rfc2544_throughput",
55             "run_rfc2544_frameloss",
56             "run_rfc2544_latency"}
57
58         equalizer = {
59             "get_numa_core",
60             "get_nic_numa",
61             "get_nic_interrupt_proc",
62             "get_vm_info",
63             "bind_cpu",
64             "catch_thread_info"}
65
66         return driver | cpu | builder | perf | device_mgr | netns | cmdline | collect | spirent | equalizer
67
68     def instance_commands(self):
69         for command in self.all_commands:
70             setattr(self, command, self.__transfer_msg(command))
71
72     def __transfer_msg(self, command):
73         def infunc(timeout=cst.TIMEOUT, **kwargs):
74             msg = self.conn.make_msg(command, **kwargs)
75             if self.target:
76                 return self.conn.call(msg, self.target, timeout)
77             return None
78
79         infunc.__name__ = command
80         return infunc