OLD | NEW |
---|---|
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import common, datetime, fnmatch, logging, os, re, string, threading, time | 5 import common, datetime, fnmatch, logging, os, re, string, threading, time |
6 | 6 |
7 from autotest_lib.server import autotest, hosts, subcommand | 7 from autotest_lib.server import autotest, hosts, subcommand |
8 from autotest_lib.server import site_bsd_router | 8 from autotest_lib.server import site_bsd_router |
9 from autotest_lib.server import site_linux_router | 9 from autotest_lib.server import site_linux_router |
10 from autotest_lib.server import site_linux_server | 10 from autotest_lib.server import site_linux_server |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 self.server = hosts.create_host(server['addr']) | 135 self.server = hosts.create_host(server['addr']) |
136 self.server_at = autotest.Autotest(self.server) | 136 self.server_at = autotest.Autotest(self.server) |
137 # if not specified assume the same as the control address | 137 # if not specified assume the same as the control address |
138 self.server_wifi_ip = server.get('wifi_addr', self.server.ip) | 138 self.server_wifi_ip = server.get('wifi_addr', self.server.ip) |
139 self.__server_discover_commands(server) | 139 self.__server_discover_commands(server) |
140 else: | 140 else: |
141 self.server = None | 141 self.server = None |
142 # NB: wifi address must be set if not reachable from control | 142 # NB: wifi address must be set if not reachable from control |
143 self.server_wifi_ip = server['wifi_addr'] | 143 self.server_wifi_ip = server['wifi_addr'] |
144 | 144 |
145 # hosting_server is a machine which hosts network services, | 145 # The 'hosting_server' is a machine which hosts network |
146 # such as VPN. | 146 # services, such as OpenVPN or StrongSwan. |
147 self.hosting_server = site_linux_server.LinuxServer(self.server, server) | 147 self.hosting_server = site_linux_server.LinuxServer(self.server, server) |
148 | 148 |
149 # potential bg thread for ping untilstop | 149 # potential bg thread for ping untilstop |
150 self.ping_thread = None | 150 self.ping_thread = None |
151 | 151 |
152 # potential bg thread for client network monitoring | 152 # potential bg thread for client network monitoring |
153 self.client_netdump_thread = None | 153 self.client_netdump_thread = None |
154 self.__client_discover_commands(client) | 154 self.__client_discover_commands(client) |
155 self.profile_save({}) | 155 self.profile_save({}) |
156 self.firewall_rules = [] | 156 self.firewall_rules = [] |
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1247 'openvpn vpn-name %s vpn-domain ' | 1247 'openvpn vpn-name %s vpn-domain ' |
1248 '%s ' # ca certificate | 1248 '%s ' # ca certificate |
1249 '%s ' # client certificate | 1249 '%s ' # client certificate |
1250 '%s' % # client key | 1250 '%s' % # client key |
1251 (self.client_cmd_flimflam_lib, | 1251 (self.client_cmd_flimflam_lib, |
1252 remote_cert_tls_option, | 1252 remote_cert_tls_option, |
1253 vpn_host_ip, | 1253 vpn_host_ip, |
1254 cert_pathnames['ca-certificate'], | 1254 cert_pathnames['ca-certificate'], |
1255 cert_pathnames['client-certificate'], | 1255 cert_pathnames['client-certificate'], |
1256 cert_pathnames['client-key'])) | 1256 cert_pathnames['client-key'])) |
1257 elif self.vpn_kind == 'l2tpipsec-psk': # aka 'strongswan' | |
Sam Leffler
2011/03/31 17:11:27
We've tried hard to not have explicit builtin code
| |
1258 result = self.client.run('%s/test/connect-vpn ' | |
1259 '--verbose ' | |
1260 'l2tpipsec-psk vpn-name %s vpn-domain ' | |
1261 'password chapuser chapsecret' % | |
1262 (self.client_cmd_flimflam_lib, | |
1263 vpn_host_ip)) | |
1257 else: | 1264 else: |
1258 raise error.TestFail('(internal error): No launch case ' | 1265 raise error.TestFail('(internal error): No launch case ' |
1259 'for VPN kind (%s)' % self.vpn_kind) | 1266 'for VPN kind (%s)' % self.vpn_kind) |
1260 | 1267 |
1261 def vpn_client_kill(self, params): | 1268 def vpn_client_kill(self, params): |
1262 """ Kill the VPN client if it's running. """ | 1269 """ Kill the VPN client if it's running. """ |
1263 if self.vpn_kind is not None: | 1270 if self.vpn_kind is not None: |
Sam Leffler
2011/03/31 17:11:27
see above, it might be time to factor out vpn supp
| |
1264 if self.vpn_kind == 'openvpn': | 1271 if self.vpn_kind == 'openvpn': |
1265 self.client.run("pkill openvpn") | 1272 self.client.run("pkill openvpn") |
1273 elif (self.vpn_kind == 'l2tpipsec-psk' or # aka 'strongswan' | |
1274 self.vpn_kind == 'l2tpipsec-cert') | |
1275 self.client.run("pkill /usr/libexec/ipsec/pluto") | |
1276 self.client.run("pkill /usr/libexec/ipsec/starter") | |
1277 self.client.run("pkill _pluto_adns") | |
1278 self.client.run("pkill /usr/sbin/pppd") | |
1279 self.client.run("pkill /usr/sbin/xl2tpd") | |
1280 self.client.run("pkill /usr/sbin/l2tpipsec_vpn") | |
1266 else: | 1281 else: |
1267 raise error.TestFail('(internal error): No kill case ' | 1282 raise error.TestFail('(internal error): No kill case ' |
1268 'for VPN kind (%s)' % self.vpn_kind) | 1283 'for VPN kind (%s)' % self.vpn_kind) |
1269 self.vpn_kind = None | 1284 self.vpn_kind = None |
1270 | 1285 |
1271 class HelperThread(threading.Thread): | 1286 class HelperThread(threading.Thread): |
1272 # Class that wraps a ping command in a thread so it can run in the bg. | 1287 # Class that wraps a ping command in a thread so it can run in the bg. |
1273 def __init__(self, client, cmd): | 1288 def __init__(self, client, cmd): |
1274 threading.Thread.__init__(self) | 1289 threading.Thread.__init__(self) |
1275 self.client = client | 1290 self.client = client |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1395 except error.TestFail: | 1410 except error.TestFail: |
1396 if 'expect_failure' in testcase: | 1411 if 'expect_failure' in testcase: |
1397 self.expect_failure(name, testcase['expect_failure']) | 1412 self.expect_failure(name, testcase['expect_failure']) |
1398 else: | 1413 else: |
1399 raise | 1414 raise |
1400 except Exception, e: | 1415 except Exception, e: |
1401 if 'expect_failure' in testcase: | 1416 if 'expect_failure' in testcase: |
1402 self.expect_failure(name, testcase['expect_failure']) | 1417 self.expect_failure(name, testcase['expect_failure']) |
1403 else: | 1418 else: |
1404 raise | 1419 raise |
OLD | NEW |