Re: [PATCH] Fix selection of alternative iface in UI after fail (#507084).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 14 Jul 2009, Radek Vykydal wrote:

Make ifcfg configuration files getting parsed properly after update.  The used
inotify configuration update mechanism (ifcfg-rh NM plugin) requires 1) writing
of new files out of /etc/sysconfig/network-scripts dir so that it doesn't
trigger parsing of the file too early (before all is written), and more
importantly, 2) removing of the old files before moving the new ones in so that
the new file gets parsed and the respective connection gets re-read and
eventually activated.

Also make sure that only device selected in UI has ONBOOT set to yes
in case of selection of another device after fail.
---
iw/netconfig_dialog.py |    8 ++++++--
network.py             |    7 ++++++-
2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/iw/netconfig_dialog.py b/iw/netconfig_dialog.py
index 29afc0e..ea59613 100644
--- a/iw/netconfig_dialog.py
+++ b/iw/netconfig_dialog.py
@@ -226,8 +226,12 @@ class NetworkConfigurator:
        combo = self.xml.get_widget("interfaceCombo")
        active = combo.get_active_iter()
        val = combo.get_model().get_value(active, 1)
-        netdev = self.network.available()[val]
-        netdev.set(('ONBOOT', 'yes'))
+        for v, dev in self.network.available().items():
+            if v == val:
+                dev.set(('ONBOOT', 'yes'))
+                netdev = dev
+            else:
+                dev.set(('ONBOOT', 'no'))

        # FIXME: need to do input validation
        if self.xml.get_widget("dhcpCheckbutton").get_active():
diff --git a/network.py b/network.py
index f597c9d..9a8d7d2 100644
--- a/network.py
+++ b/network.py
@@ -538,7 +538,7 @@ class Network:
            ipv6autoconf = dev.get('IPV6_AUTOCONF').lower()
            dhcpv6c = dev.get('DHCPV6C').lower()

-            newifcfg = "%s/ifcfg-%s.new" % (netscripts, device,)
+            newifcfg = "/tmp/ifcfg-%s.new" % (device,)
            f = open(newifcfg, "w")
            if len(dev.get("DESC")) > 0:
                f.write("# %s\n" % (dev.get("DESC"),))
@@ -596,6 +596,11 @@ class Network:

            # move the new ifcfg in place
            destcfg = "%s/ifcfg-%s" % (netscripts, device,)
+            try:
+                os.remove(destcfg)
+            except OSError as e:
+                if e.errno != 2:
+                    raise
            shutil.move(newifcfg, destcfg)

            # XXX: is this necessary with NetworkManager?


This looks fine to me.  I guess the ifcfg-rh plugin for NM reads everything in
/etc/sysconfig/network-scripts, so we need to write things to another
directory.  Oh well.

- -- David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpg1+0ACgkQ5hsjjIy1VkmC7QCg1NdjF1UEanCaoUn0NueQmlVt
zBYAn0710r7b2btWu6/j+BzFS/GTOr/z
=TfXd
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux