X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FWriteModprobeConfig.py;h=b954c648b0397c8dd4033a52be2d47868b44eb1e;hb=926feb6af0dcdfd3348a3c8dc0bf27a936798505;hp=c0c8b2d1aaa592184a6d47817e77f0dead32941e;hpb=d8248892141f1d8d16f46d6c4f92ff13294c0e64;p=bootmanager.git diff --git a/source/steps/WriteModprobeConfig.py b/source/steps/WriteModprobeConfig.py index c0c8b2d..b954c64 100644 --- a/source/steps/WriteModprobeConfig.py +++ b/source/steps/WriteModprobeConfig.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 -u +#!/usr/bin/python # Copyright (c) 2003 Intel Corporation # All rights reserved. @@ -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,38 @@ def Run( vars, log, filename = "/etc/modprobe.conf"): if sysmods is None: raise BootManagerException, "Unable to get list of system modules." - eth_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 = os.listdir("/etc/modprobe.d") + 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 - - 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 - - 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 - - modulesconf_file.close() - modulesconf_file= None + for a_mod in sysmods[systeminfo.MODULE_CLASS_SCSI]: + 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]: + 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" ) @@ -88,7 +100,7 @@ def Run( vars, log, filename = "/etc/modprobe.conf"): if eth_count == 0: log.write( "\nIt appears we don't have any network drivers. Aborting.\n" ) - vars['BOOT_STATE']= 'failboot' + vars['RUN_LEVEL']= 'failboot' vars['STATE_CHANGE_NOTIFY']= 1 vars['STATE_CHANGE_NOTIFY_MESSAGE']= \ notify_messages.MSG_NO_DETECTED_NETWORK