tests: Allow to use remote wpa_cli in WpaSupplicant class
Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
This commit is contained in:
parent
d3f340c869
commit
871bfdcdf6
1 changed files with 23 additions and 5 deletions
|
@ -13,13 +13,14 @@ import struct
|
||||||
import wpaspy
|
import wpaspy
|
||||||
import remotehost
|
import remotehost
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from remotectrl import RemoteCtrl
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
wpas_ctrl = '/var/run/wpa_supplicant'
|
wpas_ctrl = '/var/run/wpa_supplicant'
|
||||||
|
|
||||||
class WpaSupplicant:
|
class WpaSupplicant:
|
||||||
def __init__(self, ifname=None, global_iface=None, hostname=None,
|
def __init__(self, ifname=None, global_iface=None, hostname=None,
|
||||||
port=9877, global_port=9878, monitor=True):
|
port=9877, global_port=9878, monitor=True, remote_cli=False):
|
||||||
self.monitor = monitor
|
self.monitor = monitor
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
self.group_ifname = None
|
self.group_ifname = None
|
||||||
|
@ -31,6 +32,7 @@ class WpaSupplicant:
|
||||||
self.ifname = None
|
self.ifname = None
|
||||||
self.host = remotehost.Host(hostname, ifname)
|
self.host = remotehost.Host(hostname, ifname)
|
||||||
self._group_dbg = None
|
self._group_dbg = None
|
||||||
|
self.remote_cli = remote_cli
|
||||||
if ifname:
|
if ifname:
|
||||||
self.set_ifname(ifname, hostname, port)
|
self.set_ifname(ifname, hostname, port)
|
||||||
res = self.get_driver_status()
|
res = self.get_driver_status()
|
||||||
|
@ -41,7 +43,14 @@ class WpaSupplicant:
|
||||||
|
|
||||||
self.global_iface = global_iface
|
self.global_iface = global_iface
|
||||||
if global_iface:
|
if global_iface:
|
||||||
if hostname != None:
|
if hostname != None and remote_cli:
|
||||||
|
self.global_ctrl = RemoteCtrl(global_iface, global_port,
|
||||||
|
hostname=hostname)
|
||||||
|
if self.monitor:
|
||||||
|
self.global_mon = RemoteCtrl(global_iface, global_port,
|
||||||
|
hostname=hostname)
|
||||||
|
self.global_dbg = hostname + "/global"
|
||||||
|
elif hostname != None:
|
||||||
self.global_ctrl = wpaspy.Ctrl(hostname, global_port)
|
self.global_ctrl = wpaspy.Ctrl(hostname, global_port)
|
||||||
if self.monitor:
|
if self.monitor:
|
||||||
self.global_mon = wpaspy.Ctrl(hostname, global_port)
|
self.global_mon = wpaspy.Ctrl(hostname, global_port)
|
||||||
|
@ -164,6 +173,13 @@ class WpaSupplicant:
|
||||||
self.remove_ifname()
|
self.remove_ifname()
|
||||||
self.ifname = ifname
|
self.ifname = ifname
|
||||||
if hostname != None:
|
if hostname != None:
|
||||||
|
if self.remote_cli:
|
||||||
|
self.ctrl = RemoteCtrl(wpas_ctrl, port, hostname=hostname,
|
||||||
|
ifname=ifname)
|
||||||
|
if self.monitor:
|
||||||
|
self.mon = RemoteCtrl(wpas_ctrl, port, hostname=hostname,
|
||||||
|
ifname=ifname)
|
||||||
|
else:
|
||||||
self.ctrl = wpaspy.Ctrl(hostname, port)
|
self.ctrl = wpaspy.Ctrl(hostname, port)
|
||||||
if self.monitor:
|
if self.monitor:
|
||||||
self.mon = wpaspy.Ctrl(hostname, port)
|
self.mon = wpaspy.Ctrl(hostname, port)
|
||||||
|
@ -185,6 +201,8 @@ class WpaSupplicant:
|
||||||
def get_ctrl_iface_port(self, ifname):
|
def get_ctrl_iface_port(self, ifname):
|
||||||
if self.hostname is None:
|
if self.hostname is None:
|
||||||
return None
|
return None
|
||||||
|
if self.remote_cli:
|
||||||
|
return None
|
||||||
|
|
||||||
res = self.global_request("INTERFACES ctrl")
|
res = self.global_request("INTERFACES ctrl")
|
||||||
lines = res.splitlines()
|
lines = res.splitlines()
|
||||||
|
|
Loading…
Reference in a new issue