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):
15 def __init__(self, target, conn):
19 self.all_commands = self.declare_commands
20 self.instance_commands()
23 def declare_commands(self):
24 driver = {"install_drivers", "clean_drivers", "autoneg_on", "autoneg_off", "autoneg_query"}
26 builder = {"build_env", "clean_env"}
28 cpu = {"affctl_load", "affctl_list", "run_cpuwatch", "kill_cpuwatch"}
30 perf = {"perf_run", "run_vnstat", "kill_vnstat", "force_clean"}
32 device_mgr = {"get_device_detail", "list_nic_devices", "get_device_verbose"}
34 netns = {"clean_all_namespace", "config_dev", "recover_dev", "ping"}
36 collect = {"collect_host_info"}
40 spirent = {"send_packet", "stop_flow", "mac_learning", "run_rfc2544suite", "run_rfc2544_throughput",
41 "run_rfc2544_frameloss", "run_rfc2544_latency"}
43 equalizer = {"get_numa_core", "get_nic_numa", "get_nic_interrupt_proc", "get_vm_info", "bind_cpu",
46 return driver | cpu | builder | perf | device_mgr | netns | cmdline | collect | spirent | equalizer
48 def instance_commands(self):
49 for command in self.all_commands:
50 setattr(self, command, self.__transfer_msg(command))
52 def __transfer_msg(self, command):
53 def infunc(timeout=cst.TIMEOUT, **kwargs):
54 msg = self.conn.make_msg(command, **kwargs)
56 return self.conn.call(msg, self.target, timeout)
59 infunc.__name__ = command