From: Marc Fiuczynski Date: Tue, 24 Feb 2009 21:40:57 +0000 (+0000) Subject: Updated to use modprobe module to update an existing /etc/modprobe.conf file rather... X-Git-Tag: BootManager-3.2-17~5 X-Git-Url: http://git.onelab.eu/?p=bootmanager.git;a=commitdiff_plain;h=eeb51fbb76d4850362b0b2f0e7c359adda6f3208 Updated to use modprobe module to update an existing /etc/modprobe.conf file rather than blowing it away. --- diff --git a/source/steps/WriteModprobeConfig.py b/source/steps/WriteModprobeConfig.py index a9b0d2a..bb8cb2f 100644 --- a/source/steps/WriteModprobeConfig.py +++ b/source/steps/WriteModprobeConfig.py @@ -14,6 +14,7 @@ import systeminfo import BootAPI import ModelOptions import notify_messages +import modprobe def Run( vars, log, filename = "/etc/modprobe.conf"): """ @@ -51,27 +52,28 @@ def Run( vars, log, filename = "/etc/modprobe.conf"): if sysmods is None: raise BootManagerException, "Unable to get list of system modules." - eth_count= 0 - scsi_count= 0 - - modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "w" ) - modulesconf_file.write("options ata_generic all_generic_ide=1\n") - - for type in sysmods: - if type == systeminfo.MODULE_CLASS_SCSI: - for a_mod in sysmods[type]: - modulesconf_file.write( "alias scsi_hostadapter%d %s\n" % - (scsi_count,a_mod) ) - scsi_count= scsi_count + 1 + # parse the existing modprobe.conf file, if one exists + mfile = "%s/%s" % (SYSIMG_PATH,filename) + m = modprobe.Modprobe(mfile) + try: + m.input(mfile) + except: + pass - elif type == systeminfo.MODULE_CLASS_NETWORK: - for a_mod in sysmods[type]: - modulesconf_file.write( "alias eth%d %s\n" % - (eth_count,a_mod) ) - eth_count= eth_count + 1 + # storage devices + m.optionsset("ata_generic","all_generic_ide=1") + scsi_count= 0 + for a_mod in sysmods[systeminfo.MODULE_CLASS_SCSI]: + m.aliasset("scsi_hostadapter%d"%scsi_count,a_mod) + scsi_count= scsi_count + 1 - modulesconf_file.close() - modulesconf_file= None + # network devices + eth_count= 0 + for a_mod in sysmods[systeminfo.MODULE_CLASS_NETWORK]: + m.aliasset("eth%d"%eth_count,a_mod) + eth_count= eth_count + 1 + m.output(mfile, "BootManager") + m.output("%s.bak"%mfile, "BootManager") # write a backup version of this file # dump the modprobe.conf file to the log (not to screen) log.write( "Contents of new modprobe.conf file:\n" )