示例#1
0
文件: nm_test.py 项目: vjuranek/vdsm
    def test_remove_all_non_active_connection_from_a_device(self, nic0):
        iface = iface_name()
        with nm_connections(iface, IPV4ADDR, slaves=(nic0, ), con_count=3):
            device = networkmanager.Device(iface)
            device.cleanup_inactive_connections()

            assert sum(1 for _ in device.connections()) == 1
示例#2
0
    def test_configured_connections_attributes_existence(self, nic0, nmd_bus):
        with nm_connections(IFACE, IPV4ADDR, slaves=(nic0, )) as connames:
            nm_con = self._get_connection(connames[0], nmd_bus)

            assert nm_con.connection.id == connames[0]
            assert nm_con.connection.uuid is not None
            assert nm_con.connection.type is not None
示例#3
0
    def test_add_net_based_on_existing_vlan_bond_nm_setup(self):
        vlan_id = '101'
        NET = {
            NETWORK_NAME: {
                'bonding': self.iface,
                'vlan': int(vlan_id),
                'switch': self.switch,
            }
        }
        with dummy_devices(1) as nics:
            with nmnettestlib.nm_connections(self.iface,
                                             ipv4addr=None,
                                             vlan=vlan_id,
                                             slaves=nics):
                bond_hwaddress = link_iface.iface(self.iface).address()
                vlan_iface = '.'.join([self.iface, vlan_id])
                vlan_hwaddress = link_iface.iface(vlan_iface).address()
                assert vlan_hwaddress == bond_hwaddress

                with adapter.setupNetworks(NET, {}, NOCHK):
                    adapter.assertNetwork(NETWORK_NAME, NET[NETWORK_NAME])

                    # Check if the mac has been preserved.
                    bridge_hwaddress = link_iface.iface(NETWORK_NAME).address()
                    assert vlan_hwaddress == bridge_hwaddress
示例#4
0
    def test_detect_connection_based_on_ifcfg_file(self):
        """
        NM may use ifcfg files as its storage format for connections via the
        ifcfg-rh settings plugin.
        This is the default option under RHEL/Centos/Fedora.
        When a connection is defined, it is saved in an ifcfg file, however,
        the filename is not recorded in NM records.
        In some scenarios, it is useful look for the ifcfg filename based on
        a given connection or the other way around, looking for the connection
        given the filename.
        """
        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface,
                                IPV4ADDR,
                                slaves=nics,
                                con_count=3,
                                save=True):
                device = networkmanager.Device(iface)
                expected_uuids = {
                    con.connection.uuid
                    for con in device.connections()
                }

                actual_uuids = {
                    networkmanager.ifcfg2connection(file)[0]
                    for file in self._ifcfg_files()
                }

                self.assertLessEqual(expected_uuids, actual_uuids)
示例#5
0
 def test_add_net_based_on_device_with_multiple_nm_connections(self):
     IPv4_ADDRESS = '192.0.2.1'
     NET = {NETWORK_NAME: {'bonding': self.iface, 'switch': self.switch}}
     with dummy_devices(1) as nics:
         with nmnettestlib.nm_connections(
                 self.iface, IPv4_ADDRESS, con_count=3, slaves=nics):
             with self.setupNetworks(NET, {}, NOCHK):
                 self.assertNetwork(NETWORK_NAME, NET[NETWORK_NAME])
示例#6
0
文件: nmdbus_test.py 项目: xin49/vdsm
    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)
示例#7
0
文件: nmdbus_test.py 项目: nirs/vdsm
    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)
示例#8
0
文件: nm_test.py 项目: nirs/vdsm
    def test_remove_all_non_active_connection_from_a_device(self):
        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics, con_count=3):

                device = networkmanager.Device(iface)
                device.cleanup_inactive_connections()

                self.assertEqual(1, sum(1 for _ in device.connections()))
示例#9
0
    def test_remove_all_non_active_connection_from_a_device(self):
        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics, con_count=3):

                device = networkmanager.Device(iface)
                device.cleanup_inactive_connections()

                self.assertEqual(1, sum(1 for _ in device.connections()))
示例#10
0
 def test_add_net_based_on_device_with_multiple_nm_connections(
         self, adapter, nic0):
     IPv4_ADDRESS = '192.0.2.1'
     NET = {NETWORK_NAME: {'bonding': self.iface, 'switch': self.switch}}
     with nmnettestlib.nm_connections(self.iface,
                                      IPv4_ADDRESS,
                                      con_count=3,
                                      slaves=[nic0]):
         with adapter.setupNetworks(NET, {}, NOCHK):
             adapter.assertNetwork(NETWORK_NAME, NET[NETWORK_NAME])
