Remove site_linux_server

This class doesn't make sense in the new world with only a router
and a DUT.  We get most of the utility of what used to be the server
by creating delegate objects which understand how to use commands in
depth. For instance, netperf is run by the NetperfRunner rather than
being split between the client and the server.  NetperfRunner now
uses proxy_object.wifi_ip without worrying whether the proxy object
is a DUT or a router.  Netperf runner also looks up netperf commands
by itself rather than depending on the proxy object.

BUG=chromium:351555
TEST=All of wifi_matfunc passes with this change.

Change-Id: I093a488b0999cb6c418cab04ff02b3cf0f33136a
Reviewed-on: https://chromium-review.googlesource.com/189625
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/server/cros/network/netperf_runner.py b/server/cros/network/netperf_runner.py
index aebcdfb..c5447d4 100644
--- a/server/cros/network/netperf_runner.py
+++ b/server/cros/network/netperf_runner.py
@@ -10,6 +10,7 @@
 import os.path
 
 from autotest_lib.client.common_lib import error
+from autotest_lib.server.cros import wifi_test_utils
 
 
 class NetperfResult(object):
@@ -476,7 +477,7 @@
         """Construct a NetperfRunner.
 
         @param client WiFiClient object.
-        @param server LinuxServer object.
+        @param server LinuxSystem object.
 
         """
         self._client_proxy = client_proxy
@@ -484,15 +485,15 @@
         if config.server_serves:
             self._server_host = server_proxy.host
             self._client_host = client_proxy.host
-            self._command_netserv = server_proxy.cmd_netserv
-            self._command_netperf = client_proxy.command_netperf
             self._target_ip = server_proxy.wifi_ip
         else:
             self._server_host = client_proxy.host
             self._client_host = server_proxy.host
-            self._command_netserv = client_proxy.command_netserv
-            self._command_netperf = server_proxy.cmd_netperf
             self._target_ip = client_proxy.wifi_ip
+        self._command_netserv = wifi_test_utils.must_be_installed(
+                self._server_host, 'netserver')
+        self._command_netperf = wifi_test_utils.must_be_installed(
+                self._client_host, 'netperf')
         self._config = config
 
 
diff --git a/server/cros/network/netperf_session.py b/server/cros/network/netperf_session.py
index c472226..732a0f3 100644
--- a/server/cros/network/netperf_session.py
+++ b/server/cros/network/netperf_session.py
@@ -34,7 +34,7 @@
         """Construct a NetperfSession.
 
         @param client_proxy: WiFiClient object.
-        @param server_proxy: LinuxServer object.
+        @param server_proxy: LinuxSystem object.
 
         """
         self._client_proxy = client_proxy
diff --git a/server/cros/network/wifi_client.py b/server/cros/network/wifi_client.py
index 91de35f..95b205f 100644
--- a/server/cros/network/wifi_client.py
+++ b/server/cros/network/wifi_client.py
@@ -9,7 +9,6 @@
 
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.common_lib.cros.network import interface
-from autotest_lib.client.common_lib.cros.network import ping_runner
 from autotest_lib.client.cros import constants
 from autotest_lib.server import autotest
 from autotest_lib.server import site_linux_system
@@ -119,24 +118,6 @@
 
 
     @property
-    def command_iw(self):
-        """@return string path to iw command."""
-        return self._command_iw
-
-
-    @property
-    def command_netperf(self):
-        """@return string path to netperf command."""
-        return self._command_netperf
-
-
-    @property
-    def command_netserv(self):
-        """@return string path to netserv command."""
-        return self._command_netserv
-
-
-    @property
     def command_ping6(self):
         """@return string path to ping6 command."""
         return self._command_ping6
@@ -201,13 +182,9 @@
         self._board = None
         self._command_ip = 'ip'
         self._command_iptables = 'iptables'
-        self._command_iw = 'iw'
-        self._command_netperf = 'netperf'
-        self._command_netserv = 'netserver'
         self._command_ping6 = 'ping6'
         self._command_wpa_cli = 'wpa_cli'
         self._machine_id = None
