[PATCH] Take 70-persistent-net.rules generated at installation (#526322)

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

 



Discovered on s390x, but really affects all platforms.  I've done test
installs of RHEL-6 on s390x and of rawhide on x86_64 with this patch in
place and 70-persistent-net.rules looks correct on the target system
after installation.

The problem on s390x was we needed to use the KERNELS setting for the
line in the rules file, but on other platforms we don't need that.
Since /lib/udev/write_net_rules is kicked off during installation, copy
/etc/udev/rules.d/70-persistent-net.rules from the installation
environment to the target system.  If we don't have that file in the
installation environment, just do what we have been doing (which should
take care of the instances where people are doing kickstart installs
with multiple network lines but onboot is set to no).
---
 network.py |   54 ++++++++++++++++++++++++++++++------------------------
 1 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/network.py b/network.py
index 4b5ef5b..d4c13e9 100644
--- a/network.py
+++ b/network.py
@@ -725,40 +725,46 @@ class Network:
                 f.close()
 
         # /etc/udev/rules.d/70-persistent-net.rules
-        rules = instPath + "/etc/udev/rules.d/70-persistent-net.rules"
-        if (not instPath) or (not os.path.isfile(rules)) or flags.livecdInstall:
+        rules = "/etc/udev/rules.d/70-persistent-net.rules"
+        destRules = instPath + rules
+        if (not instPath) or (not os.path.isfile(destRules)) or \
+           flags.livecdInstall:
             if not os.path.isdir("%s/etc/udev/rules.d" %(instPath,)):
                 iutil.mkdirChain("%s/etc/udev/rules.d" %(instPath,))
 
-            f = open(rules, "w")
-            f.write("""
+            if os.path.isfile(rules):
+                shutil.copy(rules, destRules)
+            else:
+                f = open(destRules, "w")
+                f.write("""
 # This file was automatically generated by the /lib/udev/write_net_rules
 # program run by the persistent-net-generator.rules rules file.
 #
 # You can modify it, as long as you keep each rule on a single line.
 
 """)
-            for dev in self.netdevices.values():
-                addr = dev.get("HWADDR")
-                if not addr:
-                    continue
-                devname = dev.get("DEVICE")
-                basename = devname
-                while basename != "" and basename[-1] in string.digits:
-                    basename = basename[:-1]
+                for dev in self.netdevices.values():
+                    addr = dev.get("HWADDR")
+                    if not addr:
+                        continue
+                    devname = dev.get("DEVICE")
+                    basename = devname
+                    while basename != "" and basename[-1] in string.digits:
+                        basename = basename[:-1]
+
+                    # rules are case senstive for address. Lame.
+                    addr = addr.lower()
+
+                    s = ""
+                    if len(dev.get("DESC")) > 0:
+                        s = "# %s (rule written by anaconda)\n" % (dev.get("DESC"),)
+                    else:
+                        s = "# %s (rule written by anaconda)\n" % (devname,)
+                        s = s + 'SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", KERNEL=="%s*", NAME="%s"\n' % (addr, basename, devname,)
+
+                    f.write(s)
 
-                # rules are case senstive for address. Lame.
-                addr = addr.lower()
-
-                s = ""
-                if len(dev.get("DESC")) > 0:
-                    s = "# %s (rule written by anaconda)\n" % (dev.get("DESC"),)
-                else:
-                    s = "# %s (rule written by anaconda)\n" % (devname,)
-                s = s + 'SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS=="?*", ATTR{address}=="%s", ATTR{type}=="1", KERNEL=="%s*", NAME="%s"\n' % (addr, basename, devname)
-                f.write(s)
-
-            f.close()
+                f.close()
 
     # write out current configuration state and wait for NetworkManager
     # to bring the device up, watch NM state and return to the caller
-- 
1.6.2.5

_______________________________________________
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