summaryrefslogtreecommitdiffstats
path: root/network.py
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-10-05 17:33:13 -1000
committerRadek Vykydal <rvykydal@redhat.com>2009-10-06 18:00:55 +0200
commit0ba6cb516da384e30efdd0dbd70a6c12336fd4f5 (patch)
treee28e800117f7b55c9235690cb6126d42d8011258 /network.py
parentcf5051bc2e5595fe3f5bac22b5ab6fe2d0a54eb0 (diff)
downloadanaconda-0ba6cb516da384e30efdd0dbd70a6c12336fd4f5.tar.gz
anaconda-0ba6cb516da384e30efdd0dbd70a6c12336fd4f5.tar.xz
anaconda-0ba6cb516da384e30efdd0dbd70a6c12336fd4f5.zip
Take 70-persistent-net.rules generated at installation (#526322)
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).
Diffstat (limited to 'network.py')
-rw-r--r--network.py54
1 files changed, 30 insertions, 24 deletions
diff --git a/network.py b/network.py
index 4b5ef5b94..d4c13e9b3 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