Beispiel #1
0
    def test_active_connections_properties_vs_connection_settings(self):
        nm_active_cons = NMDbusActiveConnections()
        nm_settings = NMDbusSettings()

        iface = iface_name()
        with nm_connections(iface, IPV4ADDR):
            for active_con in nm_active_cons.connections():
                settings_con = nm_settings.connection(active_con.con_path)

                assert active_con.uuid == settings_con.connection.uuid
                assert active_con.type == settings_con.connection.type
                assert active_con.id == settings_con.connection.id
Beispiel #2
0
    def test_active_connections_properties_vs_connection_settings(self):
        nm_active_cons = NMDbusActiveConnections()
        nm_settings = NMDbusSettings()

        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics):
                for active_con in nm_active_cons.connections():
                    settings_con = nm_settings.connection(active_con.con_path)

                    assert active_con.uuid == settings_con.connection.uuid
                    assert active_con.type == settings_con.connection.type
                    assert active_con.id == settings_con.connection.id
Beispiel #3
0
    def test_active_connections_properties_vs_connection_settings(self):
        nm_active_cons = NMDbusActiveConnections()
        nm_settings = NMDbusSettings()

        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics):
                for active_con in nm_active_cons.connections():
                    connection_path = active_con.con_path()
                    settings_con = nm_settings.connection(connection_path)

                    assert active_con.uuid() == settings_con.connection.uuid
                    assert active_con.type() == settings_con.connection.type
                    assert active_con.id() == settings_con.connection.id
Beispiel #4
0
    def test_nm_connection_lifetime(self):
        nm_act_cons = NMDbusActiveConnections()
        nm_device = NMDbusDevice()

        iface = iface_name()
        with nm_connections(iface, IPV4ADDR):
            active_con_path = nm_device.device(iface).active_connection_path
            active_con = nm_act_cons.connection(active_con_path)

            self.assertEqual(TEST_LINK_TYPE, str(active_con.type))
            self.assertEqual(types.NMActiveConnectionState.ACTIVATED,
                             active_con.state)

        self._assert_no_device(iface)
Beispiel #5
0
    def test_active_connections_properties_existence(self):
        nm_active_cons = NMDbusActiveConnections()

        iface = iface_name()
        with nm_connections(iface, IPV4ADDR):
            con_count = 0
            for connection in nm_active_cons.connections():
                assert connection.id is not None
                assert connection.uuid is not None
                assert connection.type is not None
                assert connection.master_con_path is not None

                con_count += 1

            self.assertGreaterEqual(con_count, 1)
Beispiel #6
0
    def test_active_connections_properties_existence(self):
        nm_active_cons = NMDbusActiveConnections()

        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics):
                con_count = 0
                for connection in nm_active_cons.connections():
                    assert connection.id is not None
                    assert connection.uuid is not None
                    assert connection.type is not None
                    assert connection.master_con_path is not None

                    con_count += 1

                self.assertGreaterEqual(con_count, 1)
Beispiel #7
0
    def test_nm_connection_lifetime(self):
        nm_act_cons = NMDbusActiveConnections()
        nm_device = NMDbusDevice()

        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics):
                device = nm_device.device(iface)
                active_con_path = device.active_connection_path
                active_con = nm_act_cons.connection(active_con_path)

                self.assertEqual(TEST_LINK_TYPE, str(active_con.type))
                self.assertEqual(types.NMActiveConnectionState.ACTIVATED,
                                 active_con.state)

        self._assert_no_device(iface)
Beispiel #8
0
    def test_nm_connection_lifetime(self):
        nm_act_cons = NMDbusActiveConnections()
        nm_device = NMDbusDevice()

        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics):
                device = nm_device.device(iface)
                device.syncoper.waitfor_activated_state()
                active_con_path = device.active_connection_path()
                active_con = nm_act_cons.connection(active_con_path)

                self.assertEqual(TEST_LINK_TYPE, str(active_con.type()))
                self.assertEqual(types.NMActiveConnectionState.ACTIVATED,
                                 active_con.state())

        self._assert_no_device(iface)
Beispiel #9
0
    def _test_device_with_n_connections(self, con_count):
        nm_device = NMDbusDevice()
        nm_settings = NMDbusSettings()
        nm_act_cons = NMDbusActiveConnections()

        configured_connections = set()
        active_connections = set()

        iface = iface_name()
        with nm_connections(iface, IPV4ADDR, con_count=con_count):
            device = nm_device.device(iface)
            for connection_path in device.connections_path:
                settings_con = nm_settings.connection(connection_path)
                configured_connections.add(settings_con.connection.id)

            ac = nm_act_cons.connection(device.active_connection_path)
            active_connections.add(ac.id)

        self.assertEqual(con_count, len(configured_connections))
        self.assertEqual(set([iface + '0']), active_connections)
Beispiel #10
0
    def _test_device_with_n_connections(self, con_count):
        nm_device = NMDbusDevice()
        nm_settings = NMDbusSettings()
        nm_act_cons = NMDbusActiveConnections()

        configured_connections = set()
        active_connections = set()

        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(
                iface, IPV4ADDR, slaves=nics, con_count=con_count
            ):
                device = nm_device.device(iface)
                for connection_path in device.connections_path():
                    settings_con = nm_settings.connection(connection_path)
                    configured_connections.add(settings_con.connection.id)

                ac = nm_act_cons.connection(device.active_connection_path())
                active_connections.add(ac.id())

        self.assertEqual(con_count, len(configured_connections))
        self.assertEqual(set([iface + '0']), active_connections)
Beispiel #11
0
def nmd_bus():
    return {
        'active_cons': NMDbusActiveConnections(),
        'device': NMDbusDevice(),
        'settings': NMDbusSettings(),
    }