| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 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 dbus, logging, os, shutil, socket, sys, time | 5 import dbus, logging, os, shutil, socket, sys, time |
| 6 from autotest_lib.client.bin import chromeos_constants | 6 from autotest_lib.client.bin import chromeos_constants |
| 7 from autotest_lib.client.bin import site_login, site_utils, test as bin_test | 7 from autotest_lib.client.bin import site_login, site_utils, test as bin_test |
| 8 from autotest_lib.client.common_lib import error, site_ui | 8 from autotest_lib.client.common_lib import error, site_ui |
| 9 from autotest_lib.client.common_lib import site_auth_server, site_dns_server | 9 from autotest_lib.client.common_lib import site_auth_server, site_dns_server |
| 10 from dbus.mainloop.glib import DBusGMainLoop | 10 from dbus.mainloop.glib import DBusGMainLoop |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 def use_local_dns(self, dns_port=53): | 69 def use_local_dns(self, dns_port=53): |
| 70 """Set all devices to use our in-process mock DNS server. | 70 """Set all devices to use our in-process mock DNS server. |
| 71 """ | 71 """ |
| 72 self._dnsServer = site_dns_server.LocalDns(local_port=dns_port) | 72 self._dnsServer = site_dns_server.LocalDns(local_port=dns_port) |
| 73 self._dnsServer.run() | 73 self._dnsServer.run() |
| 74 self._bus_loop = DBusGMainLoop(set_as_default=True) | 74 self._bus_loop = DBusGMainLoop(set_as_default=True) |
| 75 self._system_bus = dbus.SystemBus(mainloop=self._bus_loop) | 75 self._system_bus = dbus.SystemBus(mainloop=self._bus_loop) |
| 76 self._flim = flimflam.FlimFlam(self._system_bus) | 76 self._flim = flimflam.FlimFlam(self._system_bus) |
| 77 for device in self._flim.GetObjectList('Device'): | 77 for device in self._flim.GetObjectList('Device'): |
| 78 properties = device.GetProperties() | 78 properties = device.GetProperties() |
| 79 logging.debug("Considering " + properties['Type']) |
| 79 for path in properties['IPConfigs']: | 80 for path in properties['IPConfigs']: |
| 80 ipconfig = self._flim.GetObjectInterface('IPConfig', path) | 81 ipconfig = self._flim.GetObjectInterface('IPConfig', path) |
| 81 | 82 |
| 82 servers = ipconfig.GetProperties().get('NameServers', None) | 83 servers = ipconfig.GetProperties().get('NameServers', None) |
| 83 if servers != None: | 84 if servers != None: |
| 84 self._dns[path] = ','.join(servers) | 85 self._dns[path] = ','.join(servers) |
| 86 logging.debug("Cached DNS for " + properties['Type']) |
| 85 ipconfig.SetProperty('NameServers', '127.0.0.1') | 87 ipconfig.SetProperty('NameServers', '127.0.0.1') |
| 88 logging.debug("Changed DNS for " + properties['Type']) |
| 86 | 89 |
| 87 site_utils.poll_for_condition( | 90 site_utils.poll_for_condition( |
| 88 lambda: self.__attempt_resolve('www.google.com', '127.0.0.1'), | 91 lambda: self.__attempt_resolve('www.google.com', '127.0.0.1'), |
| 89 site_login.TimeoutError('Timed out waiting for DNS changes.'), | 92 site_login.TimeoutError('Timed out waiting for DNS changes.'), |
| 90 10) | 93 10) |
| 91 site_login.refresh_login_screen() | 94 site_login.refresh_login_screen() |
| 92 | 95 |
| 93 | 96 |
| 94 def revert_dns(self): | 97 def revert_dns(self): |
| 95 """Clear the custom DNS setting for all devices and force them to use | 98 """Clear the custom DNS setting for all devices and force them to use |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 self.logout() | 254 self.logout() |
| 252 | 255 |
| 253 self.stop_authserver() | 256 self.stop_authserver() |
| 254 | 257 |
| 255 | 258 |
| 256 def get_auth_endpoint_misses(self): | 259 def get_auth_endpoint_misses(self): |
| 257 if hasattr(self, '_authServer'): | 260 if hasattr(self, '_authServer'): |
| 258 return self._authServer.get_endpoint_misses() | 261 return self._authServer.get_endpoint_misses() |
| 259 else: | 262 else: |
| 260 return {} | 263 return {} |
| OLD | NEW |