示例#1
0
    def test_delete_a_non_active_connection(self):
        nm_settings = NMDbusSettings()

        iface = iface_name()
        with nm_connections(iface, IPV4ADDR, con_count=2):
            con_count_pre_delete = sum(1 for _ in nm_settings.connections())
            con = self._connection_to_delete(nm_settings, iface + '0')

            con.delete()

            con_count_post_delete = sum(1 for _ in nm_settings.connections())
            self.assertEqual(con_count_pre_delete, con_count_post_delete + 1)
示例#2
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
示例#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():
                    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
示例#4
0
文件: nmdbus_test.py 项目: nirs/vdsm
    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
示例#5
0
class TestNMConnectionSettings(VdsmTestCase):
    def setUp(self):
        self.nm_settings = NMDbusSettings()
        self.iface = iface_name()

    def test_configured_connections_attributes_existence(self):
        with dummy_devices(1) as nics:
            with nm_connections(self.iface, IPV4ADDR, slaves=nics) as connames:
                nm_con = self._get_connection(connames[0])

                self.assertEqual(connames[0], nm_con.connection.id)
                self.assertIsNotNone(nm_con.connection.uuid)
                self.assertIsNotNone(nm_con.connection.type)

    def test_delete_one_of_two_connections(self):
        with dummy_devices(1) as nics:
            with nm_connections(self.iface, IPV4ADDR, slaves=nics,
                                con_count=2) as connames:

                con0 = self._get_connection(connames[0])
                con0.delete()
                self.assertIsNone(self._get_connection(connames[0]))

                con1 = self._get_connection(connames[1])
                self.assertEqual(connames[1], con1.connection.id)

    def _get_connection(self, con_name):
        for nm_con in self.nm_settings.connections():
            if nm_con.connection.id == con_name:
                return nm_con
示例#6
0
文件: nmdbus_test.py 项目: EdDev/vdsm
class TestNMConnectionSettings(VdsmTestCase):

    def setUp(self):
        self.nm_settings = NMDbusSettings()
        self.iface = iface_name()

    def test_configured_connections_attributes_existence(self):
        with dummy_devices(1) as nics:
            with nm_connections(self.iface, IPV4ADDR, slaves=nics) as connames:
                nm_con = self._get_connection(connames[0])

                self.assertEqual(connames[0], nm_con.connection.id)
                self.assertIsNotNone(nm_con.connection.uuid)
                self.assertIsNotNone(nm_con.connection.type)

    def test_delete_one_of_two_connections(self):
        with dummy_devices(1) as nics:
            with nm_connections(self.iface, IPV4ADDR,
                                slaves=nics, con_count=2) as connames:

                con0 = self._get_connection(connames[0])
                con0.delete()
                self.assertIsNone(self._get_connection(connames[0]))

                con1 = self._get_connection(connames[1])
                self.assertEqual(connames[1], con1.connection.id)

    def _get_connection(self, con_name):
        for nm_con in self.nm_settings.connections():
            if nm_con.connection.id == con_name:
                return nm_con
示例#7
0
    def test_configured_connections_attributes_existence(self):
        nm_settings = NMDbusSettings()

        iface = iface_name()
        with nm_connections(iface, IPV4ADDR):
            con_count = 0
            for nm_con in nm_settings.connections():
                if nm_con.connection.type in ('802-11-wireless', 'vpn'):
                    continue

                assert nm_con.connection.id is not None
                assert nm_con.connection.uuid is not None
                assert nm_con.connection.type is not None

                con_count += 1

            self.assertGreaterEqual(con_count, 1)
示例#8
0
    def test_device_attributes_existence(self):
        nm_device = NMDbusDevice()
        nm_settings = NMDbusSettings()

        device_count = 0
        for device in nm_device.devices():
            assert device.interface is not None
            assert device.state is not None
            assert device.active_connection_path is not None
            assert device.connections_path is not None

            for connection_path in device.connections_path:
                settings_con = nm_settings.connection(connection_path)
                assert settings_con.connection.uuid is not None

            device_count += 1

        self.assertGreaterEqual(device_count, 1)
示例#9
0
文件: nmdbus_test.py 项目: EdDev/vdsm
    def test_device_attributes_existence(self):
        nm_device = NMDbusDevice()
        nm_settings = NMDbusSettings()

        device_count = 0
        for device in nm_device.devices():
            assert device.interface is not None
            assert device.state is not None
            assert device.active_connection_path is not None
            assert device.connections_path is not None

            for connection_path in device.connections_path:
                settings_con = nm_settings.connection(connection_path)
                assert settings_con.connection.uuid is not None

            device_count += 1

        self.assertGreaterEqual(device_count, 1)
示例#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 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)
示例#11
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)
示例#12
0
文件: nmdbus_test.py 项目: xin49/vdsm
    def test_device_attributes_existence(self):
        nm_device = NMDbusDevice()
        nm_settings = NMDbusSettings()

        device_count = 0
        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics):
                for device in nm_device.devices():
                    try:
                        assert device.interface() is not None
                        assert device.state() is not None
                        assert device.active_connection_path() is not None
                        assert device.connections_path() is not None
                    except errors.NMPropertiesNotFoundError:
                        continue

                    for connection_path in device.connections_path():
                        settings_con = nm_settings.connection(connection_path)
                        assert settings_con.connection.uuid is not None

                    device_count += 1

        self.assertGreaterEqual(device_count, 1)
示例#13
0
文件: nmdbus_test.py 项目: nirs/vdsm
    def test_device_attributes_existence(self):
        nm_device = NMDbusDevice()
        nm_settings = NMDbusSettings()

        device_count = 0
        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics):
                for device in nm_device.devices():
                    try:
                        assert device.interface() is not None
                        assert device.state() is not None
                        assert device.active_connection_path() is not None
                        assert device.connections_path() is not None
                    except errors.NMPropertiesNotFoundError:
                        continue

                    for connection_path in device.connections_path():
                        settings_con = nm_settings.connection(connection_path)
                        assert settings_con.connection.uuid is not None

                    device_count += 1

        self.assertGreaterEqual(device_count, 1)
示例#14
0
 def setUp(self):
     self.nm_settings = NMDbusSettings()
     self.iface = iface_name()
示例#15
0
文件: nmdbus_test.py 项目: EdDev/vdsm
 def setUp(self):
     self.nm_settings = NMDbusSettings()
     self.iface = iface_name()
示例#16
0
def nmd_bus():
    return {
        'active_cons': NMDbusActiveConnections(),
        'device': NMDbusDevice(),
        'settings': NMDbusSettings(),
    }