[PATCH f17-branch 3/4] Create default ifcfg-* for each interface (#804504, #804716)

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

 



Loader used to create a default ifcfg-* file for each unused network
interface, containing DEVICE, HWADDR, UUID, BOOTPROTO=dhcp, etc.

Network.update() populated self.netdevices by reading those files,
*skipping any interface that lacked that file*, which caused the vnc
traceback in bug #804504.

And without BOOTPROTO=dhcp, "ifup $dev" didn't work post-install, which
caused #804716.

(Personally I think "ifup" should fall back to the same defaults as
NetworkManager rather than making us write the defaults to a file, but
we'll save that for later.)
---
 pyanaconda/network.py |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 067f3b1..40026a9 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -242,6 +242,28 @@ class NetworkDevice(IfcfgFile):
 
         return s
 
+    # anaconda doesn't actually need this configuration, but if we don't write
+    # it to the installed system then 'ifup' doesn't work after install.
+    # FIXME: make 'ifup' use its own defaults!
+    def setDefaultConfig(self):
+        ifcfglog.debug("NetworkDevice %s: setDefaultConfig()" % self.iface)
+        self.set(("DEVICE", self.iface),
+                 ("BOOTPROTO", "dhcp"),
+                 ("ONBOOT", "no")) # for "security", or something
+
+        try:
+            mac = open("/sys/class/net/%s/address" % self.iface).read().strip()
+            self.set(("HWADDR", mac.upper()))
+        except IOError as e:
+            ifcfglog.warning("HWADDR: %s" % str(e))
+
+        try:
+            uuid = open("/proc/sys/kernel/random/uuid").read().strip()
+            self.set(("UUID", uuid))
+        except IOError as e:
+            ifcfglog.warning("UUID: %s" % str(e))
+
+        self.writeIfcfgFile()
 
     def loadIfcfgFile(self):
         ifcfglog.debug("%s:\n%s" % (self.path, self.fileContent()))
@@ -311,6 +333,8 @@ class NetworkDevice(IfcfgFile):
         shutil.move(newifcfg, keyfile)
 
     def fileContent(self):
+        if not os.path.exists(self.path):
+            return ""
         f = open(self.path, 'r')
         content = f.read()
         f.close()
@@ -422,9 +446,7 @@ class Network:
                 if os.access(device.path, os.R_OK):
                     device.loadIfcfgFile()
                 else:
-                    log.info("Network.update(): %s file not found" %
-                             device.path)
-                    continue
+                    device.setDefaultConfig()
 
             # TODORV - the last iface in loop wins, might be ok,
             #          not worthy of special juggling
-- 
1.7.7.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