blob: 1ac362ead3f36632d5debd6fa690ed2d9d01a981 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001# Environment configuration
2# Copyright (c) 2016, Tieto Corporation
3#
4# This software may be distributed under the terms of the BSD license.
5# See README for more details.
6
7#
8# Currently static definition, in the future this could be a config file,
9# or even common database with host management.
10#
11
12import logging
13logger = logging.getLogger()
14
15#
16# You can put your settings in cfg.py file with setup_params, devices
17# definitions in the format as below. In other case HWSIM cfg will be used.
18#
19setup_params = {"setup_hw" : "./tests/setup_hw.sh",
20 "hostapd" : "./tests/hostapd-rt",
21 "wpa_supplicant" : "./tests/wpa_supplicant-rt",
22 "iperf" : "iperf",
23 "wlantest" : "./tests/wlantest",
24 "wlantest_cli" : "./tests/wlantest_cli",
25 "country" : "US",
26 "log_dir" : "/tmp/",
27 "ipv4_test_net" : "192.168.12.0",
28 "trace_start" : "./tests/trace_start.sh",
29 "trace_stop" : "./tests/trace_stop.sh",
30 "perf_start" : "./tests/perf_start.sh",
31 "perf_stop" : "./tests/perf_stop.sh"}
32
33#
34#devices = [{"hostname": "192.168.254.58", "ifname" : "wlan0", "port": "9877", "name" : "t2-ath9k", "flags" : "AP_HT40 STA_HT40"},
35# {"hostname": "192.168.254.58", "ifname" : "wlan1", "port": "9877", "name" : "t2-ath10k", "flags" : "AP_VHT80"},
36# {"hostname": "192.168.254.58", "ifname" : "wlan3", "port": "9877", "name" : "t2-intel7260", "flags" : "STA_VHT80"},
37# {"hostname": "192.168.254.55", "ifname" : "wlan0, wlan1, wlan2", "port": "", "name" : "t3-monitor"},
38# {"hostname": "192.168.254.50", "ifname" : "wlan0", "port": "9877", "name" : "t1-ath9k"},
39# {"hostname": "192.168.254.50", "ifname" : "wlan1", "port": "9877", "name" : "t1-ath10k"}]
40
41#
42# HWSIM - ifaces available after modprobe mac80211_hwsim
43#
44devices = [{"hostname": "localhost", "ifname": "wlan0", "port": "9868", "name": "hwsim0", "flags": "AP_VHT80 STA_VHT80"},
45 {"hostname": "localhost", "ifname": "wlan1", "port": "9878", "name": "hwsim1", "flags": "AP_VHT80 STA_VHT80"},
46 {"hostname": "localhost", "ifname": "wlan2", "port": "9888", "name": "hwsim2", "flags": "AP_VHT80 STA_VHT80"},
47 {"hostname": "localhost", "ifname": "wlan3", "port": "9898", "name": "hwsim3", "flags": "AP_VHT80 STA_VHT80"},
48 {"hostname": "localhost", "ifname": "wlan4", "port": "9908", "name": "hwsim4", "flags": "AP_VHT80 STA_VHT80"}]
49
50
51def get_setup_params(filename="cfg.py"):
52 try:
53 mod = __import__(filename.split(".")[0])
54 return mod.setup_params
55 except:
56 logger.debug("__import__(" + filename + ") failed, using static settings")
57 pass
58 return setup_params
59
60def get_devices(filename="cfg.py"):
61 try:
62 mod = __import__(filename.split(".")[0])
63 return mod.devices
64 except:
65 logger.debug("__import__(" + filename + ") failed, using static settings")
66 pass
67 return devices
68
69def get_device(devices, name=None, flags=None, lock=False):
70 if name is None and flags is None:
71 raise Exception("Failed to get device")
72 word = name.split(":")
73 name = word[0]
74 for device in devices:
75 if device['name'] == name:
76 return device
77 for device in devices:
78 try:
79 device_flags = device['flags']
80 if device_flags.find(flags) != -1:
81 return device
82 except:
83 pass
84 raise Exception("Failed to get device " + name)
85
86def put_device(devices, name):
87 pass