-        self._ping_runner = ping_runner.PingRunner(host=self.host)
         self._ping_thread = None
         self._result_dir = result_dir
         if isinstance(self.host, adb_host.ADBHost):
@@ -306,17 +283,6 @@
         super(WiFiClient, self).close()
 
 
-    def ping(self, ping_config):
-        """Ping an address from the client and return the command output.
-
-        @param ping_config parameters for the ping command.
-        @return a PingResult object.
-
-        """
-        logging.info('Pinging from the client.')
-        return self._ping_runner.ping(ping_config)
-
-
     def ping_bg(self, ping_ip, ping_args):
         """Ping an address from the client in the background.
 
diff --git a/server/cros/network/wifi_test_context_manager.py b/server/cros/network/wifi_test_context_manager.py
index fe0611b..e3237cd 100644
--- a/server/cros/network/wifi_test_context_manager.py
+++ b/server/cros/network/wifi_test_context_manager.py
@@ -12,7 +12,6 @@
 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes
 from autotest_lib.server import hosts
 from autotest_lib.server import site_linux_router
-from autotest_lib.server import site_linux_server
 from autotest_lib.server.cros import wifi_test_utils
 from autotest_lib.server.cros.network import attenuator_controller
 from autotest_lib.server.cros.network import wifi_client
@@ -89,12 +88,6 @@
         return self._router
 
 
-    @property
-    def server(self):
-        """@return server object representing the server in the test."""
-        return self._server
-
-
     def __init__(self, test_name, host, cmdline_args, debug_dir):
         """Construct a WiFiTestContextManager.
 
@@ -112,7 +105,6 @@
         self._client_proxy = wifi_client.WiFiClient(host, debug_dir)
         self._attenuator = None
         self._router = None
-        self._server = None
         self._enable_client_packet_captures = False
         self._enable_router_packet_captures = False
         self._packet_capture_snaplen = None
@@ -145,9 +137,7 @@
         @return string IPv4 address.
 
         """
-        if self.router.has_local_server():
-            return self.router.local_server_address(ap_num)
-        return self.server.wifi_ip
+        return self.router.local_server_address(ap_num)
 
 
     def get_wifi_if(self, ap_num=0):
@@ -157,18 +147,12 @@
         @return string interface name "e.g. wlan0".
 
         """
-        if self.router.has_local_server():
-            return self.router.local_servers[ap_num]['interface']
-
-        return self.server.wifi_if
+        return self.router.get_hostapd_interface(ap_num)
 
 
     def get_wifi_host(self):
         """@return host object representing a pingable machine."""
-        if self.router.has_local_server():
-            return self.router.host
-
-        return self.server.host
+        return self.router.host
 
 
     def configure(self, configuration_parameters, multi_interface=None,
@@ -220,12 +204,6 @@
         self._router = site_linux_router.LinuxRouter(
                 hosts.SSHHost(self._router_address, port=router_port),
                 self._test_name)
-        # The '_server' is a machine which hosts network services, such as
-        # OpenVPN or StrongSwan.  Note that we make a separate SSHHost instance
-        # here because both the server and the router expect to close() their
-        # host, and only one close() is permitted.
-        self._server = site_linux_server.LinuxServer(
-                hosts.SSHHost(self._router_address, port=router_port), {})
         # The attenuator host gives us the ability to attenuate particular
         # antennas on the router.  Most setups don't have this capability
         # and most tests do not require it.  We use this for RvR
@@ -243,7 +221,7 @@
         if self.CMDLINE_PACKET_CAPTURE_SNAPLEN in self._cmdline_args:
             self._packet_capture_snaplen = int(
                     self._cmdline_args[self.CMDLINE_PACKET_CAPTURE_SNAPLEN])
-        for system in (self.client, self.server, self.router):
+        for system in (self.client, self.router):
             system.sync_host_times()
 
 
@@ -251,7 +229,7 @@
         """Teardown the state used in a WiFi test."""
         logging.debug('Tearing down the test context.')
         for system in [self._attenuator, self._client_proxy,
-                       self._router, self._server]:
+                       self._router]:
             if system is not None:
                 system.close()
 
