[PATCH rhel6-branch] Don't overwrite 70-persistent-net.rules (#597625)

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

 



I accidentally dropped commit f62ac02d6923230e7cf501d3db24c07f14791e6b
during nm-c-e integration.
---
 network.py |   41 +++++++++++++++++++++--------------------
 1 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/network.py b/network.py
index 8b0d109..531ba9d 100644
--- a/network.py
+++ b/network.py
@@ -653,36 +653,37 @@ class Network:
 
         # /etc/udev/rules.d/70-persistent-net.rules
         rules = "/etc/udev/rules.d/70-persistent-net.rules"
-        f = open(rules, "w")
-        f.write("""
+        if not os.path.isfile(rules):
+            f = open(rules, "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()
+                # rules are case senstive for address. Lame.
+                addr = addr.lower()
 
-            s = ""
-            if len(dev.description) > 0:
-                s = "# %s (rule written by anaconda)\n" % (dev.description,)
-            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,)
+                s = ""
+                if len(dev.description) > 0:
+                    s = "# %s (rule written by anaconda)\n" % (dev.description,)
+                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.write(s)
 
-        f.close()
+            f.close()
 
     def waitForDevicesActivation(self, devices):
         waited_devs_props = {}
-- 
1.6.0.6

_______________________________________________
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