def create(devices, setup_params, refs, duts, monitors): mons = [] mhosts = [] hosts = duts + refs # choose only standalone monitors for monitor in monitors: if monitor not in hosts and monitor != "all": mons.append(monitor) for mon in mons: dev = config.get_device(devices, mon) if dev is None: continue host = Host(host=dev['hostname'], ifname=dev['ifname'], port=dev['port'], name=dev['name']) try: host.execute(["iw", "reg", "set", setup_params['country']]) rutils.setup_hw_host(host, setup_params, True) except: pass mhosts.append(host) return mhosts
def check_device(devices, setup_params, dev_name, monitor=False): host = rutils.get_host(devices, dev_name) # simple check if authorized_keys works correctly status, buf = host.execute(["id"]) if status != 0: raise Exception(dev_name + " - ssh communication FAILED: " + buf) rutils.setup_hw_host(host, setup_params) ifaces = re.split('; | |, ', host.ifname) # check interfaces (multi for monitor) for iface in ifaces: status, buf = host.execute(["ifconfig", iface]) if status != 0: raise Exception(dev_name + " ifconfig " + iface + " failed: " + buf) # monitor doesn't need wpa_supplicant/hostapd ... if monitor == True: return status, buf = host.execute(["ls", "-l", setup_params['wpa_supplicant']]) if status != 0: raise Exception(dev_name + " - wpa_supplicant: " + buf) status, buf = host.execute(["ls", "-l", setup_params['hostapd']]) if status != 0: raise Exception(dev_name + " - hostapd: " + buf) status, buf = host.execute(["which", setup_params['iperf']]) if status != 0: raise Exception(dev_name + " - iperf: " + buf) status, buf = host.execute(["which", "tshark"]) if status != 0: logger.debug(dev_name + " - tshark: " + buf)
def show_devices(devices, setup_params): """Show/check available devices""" print("Devices:") for device in devices: host = rutils.get_host(devices, device['name']) # simple check if authorized_keys works correctly status, buf = host.execute(["id"]) if status != 0: print("[" + host.name + "] - ssh communication: FAILED") continue else: print("[" + host.name + "] - ssh communication: OK") # check setup_hw works correctly rutils.setup_hw_host(host, setup_params) # show uname status, buf = host.execute(["uname", "-s", "-n", "-r", "-m", "-o"]) print("\t" + buf) # show ifconfig ifaces = re.split('; | |, ', host.ifname) for iface in ifaces: status, buf = host.execute(["ifconfig", iface]) if status != 0: print("\t" + iface + " failed\n") continue lines = buf.splitlines() for line in lines: print("\t" + line) # check hostapd, wpa_supplicant, iperf exist status, buf = host.execute([setup_params['wpa_supplicant'], "-v"]) if status != 0: print("\t" + setup_params['wpa_supplicant'] + " not find\n") continue lines = buf.splitlines() for line in lines: print("\t" + line) print("") status, buf = host.execute([setup_params['hostapd'], "-v"]) if status != 1: print("\t" + setup_params['hostapd'] + " not find\n") continue lines = buf.splitlines() for line in lines: print("\t" + line) print("") status, buf = host.execute([setup_params['iperf'], "-v"]) if status != 0 and status != 1: print("\t" + setup_params['iperf'] + " not find\n") continue lines = buf.splitlines() for line in lines: print("\t" + line) print("")
def create(devices, setup_params, refs, duts, monitors): mons = [] mhosts = [] hosts = duts + refs # choose only standalone monitors for monitor in monitors: if monitor not in hosts and monitor != "all": mons.append(monitor) for mon in mons: word = mon.split(":") dev = config.get_device(devices, word[0]) if dev is None: continue host = Host(host=dev['hostname'], ifname=dev['ifname'], port=dev['port'], name=dev['name']) for iface_param in word[1:]: params = iface_param.split(",") if len(params) > 3: monitor_param = { "freq": rutils.c2f(params[0]), "bw": params[1], "center_freq1": rutils.c2f(params[2]), "center_freq2": rutils.c2f(params[3]) } host.monitor_params.append(monitor_param) try: host.execute(["iw", "reg", "set", setup_params['country']]) rutils.setup_hw_host(host, setup_params, True) except: pass mhosts.append(host) return mhosts