@@ -325,7 +303,7 @@
         if ping_config is None:
             ping_ip = self.client.wifi_ip
             ping_config = ping_runner.PingConfig(ping_ip)
-        self.server.ping(ping_config)
+        self.router.ping(ping_config)
 
 
     def wait_for_connection(self, ssid, freq=None, ap_num=None,
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index 3670479..afc93d8 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -68,6 +68,19 @@
         return self.host
 
 
+    @property
+    def wifi_ip(self):
+        """Simple accessor for the WiFi IP when there is only one AP.
+
+        @return string IP of WiFi interface.
+
+        """
+        if len(self.local_servers) != 1:
+            raise error.TestError('Could not pick a WiFi IP to return.')
+
+        return self.get_wifi_ip(0)
+
+
     def __init__(self, host, test_name):
         """Build a LinuxRouter.
 
diff --git a/server/site_linux_server.py b/server/site_linux_server.py
deleted file mode 100644
index d78c74e..0000000
--- a/server/site_linux_server.py
+++ /dev/null
@@ -1,368 +0,0 @@
-# Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import logging
-import re
-
-from autotest_lib.client.common_lib import error
-from autotest_lib.client.common_lib.cros.network import ping_runner
-from autotest_lib.server import site_linux_system
-from autotest_lib.server.cros import wifi_test_utils
-
-class LinuxServer(site_linux_system.LinuxSystem):
-    """
-    Linux Server: A machine which hosts network services.
-
-    """
-
-    COMMAND_PING = '/usr/bin/ping'
-    COMMAND_NETPERF = '/usr/bin/netperf'
-    COMMAND_NETSERVER = '/usr/bin/netserver'
-
-
-    def __init__(self, server, config):
-        site_linux_system.LinuxSystem.__init__(self, server, {}, "server")
-
-        self._server                     = server    # Server host.
-        self.vpn_kind                    = None
-        self.config                      = config
-        self.openvpn_config              = {}
-        self.radvd_config                = {'file':'/tmp/radvd-test.conf',
-                                            'server':'/usr/sbin/radvd'}
-
-        # Check that tools we require from WiFi test servers exist.
-        self._cmd_netperf = wifi_test_utils.must_be_installed(
-                self._server, LinuxServer.COMMAND_NETPERF)
-        self._cmd_netserver = wifi_test_utils.must_be_installed(
-                self._server, LinuxServer.COMMAND_NETSERVER)
-        # /usr/bin/ping is preferred, as it is likely to be iputils.
-        if wifi_test_utils.is_installed(self._server,
-                                        LinuxServer.COMMAND_PING):
-            self._cmd_ping = LinuxServer.COMMAND_PING
-        else:
-            self._cmd_ping = 'ping'
-
-        self._ping_bg_job = None
-        self._wifi_ip = None
-        self._wifi_if = None
-        self._ping_runner = ping_runner.PingRunner(command_ping=self.cmd_ping,
-                                                   host=self.host)
-
-
-    @property
-    def cmd_netperf(self):
-        """ @return string full path to start netperf. """
-        return self._cmd_netperf
-
-
-    @property
-    def cmd_netserv(self):
-        """ @return string full path to start netserv. """
-        return self._cmd_netserver
-
-
-    @property
-    def cmd_ping(self):
-        """ @return string full path to start ping. """
-        return self._cmd_ping
-
-
-    @property
-    def server(self):
-        """ @return Host object for this remote server. """
-        return self._server
-
-
-    @property
-    def wifi_ip(self):
-        """Returns an IP address pingable from the client DUT.
-
-        Throws an error if no interface is configured with a potentially
-        pingable IP.
-
-        @return String IP address on the WiFi subnet.
-
-        """
-        if not self._wifi_ip:
-            self.__setup_wifi_interface_info()
-        return self._wifi_ip
-
-    @property
-    def wifi_if(self):
-        """Returns an interface corresponding to self.wifi_ip.
-
-        Throws an error if no interface is configured with a potentially
-        pingable IP.
-
-        @return String interface name (e.g. 'mlan0')
-
-        """
-        if not self._wifi_if:
-            self.__setup_wifi_interface_info()
-        return self._wifi_if
-
-
-    def __setup_wifi_interface_info(self):
-        """Parse the output of 'ip -4 addr show' and extract wifi interface/ip.
-
-        This looks something like:
-
-localhost ~ # ip -4 addr show
-1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
-    inet 127.0.0.1/8 scope host lo
-3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
-    inet 172.22.50.174/24 brd 172.22.50.255 scope global eth0
-4: mlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
-    inet 192.168.0.124/24 brd 192.168.0.255 scope global mlan0
-
-        """
-        ip_output = self.host.run('%s -4 addr show' % self.cmd_ip).stdout
-        regex = re.compile('^inet ([0-9]{1,3}(\\.[0-9]{1,3}){3}).+ '
-                           'scope [a-zA-Z]+ ([a-zA-Z0-9]+)$')
-        for line in ip_output.splitlines():
-            match = re.search(regex, line.strip())
-            if not match:
-                continue
-
-            # Group 1 will be the IP address following 'inet addr:'.
-            ip = match.group(1)
-            wifi_if = match.group(3)
-            if ip.startswith('127.0.0') or ip.startswith(self.host.ip):
-                continue
-
-            logging.debug('Choosing wifi ip/if: %s/%s', ip, wifi_if)
-            self._wifi_ip = ip
-            self._wifi_if = wifi_if
-            return
-
-        raise error.TestFail('No configured interfaces.')
-
-
-    def vpn_server_config(self, params):
-        """ Configure & launch the server side of the VPN.
-
-            Parameters, in 'params':
-
-               kind  : required
-
-                       The kind of VPN which should be configured and
-                       launched.
-
-                       Valid values:
-
-                          openvpn
-                          l2tpipsec (StrongSwan PSK or certificates)
-
-               config: required
-
-                       The configuration information associated with
-                       the VPN server.
-
-                       This is a dict which contains key/value pairs
-                       representing the VPN's configuration.
-
-          The values stored in the 'config' param must all be
-          supported by the specified VPN kind.
-
-        @param params dict of site_wifitest style parameters.
-
-        """
-        self.vpn_server_kill({}) # Must be first.  Relies on self.vpn_kind.
-        self.vpn_kind = params.get('kind', None)
-
-        # Launch specified VPN server.
-        if self.vpn_kind is None:
-            raise error.TestFail('No VPN kind specified for this test.')
-        elif self.vpn_kind == 'openvpn':
-            # Read config information & create server configuration file.
-            for k, v in params.get('config', {}).iteritems():
-                self.openvpn_config[k] = v
-            self.server.run("cat <<EOF >/tmp/vpn-server.conf\n%s\nEOF\n" %
-                            ('\n'.join( "%s %s" % kv for kv in
-                                        self.openvpn_config.iteritems())))
-            self.server.run("/usr/sbin/openvpn "
-                            "--config /tmp/vpn-server.conf &")
-        elif self.vpn_kind in ('l2tpipsec-psk', 'l2tpipsec-cert'):
-            configs = {
-                "/etc/xl2tpd/xl2tpd.conf" :
-                "[global]\n"
-                "\n"
-                "[lns default]\n"
-                "  ip range = 192.168.1.128-192.168.1.254\n"
-                "  local ip = 192.168.1.99\n"
-                "  require chap = yes\n"
-                "  refuse pap = yes\n"
-                "  require authentication = yes\n"
-                "  name = LinuxVPNserver\n"
-                "  ppp debug = yes\n"
-                "  pppoptfile = /etc/ppp/options.xl2tpd\n"
-                "  length bit = yes\n",
-
-                "/etc/xl2tpd/l2tp-secrets" :
-                "*      them    l2tp-secret",
-
-                "/etc/ppp/chap-secrets" :
-                "chapuser        *       chapsecret      *",
-
-                "/etc/ppp/options.xl2tpd" :
-                "ipcp-accept-local\n"
-                "ipcp-accept-remote\n"
-                "noccp\n"
-                "auth\n"
-                "crtscts\n"
-                "idle 1800\n"
-                "mtu 1410\n"
-                "mru 1410\n"
-                "nodefaultroute\n"
-                "debug\n"
-                "lock\n"
-                "proxyarp\n"
-                "connect-delay 5000\n"
-            }
-            config_choices = {
-              'l2tpipsec-psk': {
-                  "/etc/ipsec.conf" :
-                  "config setup\n"
-                  "  charonstart=no\n"
-                  "  plutostart=yes\n"
-                  "  plutodebug=%(@plutodebug@)s\n"
-                  "  plutostderrlog=/var/log/pluto.log\n"
-                  "conn L2TP\n"
-                  "  keyexchange=ikev1\n"
-                  "  authby=psk\n"
-                  "  pfs=no\n"
-                  "  rekey=no\n"
-                  "  left=%(@local-listen-ip@)s\n"
-                  "  leftprotoport=17/1701\n"
-                  "  right=%%any\n"
-                  "  rightprotoport=17/%%any\n"
-                  "  auto=add\n",
-
-                  "/etc/ipsec.secrets" :
-                  "%(@ipsec-secrets@)s %%any : PSK \"password\"",
-                },
-                'l2tpipsec-cert': {
-                    "/etc/ipsec.conf" :
-                    "config setup\n"
-                    "  charonstart=no\n"
-                    "  plutostart=yes\n"
-                    "  plutodebug=%(@plutodebug@)s\n"
-                    "  plutostderrlog=/var/log/pluto.log\n"
-                    "conn L2TP\n"
-                    "  keyexchange=ikev1\n"
-                    "  left=%(@local-listen-ip@)s\n"
-                    "  leftcert=server.crt\n"
-                    "  leftid=\"C=US, ST=California, L=Mountain View, "
-                    "CN=chromelab-wifi-testbed-server.mtv.google.com\"\n"
-                    "  leftprotoport=17/1701\n"
-                    "  right=%%any\n"
-                    "  rightca=\"C=US, ST=California, L=Mountain View, "
-                    "CN=chromelab-wifi-testbed-root.mtv.google.com\"\n"
-                    "  rightprotoport=17/%%any\n"
-                    "  auto=add\n"
-                    "  pfs=no\n",
-
-                    "/etc/ipsec.secrets" : ": RSA server.key \"\"\n",
-                },
-            }
-            configs.update(config_choices[self.vpn_kind])
-
-            replacements = params.get("replacements", {})
-            # These two replacements must match up to the same
-            # adapter, or a connection will not be established.
-            replacements["@local-listen-ip@"] = "%defaultroute"
-            replacements["@ipsec-secrets@"]   = self.server.ip
-
-            for cfg, template in configs.iteritems():
-                contents = template % (replacements)
-                self.server.run("cat <<EOF >%s\n%s\nEOF\n" % (cfg, contents))
-
-            self.server.run("/usr/sbin/ipsec restart")
-
-            # Restart xl2tpd to ensure use of newly-created config files.
-            self.server.run("sh /etc/init.d/xl2tpd restart")
-        else:
-            raise error.TestFail('(internal error): No config case '
-                                 'for VPN kind (%s)' % self.vpn_kind)
-
-
-    def vpn_server_kill(self, params):
-        """Kill the VPN server.
-
-        @param params ignored.
-
-        """
-        if self.vpn_kind is not None:
-            if self.vpn_kind == 'openvpn':
-                self.server.run("pkill /usr/sbin/openvpn")
-            elif self.vpn_kind in ('l2tpipsec-psk', 'l2tpipsec-cert'):
-                self.server.run("/usr/sbin/ipsec stop")
-            else:
-                raise error.TestFail('(internal error): No kill case '
-                                     'for VPN kind (%s)' % self.vpn_kind)
-            self.vpn_kind = None
-
-
-    def ipv6_server_config(self, params):
-        """Start an IPv6 router advertisement daemon.
-
-        @param params dict of site_wifitest style parameters.
-
-        """
-        self.ipv6_server_kill({})
-        radvd_opts = { 'interface': self.config.get('server_dev', 'eth0'),
-                       'adv_send_advert': 'on',
-                       'min_adv_interval': '3',
-                       'max_adv_interval': '10',
-                       # NB: Addresses below are within the 2001:0db8/32
-                       # "documentation only" prefix (RFC3849), which is
-                       # guaranteed never to be assigned to a real network.
-                       'prefix': '2001:0db8:0100:f101::/64',
-                       'adv_on_link': 'on',
-                       'adv_autonomous': 'on',
-                       'adv_router_addr': 'on',
-                       'rdnss_servers': '2001:0db8:0100:f101::0001 '
-                                        '2001:0db8:0100:f101::0002',
-                       'adv_rdnss_lifetime': 'infinity',
-                       'dnssl_list': 'a.com b.com' }
-        radvd_opts.update(params)
-
-        config = ('interface %(interface)s {\n'
-                  '  AdvSendAdvert %(adv_send_advert)s;\n'
-                  '  MinRtrAdvInterval %(min_adv_interval)s;\n'
-                  '  MaxRtrAdvInterval %(max_adv_interval)s;\n'
-                  '  prefix %(prefix)s {\n'
-                  '    AdvOnLink %(adv_on_link)s;\n'
-                  '    AdvAutonomous %(adv_autonomous)s;\n'
-                  '    AdvRouterAddr %(adv_router_addr)s;\n'
-                  '  };\n'
-                  '  RDNSS %(rdnss_servers)s {\n'
-                  '    AdvRDNSSLifetime %(adv_rdnss_lifetime)s;\n'
-                  '  };\n'
-                  '  DNSSL %(dnssl_list)s {\n'
-                  '  };\n'
-                  '};\n') % radvd_opts
-        cfg_file = params.get('config_file', self.radvd_config['file'])
-        self.server.run('cat <<EOF >%s\n%s\nEOF\n' % (cfg_file, config))
-        self.server.run('%s -C %s\n' % (self.radvd_config['server'], cfg_file))
-
-
-    def ipv6_server_kill(self, params):
-        """Kill the IPv6 route advertisement daemon.
-
-        @param params ignored.
-
-        """
-        self.server.run('pkill %s >/dev/null 2>&1' %
-                        self.radvd_config['server'], ignore_status=True)
-
-
-    def ping(self, ping_config):
-        """Ping a client from the server.
-
-        @param ping_config PingConfig object describing the ping command to run.
-        @return a PingResult object.
-
-        """
-        return self._ping_runner.ping(ping_config)
diff --git a/server/site_linux_system.py b/server/site_linux_system.py
index 0c3b156..45574c2 100644
--- a/server/site_linux_system.py
+++ b/server/site_linux_system.py
@@ -9,6 +9,7 @@
 
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.common_lib.cros.network import iw_runner
+from autotest_lib.client.common_lib.cros.network import ping_runner
 from autotest_lib.server.cros import wifi_test_utils
 from autotest_lib.server.cros.network import packet_capturer
 
@@ -80,6 +81,7 @@
         # is not desired.
         self._wlanifs_initialized = False
         self._capabilities = None
+        self._ping_runner = ping_runner.PingRunner(host=self.host)
 
 
     @property
@@ -355,3 +357,14 @@
         for phy in self.phy_list:
             self.iw_runner.set_antenna_bitmap(phy.name, phy.avail_tx_antennas,
                                               phy.avail_rx_antennas)
+
+
+    def ping(self, ping_config):
+        """Ping an IP from this system.
+
+        @param ping_config PingConfig object describing the ping command to run.
+        @return a PingResult object.
+
+        """
+        logging.info('Pinging from the %s.', self.role)
+        return self._ping_runner.ping(ping_config)
diff --git a/server/site_tests/network_WiFi_AttenuatedPerf/network_WiFi_AttenuatedPerf.py b/server/site_tests/network_WiFi_AttenuatedPerf/network_WiFi_AttenuatedPerf.py
index bd3bce9..d34c599 100644
--- a/server/site_tests/network_WiFi_AttenuatedPerf/network_WiFi_AttenuatedPerf.py
+++ b/server/site_tests/network_WiFi_AttenuatedPerf/network_WiFi_AttenuatedPerf.py
@@ -75,7 +75,7 @@
         # at high attenuations, sometimes the control connection
         # is unable to terminate the test properly.
         session = netperf_session.NetperfSession(self.context.client,
-                                                 self.context.server,
+                                                 self.context.router,
                                                  ignore_failures=True)
         session.warmup_stations()
         for atten in range(self.STARTING_ATTENUATION,
diff --git a/server/site_tests/network_WiFi_Perf/network_WiFi_Perf.py b/server/site_tests/network_WiFi_Perf/network_WiFi_Perf.py
index be16215..3421bc5 100644
--- a/server/site_tests/network_WiFi_Perf/network_WiFi_Perf.py
+++ b/server/site_tests/network_WiFi_Perf/network_WiFi_Perf.py
@@ -54,7 +54,7 @@
                     security_config=ap_config.security_config)
             self.context.assert_connect_wifi(assoc_params)
             session = netperf_session.NetperfSession(self.context.client,
-                                                     self.context.server)
+                                                     self.context.router)
             # Conduct the performance tests while toggling powersave mode.
             for power_save in (True, False):
                 self.context.client.powersave_switch(power_save)
diff --git a/server/site_tests/network_WiFi_RateControl/network_WiFi_RateControl.py b/server/site_tests/network_WiFi_RateControl/network_WiFi_RateControl.py
index f29399e..387c1e6 100644
--- a/server/site_tests/network_WiFi_RateControl/network_WiFi_RateControl.py
+++ b/server/site_tests/network_WiFi_RateControl/network_WiFi_RateControl.py
@@ -134,7 +134,7 @@
                     ssid=self.context.router.get_ssid())
             self.context.assert_connect_wifi(assoc_params)
             with netperf_runner.NetperfRunner(self.context.client,
-                                              self.context.server,
+                                              self.context.router,
                                               netperf_config) as runner:
                 runner.run()
             results = self.context.router.stop_capture()
diff --git a/server/site_tests/network_WiFi_RoamOnLowPower/network_WiFi_RoamOnLowPower.py b/server/site_tests/network_WiFi_RoamOnLowPower/network_WiFi_RoamOnLowPower.py
index d8eb83a..a25594f 100644
--- a/server/site_tests/network_WiFi_RoamOnLowPower/network_WiFi_RoamOnLowPower.py
+++ b/server/site_tests/network_WiFi_RoamOnLowPower/network_WiFi_RoamOnLowPower.py
@@ -77,7 +77,7 @@
     as regular expressions.
 
     Expected to be called as follows:
-        launch_iw_event = LaunchIwEvent(self.context.client.command_iw,
+        launch_iw_event = LaunchIwEvent('iw',
                                         self.context.client.host,
                                         timeout_seconds=60.0)
         # Do things that cause nl80211 traffic
@@ -331,7 +331,7 @@
                     mode=hostap_config.HostapConfig.MODE_11G),
                                    multi_interface=True)
 
-            launch_iw_event = LaunchIwEvent(self.context.client.command_iw,
+            launch_iw_event = LaunchIwEvent('iw',
                                             self.context.client.host,
                                             timeout_seconds=60.0)