Ejemplo n.º 1
0
 def is_monitor_alive(self):
     """Check if huddly-monitor is alive and registered on Dbus."""
     result = dbus_send.dbus_send("org.freedesktop.DBus",
                                  "org.freedesktop.DBus",
                                  "/org/freedesktop/DBus", "ListNames",
                                  None, self._host, 2, False, "cfm-monitor")
     return OBJ_INTERFACE in result.response
Ejemplo n.º 2
0
    def delete_component(self, component):
        """
        Delete filter component via dbus API

        Args:
        @param component: name of component
        """
        logging.info('delete component:' + component)

        dbus_send.dbus_send('org.chromium.ComponentUpdaterService',
                            'org.chromium.ComponentUpdaterService',
                            '/org/chromium/ComponentUpdaterService',
                            'UnloadComponent',
                            timeout_seconds=20,
                            user='******',
                            args=[dbus.String(component)])
Ejemplo n.º 3
0
    def _delete_component(self, component):
        """
        Delete filter component via dbus API

        @param component: name of component

        """
        if component not in self._loaded_components:
            return
        dbus_send.dbus_send('org.chromium.ComponentUpdaterService',
                            'org.chromium.ComponentUpdaterService',
                            '/org/chromium/ComponentUpdaterService',
                            'UnloadComponent',
                            timeout_seconds=20,
                            user='******',
                            args=[dbus.String(component)])
        self._loaded_components.remove(component)
Ejemplo n.º 4
0
 def _get_component_version(self, name):
     args = [dbus.String(name)]
     return dbus_send.dbus_send(self.BUS_NAME,
                                self.BUS_INTERFACE,
                                self.BUS_PATH,
                                self.GET_COMPONENT_VERSION,
                                user=self.USER,
                                args=args).response
 def _load_component(self, name):
     args = [dbus.String(name)]
     return dbus_send.dbus_send(self.BUS_NAME,
                                self.BUS_INTERFACE,
                                self.BUS_PATH,
                                self.LOAD_COMPONENT,
                                timeout_seconds=60,
                                user=self.USER,
                                args=args).response
Ejemplo n.º 6
0
 def _unmount_component(self, name):
     args = [dbus.String(name)]
     return dbus_send.dbus_send(self.BUS_NAME,
                                self.BUS_INTERFACE,
                                self.BUS_PATH,
                                self.UNMOUNT_COMPONENT,
                                timeout_seconds=20,
                                user=self.USER,
                                args=args).response
Ejemplo n.º 7
0
 def _load_component_at_path(self, name, path):
     args = [dbus.String(name), dbus.String(path)]
     return dbus_send.dbus_send(self.BUS_NAME,
                                self.BUS_INTERFACE,
                                self.BUS_PATH,
                                self.LOAD_COMPONENT_AT_PATH,
                                timeout_seconds=20,
                                user=self.USER,
                                args=args).response
Ejemplo n.º 8
0
 def _register_component(self, name, version, path):
     args = [dbus.String(name), dbus.String(version), dbus.String(path)]
     return dbus_send.dbus_send(self.BUS_NAME,
                                self.BUS_INTERFACE,
                                self.BUS_PATH,
                                self.REGISTER_COMPONENT,
                                timeout_seconds=20,
                                user=self.USER,
                                args=args).response
Ejemplo n.º 9
0
def avahi_get_domain_name(host=None):
    """Get the current domain name being used by Avahi.

    @param host: An optional host object if running against a remote host.
    @return string: the current domain name being used by Avahi.

    """
    result = dbus_send.dbus_send(BUS_NAME,
                                 INTERFACE_SERVER,
                                 '/',
                                 'GetDomainName',
                                 host=host,
                                 timeout_seconds=2,
                                 tolerate_failures=True)
    return None if result is None else result.response
Ejemplo n.º 10
0
def avahi_get_hostname(host=None):
    """Get the lan-unique hostname of the the device.

    @param host: An optional host object if running against a remote host.
    @return string: the lan-unique hostname of the DUT.

    """
    result = dbus_send.dbus_send(BUS_NAME,
                                 INTERFACE_SERVER,
                                 '/',
                                 'GetHostName',
                                 host=host,
                                 timeout_seconds=2,
                                 tolerate_failures=True)
    return None if result is None else result.response
