3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
16 import notify_messages
19 def Run( vars, log, filename = "/etc/modprobe.conf"):
21 write out the system file /etc/modprobe.conf with the current
24 returns a tuple of the number of network driver lines and storage
25 driver lines written as (networkcount,storagecount)
28 # write out the modprobe.conf file for the system. make sure
29 # the order of the ethernet devices are listed in the same order
30 # as the boot cd loaded the modules. this is found in /tmp/loadedmodules
31 # ultimately, the order will only match the boot cd order if
32 # the kernel modules have the same name - which should be true for the later
33 # version boot cds because they use the same kernel version.
34 # older boot cds use a 2.4.19 kernel, and its possible some of the network
35 # module names have changed, in which case the system might not boot
36 # if the network modules are activated in a different order that the
39 # make sure we have this class loaded
42 SYSIMG_PATH= vars["SYSIMG_PATH"]
44 raise ValueError, "SYSIMG_PATH"
47 raise BootManagerException, "Missing variable in vars: %s\n" % var
48 except ValueError, var:
49 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
51 sysmods= systeminfo.get_system_modules(vars, log)
53 raise BootManagerException, "Unable to get list of system modules."
55 # parse the existing modprobe.conf file, if one exists
56 mfile = "%s/%s" % (SYSIMG_PATH,filename)
57 m = modprobe.Modprobe()
58 if os.path.exists(mfile):
61 blacklist = modprobe.Modprobe()
62 blacklistfiles = ("blacklist","blacklist-compat","blacklist-firewire")
63 for blf in blacklistfiles:
64 if os.path.exists("/etc/modprobe.d/%s"%blf):
65 blacklist.input("/etc/modprobe.d/%s"%blf)
68 m.optionsset("ata_generic","all_generic_ide=1")
70 for a_mod in sysmods[systeminfo.MODULE_CLASS_SCSI]:
71 if m.blacklistget(a_mod) <> None or \
72 blacklist.blacklistget(a_mod) <> None:
74 m.aliasset("scsi_hostadapter%d"%scsi_count,a_mod)
75 scsi_count= scsi_count + 1
79 for a_mod in sysmods[systeminfo.MODULE_CLASS_NETWORK]:
80 if m.blacklistget(a_mod) <> None or \
81 blacklist.blacklistget(a_mod) <> None:
83 m.aliasset("eth%d"%eth_count,a_mod)
84 eth_count= eth_count + 1
85 m.output(mfile, "BootManager")
86 m.output("%s.bak"%mfile, "BootManager") # write a backup version of this file
88 # dump the modprobe.conf file to the log (not to screen)
89 log.write( "Contents of new modprobe.conf file:\n" )
90 modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "r" )
91 contents= modulesconf_file.read()
92 log.write( contents + "\n" )
93 modulesconf_file.close()
94 modulesconf_file= None
95 log.write( "End contents of new modprobe.conf file.\n" )
97 # before we do the real kexec, check to see if we had any
98 # network drivers written to modprobe.conf. if not, return -1,
99 # which will cause this node to be switched to a debug state.
101 log.write( "\nIt appears we don't have any network drivers. Aborting.\n" )
103 vars['RUN_LEVEL']= 'failboot'
104 vars['STATE_CHANGE_NOTIFY']= 1
105 vars['STATE_CHANGE_NOTIFY_MESSAGE']= \
106 notify_messages.MSG_NO_DETECTED_NETWORK
107 raise BootManagerException, \
108 notify_messages.MSG_NO_DETECTED_NETWORK