コード例 #1
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)
コード例 #2
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
コード例 #3
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()))
コード例 #4
0
ファイル: ifcfg_acquire.py プロジェクト: xiaojiongming/vdsm
    def acquire_device(device):
        try:
            dev = networkmanager.Device(device)
        except NMDeviceNotFoundError:
            return

        dev.cleanup_inactive_connections()

        active_connection = dev.active_connection
        if not active_connection:
            return

        fpath = IfcfgAcquireNMonline._ifcfg_file_lookup(active_connection.uuid)
        if fpath:
            os.rename(fpath, NET_CONF_PREF + device)
コード例 #5
0
ファイル: ifcfg_acquire.py プロジェクト: xin49/vdsm
    def acquire_device(device):
        try:
            dev = networkmanager.Device(device)
            dev.syncoper.waitfor_activated_state()
            dev.cleanup_inactive_connections()
            active_connection = dev.active_connection
        except (nmerrors.NMDeviceNotFoundError,
                nmerrors.NMPropertiesNotFoundError, nmerrors.NMTimeoutError):
            return

        if not active_connection:
            return

        con_uuid = active_connection.uuid()
        fpath = IfcfgAcquireNMonline._ifcfg_file_lookup(con_uuid)
        if fpath:
            os.rename(fpath, NET_CONF_PREF + device)