1 ##############################################################################
2 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
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 ##############################################################################
10 from vstf.rpc_frame_work import constant as const
11 import vstf.common.constants as cst
14 class Fabricant(object):
16 def __init__(self, target, conn):
20 self.all_commands = self.declare_commands
21 self.instance_commands()
24 def declare_commands(self):
32 builder = {"build_env", "clean_env"}
34 cpu = {"affctl_load", "affctl_list", "run_cpuwatch", "kill_cpuwatch"}
36 perf = {"perf_run", "run_vnstat", "kill_vnstat", "force_clean"}
43 netns = {"clean_all_namespace", "config_dev", "recover_dev", "ping"}
45 collect = {"collect_host_info"}
54 "run_rfc2544_throughput",
55 "run_rfc2544_frameloss",
56 "run_rfc2544_latency"}
61 "get_nic_interrupt_proc",
66 return driver | cpu | builder | perf | device_mgr | netns | cmdline | collect | spirent | equalizer
68 def instance_commands(self):
69 for command in self.all_commands:
70 setattr(self, command, self.__transfer_msg(command))
72 def __transfer_msg(self, command):
73 def infunc(timeout=cst.TIMEOUT, **kwargs):
74 msg = self.conn.make_msg(command, **kwargs)
76 return self.conn.call(msg, self.target, timeout)
79 infunc.__name__ = command