import time
from remotehost import Host
import config
+import rutils
import re
import traceback
import logging
try:
host.execute(["iw", "reg", "set", setup_params['country']])
- setup_hw = setup_params['setup_hw']
- ifaces = re.split('; | |, ', host.ifname)
- for iface in ifaces:
- host.execute(setup_hw + " -I " + iface + " -R 1")
+ rutils.setup_hw_host(host, setup_params, True)
except:
pass
mhosts.append(host)
# This software may be distributed under the terms of the BSD license.
# See README for more details.
+import re
import time
from remotehost import Host
import hostapd
return host
# run setup_hw - hw specyfic
-def setup_hw(hosts, setup_params):
- for host in hosts:
- setup_hw_host(host, setup_params)
-
-def setup_hw_host(host, setup_params):
+def setup_hw_host_iface(host, iface, setup_params, force_restart=False):
try:
setup_hw = setup_params['setup_hw']
restart = ""
try:
if setup_params['restart_device'] == True:
- restart = " -R "
+ restart = "-R"
except:
pass
- host.execute([setup_hw, "-I", host.ifname, restart])
+
+ if force_restart:
+ restart = "-R"
+
+ host.execute([setup_hw, "-I", iface, restart])
except:
pass
+def setup_hw_host(host, setup_params, force_restart=False):
+ ifaces = re.split('; | |, ', host.ifname)
+ for iface in ifaces:
+ setup_hw_host_iface(host, iface, setup_params, force_restart)
+
+def setup_hw(hosts, setup_params, force_restart=False):
+ for host in hosts:
+ setup_hw_host(host, setup_params, force_restart)
+
# get traces - hw specific
def trace_start(hosts, setup_params):
for host in hosts:
else:
print "[" + host.name + "] - ssh communication: OK"
# check setup_hw works correctly
- try:
- setup_hw = setup_params['setup_hw']
- try:
- restart_device = setup_params['restart_device']
- except:
- restart_device = "0"
- host.execute([setup_hw, "-I", host.ifname, "-R", restart_device])
- except:
- pass
+ rutils.setup_hw_host(host, setup_params)
+
# show uname
status, buf = host.execute(["uname", "-s", "-n", "-r", "-m", "-o"])
print "\t" + buf
# show ifconfig
- status, buf = host.execute(["ifconfig", host.ifname])
- if status != 0:
- print "\t" + host.ifname + " failed\n"
- continue
- lines = buf.splitlines()
- for line in lines:
- print "\t" + line
+ 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:
if status != 0:
raise Exception(dev_name + " - ssh communication FAILED: " + buf)
- ifaces = re.split('; | |, ', host.ifname)
- # try to setup host/ifaces
- for iface in ifaces:
- try:
- setup_hw = setup_params['setup_hw']
- try:
- restart_device = setup_params['restart_device']
- except:
- restart_device = "0"
- host.execute(setup_hw + " -I " + iface + " -R " + restart_device)
- except:
- pass
+ 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])