예제 #1
0
 def initialize(self):
     # Make sure these are initiallized to None in case we throw
     # during self.initialize().
     self._chrooted_avahi = None
     self._peerd = None
     self._host = None
     self._zc_listener = None
     self._chrooted_avahi = chrooted_avahi.ChrootedAvahi()
     self._chrooted_avahi.start()
     # Start up a fresh copy of peerd with really verbose logging.
     self._peerd = peerd_dbus_helper.make_helper(
             peerd_config.PeerdConfig(verbosity_level=3))
     # Listen on our half of the interface pair for mDNS advertisements.
     self._host = interface_host.InterfaceHost(
             self._chrooted_avahi.unchrooted_interface_name)
     self._zc_listener = zeroconf.ZeroconfDaemon(self._host,
                                                 self.FAKE_HOST_HOSTNAME)
     # The queries for hostname/dns_domain are IPCs and therefore relatively
     # expensive.  Do them just once.
     hostname = self._chrooted_avahi.hostname
     dns_domain = self._chrooted_avahi.dns_domain
     if not hostname or not dns_domain:
         raise error.TestFail('Failed to get hostname/domain from avahi.')
     self._dns_domain = dns_domain
     self._hostname = '%s.%s' % (hostname, dns_domain)
예제 #2
0
    def reset_peerd(self):
        """Start up a peerd instance.

        This instance will have really verbose logging and will attempt
        to use a known MDNS prefix to start out.

        """
        self._peerd = peerd_dbus_helper.make_helper(
                peerd_config.PeerdConfig(verbosity_level=3,
                                         mdns_prefix=self.INITIAL_MDNS_PREFIX))
예제 #3
0
 def warmup(self, host, router_hostname=None):
     self._router = None
     self._shill_xmlrpc_proxy = None
     config = buffet_config.BuffetConfig(
             log_verbosity=3,
             enable_ping=True,
             disable_pairing_security=True,
             device_whitelist='any',
             options={'wifi_bootstrap_mode': 'automatic'})
     config.restart_with_config(host=host)
     self._router = site_linux_router.build_router_proxy(
             test_name=self.__class__.__name__,
             client_hostname=host.hostname,
             router_addr=router_hostname,
             enable_avahi=True)
     self._shill_xmlrpc_proxy = wifi_client.get_xmlrpc_proxy(host)
     # Cleans up profiles, wifi credentials, sandboxes our new credentials.
     self._shill_xmlrpc_proxy.init_test_network_state()
     peerd_config.PeerdConfig(verbosity_level=3).restart_with_config(
             host=host)
 def run_once(self):
     self._bus = dbus.SystemBus()
     config = peerd_config.PeerdConfig(verbosity_level=5)
     config.restart_with_config()
     self._check_has_test_service(expect_service=False)
     self._manager = dbus.Interface(
             self._bus.get_object(peerd_config.SERVICE_NAME,
                                  peerd_config.DBUS_PATH_MANAGER),
             peerd_config.DBUS_INTERFACE_MANAGER)
     self._manager.ExposeService(SERVICE_ID,
                                 dbus.Dictionary(signature='ss'),
                                 dbus.Dictionary(signature='sv'))
     # Python keeps the DBus connection sitting around unless we
     # explicitly close it.  The service should still be there.
     time.sleep(1)  # Peerd might take some time to publish the service.
     self._check_has_test_service()
     # Close our previous connection, open a new one.
     self._bus.close()
     self._bus = dbus.SystemBus()
     time.sleep(1)  # Peerd might take some time to remove the service.
     self._check_has_test_service(expect_service=False)