Example #1
0
            def get_network_mode_cb(mode):
                allowed = convert_network_mode_to_allowed_mode(mode)

                if allowed == self.settings['allowed_mode']:
                    log.msg("Simple SM: set_allowed_mode is current")
                    self.transition_to('wait_for_registration')
                else:
                    log.msg("Simple SM: set_allowed_mode change required")
                    d2 = self.sconn.set_allowed_mode(
                            self.settings['allowed_mode'])
                    # We need to wait long enough for the device to start
                    # switching and lose the current registration
                    d2.addCallback(lambda _: reactor.callLater(5,
                            self.transition_to, 'wait_for_registration'))
Example #2
0
    def test_NetworkSetAllowedMode(self):
        modes = self.device.Get(CRD_INTFACE, 'SupportedModes',
                                dbus_interface=dbus.PROPERTIES_IFACE)
        if not modes:
            raise unittest.SkipTest("Cannot be tested")

        for net_mode in get_network_modes(modes):
            mode = convert_network_mode_to_allowed_mode(net_mode)
            if mode is None:
                # could not convert it to allowed_mode
                continue

            self.device.SetAllowedMode(mode)
            allowed_mode = self.device.Get(NET_INTFACE, 'AllowedMode',
                                        dbus_interface=dbus.PROPERTIES_IFACE)
            self.assertEqual(mode, allowed_mode)

        # leave it in MODE_ANY and give it some seconds to settle
        self.device.SetAllowedMode(MM_ALLOWED_MODE_ANY)
        time.sleep(5)