From d4ad6286fa4ee86e6f60c18761df8828e15a375e Mon Sep 17 00:00:00 2001 From: Marc Fiuczynski Date: Wed, 15 Apr 2009 18:26:11 +0000 Subject: [PATCH] Uses modprobe to write out /etc/modprobe.conf properly --- source/steps/WriteModprobeConfig.py | 58 +++++++++++++++-------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/source/steps/WriteModprobeConfig.py b/source/steps/WriteModprobeConfig.py index 9549c08..63347ef 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,33 +52,38 @@ def Run( vars, log, filename = "/etc/modprobe.conf"): if sysmods is None: raise BootManagerException, "Unable to get list of system modules." - modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "w" ) - modulesconf_file.write("options ata_generic all_generic_ide=1\n") - - # MEF: I am not sure this is the proper thing to do if there are - # two completely different scsi_hostadapter. I think its ok, but - # it seems rather arbitrary. - count=0 + # parse the existing modprobe.conf file, if one exists + mfile = "%s/%s" % (SYSIMG_PATH,filename) + m = modprobe.Modprobe() + if os.path.exists(mfile): + m.input(mfile) + + blacklist = modprobe.Modprobe() + blacklistfiles = ("blacklist","blacklist-compat","blacklist-firewire") + for blf in blacklistfiles: + if os.path.exists("/etc/modprobe.d/%s"%blf): + blacklist.input("/etc/modprobe.d/%s"%blf) + + # storage devices + m.optionsset("ata_generic","all_generic_ide=1") + scsi_count= 0 for a_mod in sysmods[systeminfo.MODULE_CLASS_SCSI]: - line="alias scsi_hostadapter%d %s\n" % (count,a_mod) - modulesconf_file.write(line) - count=count+1 - - # This should involve looking at the NodeNetworks associated with - # this node and matching on their ethernet address. Barring that - # information order the remaining ethX numbering according to PCI - # enumeration order. This should be integrated with - # WriteNetworkConfig and integrate. For now lets just comment out - # the 'alias ethX a_mod' lines in modprobe.conf - count=0 + if m.blacklistget(a_mod) <> None or \ + blacklist.blacklistget(a_mod) <> None: + continue + m.aliasset("scsi_hostadapter%d"%scsi_count,a_mod) + scsi_count= scsi_count + 1 + + # network devices + eth_count= 0 for a_mod in sysmods[systeminfo.MODULE_CLASS_NETWORK]: - line="# Want to comment this out in the future.\n" - line+="alias eth%d %s\n" % (count,a_mod) - modulesconf_file.write(line) - count=count+1 - - modulesconf_file.close() - modulesconf_file= None + if m.blacklistget(a_mod) <> None or \ + blacklist.blacklistget(a_mod) <> None: + continue + 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" ) @@ -91,8 +97,6 @@ def Run( vars, log, filename = "/etc/modprobe.conf"): # before we do the real kexec, check to see if we had any # network drivers written to modprobe.conf. if not, return -1, # which will cause this node to be switched to a debug state. - scsi_count=len(sysmods[systeminfo.MODULE_CLASS_SCSI]) - eth_count=len(sysmods[systeminfo.MODULE_CLASS_NETWORK]) if eth_count == 0: log.write( "\nIt appears we don't have any network drivers. Aborting.\n" ) -- 2.43.0