tests: Pass apdev param to HostapdGlobal()
Pass apdev param to HostapdGlobal() to support operating with a remote test host. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
This commit is contained in:
parent
9cd6f4c015
commit
625bf74436
1 changed files with 13 additions and 11 deletions
|
@ -21,7 +21,13 @@ def mac2tuple(mac):
|
||||||
return struct.unpack('6B', binascii.unhexlify(mac.replace(':','')))
|
return struct.unpack('6B', binascii.unhexlify(mac.replace(':','')))
|
||||||
|
|
||||||
class HostapdGlobal:
|
class HostapdGlobal:
|
||||||
def __init__(self, hostname=None, port=8878):
|
def __init__(self, apdev=None):
|
||||||
|
try:
|
||||||
|
hostname = apdev['hostname']
|
||||||
|
port = apdev['port']
|
||||||
|
except:
|
||||||
|
hostname = None
|
||||||
|
port = 8878
|
||||||
self.host = remotehost.Host(hostname)
|
self.host = remotehost.Host(hostname)
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
self.port = port
|
self.port = port
|
||||||
|
@ -356,7 +362,7 @@ def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30):
|
||||||
logger.info("Starting AP " + ifname + " (old add_ap argument type)")
|
logger.info("Starting AP " + ifname + " (old add_ap argument type)")
|
||||||
hostname = None
|
hostname = None
|
||||||
port = 8878
|
port = 8878
|
||||||
hapd_global = HostapdGlobal(hostname=hostname, port=port)
|
hapd_global = HostapdGlobal(apdev)
|
||||||
hapd_global.remove(ifname)
|
hapd_global.remove(ifname)
|
||||||
hapd_global.add(ifname)
|
hapd_global.add(ifname)
|
||||||
port = hapd_global.get_ctrl_iface_port(ifname)
|
port = hapd_global.get_ctrl_iface_port(ifname)
|
||||||
|
@ -400,7 +406,7 @@ def add_bss(apdev, ifname, confname, ignore_error=False):
|
||||||
logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
|
logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
|
||||||
hostname = None
|
hostname = None
|
||||||
port = 8878
|
port = 8878
|
||||||
hapd_global = HostapdGlobal(hostname=hostname, port=port)
|
hapd_global = HostapdGlobal(apdev)
|
||||||
hapd_global.add_bss(phy, confname, ignore_error)
|
hapd_global.add_bss(phy, confname, ignore_error)
|
||||||
port = hapd_global.get_ctrl_iface_port(ifname)
|
port = hapd_global.get_ctrl_iface_port(ifname)
|
||||||
hapd = Hostapd(ifname, hostname=hostname, port=port)
|
hapd = Hostapd(ifname, hostname=hostname, port=port)
|
||||||
|
@ -417,7 +423,7 @@ def add_iface(apdev, confname):
|
||||||
logger.info("Starting interface " + ifname)
|
logger.info("Starting interface " + ifname)
|
||||||
hostname = None
|
hostname = None
|
||||||
port = 8878
|
port = 8878
|
||||||
hapd_global = HostapdGlobal(hostname=hostname, port=port)
|
hapd_global = HostapdGlobal(apdev)
|
||||||
hapd_global.add_iface(ifname, confname)
|
hapd_global.add_iface(ifname, confname)
|
||||||
port = hapd_global.get_ctrl_iface_port(ifname)
|
port = hapd_global.get_ctrl_iface_port(ifname)
|
||||||
hapd = Hostapd(ifname, hostname=hostname, port=port)
|
hapd = Hostapd(ifname, hostname=hostname, port=port)
|
||||||
|
@ -433,21 +439,17 @@ def remove_bss(apdev, ifname=None):
|
||||||
logger.info("Removing BSS " + hostname + "/" + port + " " + ifname)
|
logger.info("Removing BSS " + hostname + "/" + port + " " + ifname)
|
||||||
except:
|
except:
|
||||||
logger.info("Removing BSS " + ifname)
|
logger.info("Removing BSS " + ifname)
|
||||||
hostname = None
|
hapd_global = HostapdGlobal(apdev)
|
||||||
port = 8878
|
|
||||||
hapd_global = HostapdGlobal(hostname=hostname, port=port)
|
|
||||||
hapd_global.remove(ifname)
|
hapd_global.remove(ifname)
|
||||||
|
|
||||||
def terminate(apdev):
|
def terminate(apdev):
|
||||||
try:
|
try:
|
||||||
hostname = apdev['hostname']
|
hostname = apdev['hostname']
|
||||||
port = apdev['port']
|
port = apdev['port']
|
||||||
logger.info("Terminating hostapd " + apdev['hostname'] + "/" + apdev['port'])
|
logger.info("Terminating hostapd " + hostname + "/" + port)
|
||||||
except:
|
except:
|
||||||
hostname = None
|
|
||||||
port = 8878
|
|
||||||
logger.info("Terminating hostapd")
|
logger.info("Terminating hostapd")
|
||||||
hapd_global = HostapdGlobal(hostname=hostname, port=port)
|
hapd_global = HostapdGlobal(apdev)
|
||||||
hapd_global.terminate()
|
hapd_global.terminate()
|
||||||
|
|
||||||
def wpa2_params(ssid=None, passphrase=None):
|
def wpa2_params(ssid=None, passphrase=None):
|
||||||
|
|
Loading…
Reference in a new issue