Ejemplo n.º 11
0
def check_dbus_available():
    """
    Checks if Atrusd with dbus support is available.

    @returns True if dbus is supported in atrusd. False otherwise.
    """
    result = dbus_send.dbus_send('org.freedesktop.DBus',
                                 'org.freedesktop.DBus',
                                 '/org/freedesktop/DBus',
                                 'ListNames',
                                 args=None,
                                 timeout_seconds=2,
                                 tolerate_failures=False)

    return 'org.chromium.Atrusctl' in result.response
Ejemplo n.º 12
0
def force_upgrade_atrus():
    """
    Executes a forced upgrade of the Atrus device.

    @returns True if the upgrade succeeded. False otherwise.
    """
    args = [dbus.String('/lib/firmware/google/atrus-fw-bundle-latest.bin')]
    result = dbus_send.dbus_send('org.chromium.Atrusctl',
                                 'org.chromium.Atrusctl',
                                 '/org/chromium/Atrusctl',
                                 'ForceFirmwareUpgrade',
                                 args=args,
                                 timeout_seconds=90,
                                 tolerate_failures=True)

    return result.response
Ejemplo n.º 13
0
def confirm_peerd_up(service_name=SERVICE_NAME, timeout_seconds=10, host=None):
    """Confirm that an instance of peerd is running.

    @param service_name: string name of DBus connection to look for peerd on.
            Defaults to the well known peerd bus name.
    @param timeout_seconds: number of seconds to wait for peerd to answer
            queries.
    @param host: Host object if peerd is running on a remote host.

    """
    start_time = time.time()
    while time.time() - start_time < timeout_seconds:
        result = dbus_send.dbus_send(
                service_name, DBUS_INTERFACE_MANAGER, DBUS_PATH_MANAGER,
                'Ping', host=host, tolerate_failures=True)
        if result is not None and result.response == 'Hello world!':
            return
        time.sleep(0.5)
    raise error.TestFail('Timed out before peerd at %s started.' % service_name)
Ejemplo n.º 14
0
def avahi_ping(host=None):
    """Returns True when the avahi-deamon's DBus interface is ready.

    After your launch avahi-daemon, there is a short period of time where the
    daemon is running but the DBus interface isn't ready yet. This functions
    blocks for a few seconds waiting for a ping response from the DBus API
    and returns wether it got a response.

    @param host: An optional host object if running against a remote host.
    @return boolean: True if Avahi is up and in a stable state.

    """
    result = dbus_send.dbus_send(BUS_NAME,
                                 INTERFACE_SERVER,
                                 '/',
                                 'GetState',
                                 host=host,
                                 timeout_seconds=2,
                                 tolerate_failures=True)
    # AVAHI_ENTRY_GROUP_ESTABLISHED == 2
    return result is not None and result.response == 2
Ejemplo n.º 15
0
    def download_component(self, component):
        """
        Download filter component via dbus API

        Args:
        @param component: name of component

        @raises: error.TestFail is component is not loaded.
        """
        logging.info('download component:' + component)

        res = dbus_send.dbus_send('org.chromium.ComponentUpdaterService',
                                  'org.chromium.ComponentUpdaterService',
                                  '/org/chromium/ComponentUpdaterService',
                                  'LoadComponent',
                                  timeout_seconds=20,
                                  user='******',
                                  args=[dbus.String(component)])

        if res.response == '':
            raise error.TestFail('Component could not be loaded.')
Ejemplo n.º 16
0
    def _load_component(self, component):
        """
        Download filter component via dbus API

        @param component: name of component

        @raises Exception if component is not loaded.

        """
        if component in self._loaded_components:
            return
        res = dbus_send.dbus_send('org.chromium.ComponentUpdaterService',
                                  'org.chromium.ComponentUpdaterService',
                                  '/org/chromium/ComponentUpdaterService',
                                  'LoadComponent',
                                  timeout_seconds=20,
                                  user='******',
                                  args=[dbus.String(component)])
        if res.response == '':
            message = 'Component %s could not be loaded.' % component
            raise Exception(message)
        self._loaded_components.append(component)