diff mbox

[4/6] tests: pass apdev to HostapdGlobal()

Message ID 1459328161-4298-5-git-send-email-janusz.dziedzic@tieto.com
State Changes Requested
Headers show

Commit Message

Janusz.Dziedzic@tieto.com March 30, 2016, 8:55 a.m. UTC
Pass apdev to HostapdGlobal() and handle
apdev['hostname'] for case of remote
hosts usage.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 tests/hwsim/hostapd.py | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
diff mbox

Patch

diff --git a/tests/hwsim/hostapd.py b/tests/hwsim/hostapd.py
index a4af629..db37d20 100644
--- a/tests/hwsim/hostapd.py
+++ b/tests/hwsim/hostapd.py
@@ -20,7 +20,13 @@  def mac2tuple(mac):
     return struct.unpack('6B', binascii.unhexlify(mac.replace(':','')))
 
 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.hostname = hostname
         self.port = port
@@ -349,7 +355,7 @@  def add_ap(apdev, params, wait_enabled=True, no_enable=False, timeout=30):
             logger.info("Starting AP " + ifname)
             hostname = None
             port = 8878
-        hapd_global = HostapdGlobal(hostname=hostname, port=port)
+        hapd_global = HostapdGlobal(apdev)
         hapd_global.remove(ifname)
         hapd_global.add(ifname)
         port = hapd_global.get_ctrl_iface_port(ifname)
@@ -393,7 +399,7 @@  def add_bss(phy, apdev, confname, ignore_error=False):
         logger.info("Starting BSS phy=" + phy + " ifname=" + ifname)
         hostname = None
         port = 8878
-    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global = HostapdGlobal(apdev)
     hapd_global.add_bss(phy, confname, ignore_error)
     port = hapd_global.get_ctrl_iface_port(ifname)
     hapd = Hostapd(ifname, hostname=hostname, port=port)
@@ -410,7 +416,7 @@  def add_iface(apdev, confname):
         logger.info("Starting interface " + ifname)
         hostname = None
         port = 8878
-    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global = HostapdGlobal(apdev)
     hapd_global.add_iface(ifname, confname)
     port = hapd_global.get_ctrl_iface_port(ifname)
     hapd = Hostapd(ifname, hostname=hostname, port=port)
@@ -419,20 +425,13 @@  def add_iface(apdev, confname):
 
 def remove_bss(apdev):
     ifname = apdev['ifname']
-    try:
-        hostname = apdev['hostname']
-        port = apdev['port']
-        logger.info("Removing BSS " + hostname + "/" + port + " " + ifname)
-    except:
-        logger.info("Removing BSS " + ifname)
-        hostname = None
-        port = 8878
-    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    logger.info("Removing BSS " + ifname)
+    hapd_global = HostapdGlobal(apdev)
     hapd_global.remove(ifname)
 
-def terminate(hostname=None, port=8878):
+def terminate(apdev):
     logger.info("Terminating hostapd")
-    hapd_global = HostapdGlobal(hostname=hostname, port=port)
+    hapd_global = HostapdGlobal(apdev)
     hapd_global.terminate()
 
 def wpa2_params(ssid=None, passphrase=None):