示例#11
0
    def test_delete_one_of_two_connections(self, nic0, nmd_bus):
        with nm_connections(IFACE, IPV4ADDR, slaves=(nic0, ),
                            con_count=2) as connames:

            con0 = self._get_connection(connames[0], nmd_bus)
            con0.delete()
            assert self._get_connection(connames[0], nmd_bus) is None

            con1 = self._get_connection(connames[1], nmd_bus)
            assert con1.connection.id == connames[1]
示例#12
0
    def test_active_connections_properties_vs_connection_settings(
            self, nic0, nmd_bus):
        with nm_connections(IFACE, IPV4ADDR, slaves=(nic0, )):
            for active_con in nmd_bus['active_cons'].connections():
                connection_path = active_con.con_path()
                settings_con = nmd_bus['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
示例#13
0
文件: nmdbus_test.py 项目: xin49/vdsm
    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)
示例#14
0
文件: nmdbus_test.py 项目: nirs/vdsm
    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)
示例#15
0
    def test_active_connections_properties_existence(self, nic0, nmd_bus):
        with nm_connections(IFACE, IPV4ADDR, slaves=(nic0, )):
            con_count = 0
            for connection in nmd_bus['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

            assert con_count > 0
示例#16
0
    def test_nm_connection_lifetime(self, nmd_bus):
        with dummy_device() as nic:
            with nm_connections(IFACE, IPV4ADDR, slaves=(nic, )):
                device = nmd_bus['device'].device(IFACE)
                device.syncoper.waitfor_activated_state()
                active_con_path = device.active_connection_path()
                active_con = nmd_bus['active_cons'].connection(active_con_path)

                assert str(active_con.type()) == TEST_LINK_TYPE
                active_state = nmtypes.NMActiveConnectionState.ACTIVATED
                assert active_con.state() == active_state

        self._assert_no_device(IFACE, nmd_bus['device'])
示例#17
0
文件: nmdbus_test.py 项目: xin49/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
示例#18
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
示例#19
0
文件: nmdbus_test.py 项目: xin49/vdsm
    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)
示例#20
0
文件: nmdbus_test.py 项目: nirs/vdsm
    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)
示例#21
0
文件: nmdbus_test.py 项目: nirs/vdsm
    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)
示例#22
0
文件: nmdbus_test.py 项目: xin49/vdsm
    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)
示例#23
0
    def _test_device_with_n_connections(self, con_count, nic, nmd_bus):
        configured_connections = set()
        active_connections = set()
        with nm_connections(IFACE,
                            IPV4ADDR,
                            slaves=(nic, ),
                            con_count=con_count):
            device = nmd_bus['device'].device(IFACE)
            for connection_path in device.connections_path():
                settings_con = nmd_bus['settings'].connection(connection_path)
                configured_connections.add(settings_con.connection.id)

            active_con = nmd_bus['active_cons'].connection(
                device.active_connection_path())
            active_connections.add(active_con.id())

        assert len(configured_connections) == con_count
        assert active_connections == {IFACE + '0'}
示例#24
0
    def test_device_attributes_existence(self, nic0, nmd_bus):
        device_count = 0
        with nm_connections(IFACE, IPV4ADDR, slaves=(nic0, )):
            for device in nmd_bus['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 = nmd_bus['settings'].connection(
                        connection_path)
                    assert settings_con.connection.uuid is not None

                device_count += 1

        assert device_count > 0
示例#25
0
文件: nmdbus_test.py 项目: nirs/vdsm
    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)
示例#26
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)
示例#27
0
文件: nm_test.py 项目: nirs/vdsm
    def test_detect_connection_based_on_ifcfg_file(self):
        """
        NM may use ifcfg files as its storage format for connections via the
        ifcfg-rh settings plugin.
        This is the default option under RHEL/Centos/Fedora.
        When a connection is defined, it is saved in an ifcfg file, however,
        the filename is not recorded in NM records.
        In some scenarios, it is useful look for the ifcfg filename based on
        a given connection or the other way around, looking for the connection
        given the filename.
        """
        iface = iface_name()
        with dummy_devices(1) as nics:
            with nm_connections(iface, IPV4ADDR, slaves=nics, con_count=3,
                                save=True):
                device = networkmanager.Device(iface)
                expected_uuids = {con.connection.uuid
                                  for con in device.connections()}

                actual_uuids = {networkmanager.ifcfg2connection(file)[0]
                                for file in self._ifcfg_files()}

                self.assertLessEqual(expected_uuids, actual_uuids)
示例#28
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)
示例#29
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)