[PATCH 1/4] networking: write configuration in doInstall

Radek Vykydal rvykydal at redhat.com
Thu Jul 26 08:37:46 UTC 2012

Short story:

Still just copying ifcfg files from installer environment to
system, not actually generating them from ksdata in this patch.


Ifcfg files are copied from installer environment instead of generating
from ksdata[1]. Using nm-c-e, the configuration is applied directly to ifcfg
files so doing

write ifcfg (in dracut based on boot options or ks, or nm-c-e GUI)
-> update ksdata (in spoke's apply)
-> write ifcfg (in doInstall)

is not necessary. Currently we are creating ifcfg files in dracut (based on
boot options, and for kickstart) and in anaconda where we are creating only
missing default ifcfg files[2].

I am not against considering going through ifcfg -> ksdata -> ifcfg[3],
be it for consistency with other spokes/modules. or we may come to point
where we actually need to do it. It will require some thinking though.

We have been doing pre-NM-run ksdata -> ifcfg direction[4].
Ifcfg -> ksdata is implemented in basic form in spoke.apply but ksdata, as
mentioned before, it is not actually used yet in this patchset. We'd need to
consider where to sync ifcfg files created by dracut (or anaconda) with
ksdata[5], and if/how we need to update our ks network command. I am afraid of
storing complete network configuration doable with nm-c-e (wireless
credentials, routing) in ksdata and have fairly strong gut feeling against
doing ifcfg -> ksdata -> ifcfg. It means we need to keep up with what nm-c-e
starts to support and lost something we could get for free from nm-c-e.

[1] We also copy /etc/sysconfig/network-scripts/keys-<device>
files. We might want to copy also routing files created in nm-c-e.

[2] this should go to dracut IMO.

[3] Actually this would be the chain:

    dracut writes ifcfg
    NM can update ifcfg when activating device
    (? does anaconda need to updates ksdata ?)
    nm-c-e modifies ifcfg files (GUI configuration)
    anaconda stores ifcfg to ksdata (spoke.apply)
    anaconda dumps ksdata to ifcfg on /mnt/sysimage (doInstall)

[4] Note that NM updates the ifcfg file created by us
    after parsing it for the first time

[5] __init__ of NetworkStandaloneSpoke as I do it for hostname in one
    of following patches or some pre-GUI initialization
 pyanaconda/install.py |    3 +++
 pyanaconda/network.py |   11 +++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/pyanaconda/install.py b/pyanaconda/install.py
index be31e75..45a659a 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -25,6 +25,7 @@ from pyanaconda.storage import turnOnFilesystems
 from pyanaconda.bootloader import writeBootLoader
 from pyanaconda.progress import progress_report
 from pyanaconda.users import createLuserConf, Users
+from pyanaconda.network import writeNetworkConf
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
@@ -78,6 +79,8 @@ def doInstall(storage, payload, ksdata, instClass):
     ksdata.services.execute(storage, ksdata, instClass)
     ksdata.keyboard.execute(storage, ksdata, instClass)
+    writeNetworkConf(storage, instClass)
     # Creating users and groups requires some pre-configuration.
     u = Users()
     createLuserConf(ROOT_PATH, algoname=u.getPassAlgo(ksdata.authconfig.authconfig))
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 22025ff..639657a 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -716,6 +716,7 @@ def _copyIfcfgFiles(destPath):
             srcfile = os.path.join(netscriptsDir, cfgFile)
             _copyFileToPath(srcfile, destPath)
+# TODO: routing info from /etc/sysconfig/network-scripts?
 def copyConfigToPath(destPath):
     if flags.imageInstall:
         # for image installs we only want to write out
@@ -892,3 +893,13 @@ def usedByRootOnISCSI(iface, storage):
                 return True
     return False
+def writeNetworkConf(storage, instClass):
+    write_sysconfig_network()
+    disableIPV6()
+    copyConfigToPath(ROOT_PATH)
+    # TODO the default for ONBOOT needs to be lay down
+    # before newui we didn't set it for kickstart installs
+    instClass.setNetworkOnbootDefault()
+    disableNMForStorageDevices(storage)
+    autostartFCoEDevices(storage)

More information about the anaconda-patches mailing list