3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
16 import notify_messages
18 def Run( vars, log, filename = "/etc/modprobe.conf"):
20 write out the system file /etc/modprobe.conf with the current
23 returns a tuple of the number of network driver lines and storage
24 driver lines written as (networkcount,storagecount)
27 # write out the modprobe.conf file for the system. make sure
28 # the order of the ethernet devices are listed in the same order
29 # as the boot cd loaded the modules. this is found in /tmp/loadedmodules
30 # ultimately, the order will only match the boot cd order if
31 # the kernel modules have the same name - which should be true for the later
32 # version boot cds because they use the same kernel version.
33 # older boot cds use a 2.4.19 kernel, and its possible some of the network
34 # module names have changed, in which case the system might not boot
35 # if the network modules are activated in a different order that the
38 # make sure we have this class loaded
41 SYSIMG_PATH= vars["SYSIMG_PATH"]
43 raise ValueError, "SYSIMG_PATH"
46 raise BootManagerException, "Missing variable in vars: %s\n" % var
47 except ValueError, var:
48 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
50 sysmods= systeminfo.get_system_modules(vars, log)
52 raise BootManagerException, "Unable to get list of system modules."
54 modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "w" )
55 modulesconf_file.write("options ata_generic all_generic_ide=1\n")
57 # MEF: I am not sure this is the proper thing to do if there are
58 # two completely different scsi_hostadapter. I think its ok, but
59 # it seems rather arbitrary.
61 for a_mod in sysmods[systeminfo.MODULE_CLASS_SCSI]:
62 line="alias scsi_hostadapter%d %s\n" % (count,a_mod)
63 modulesconf_file.write(line)
66 # This should involve looking at the NodeNetworks associated with
67 # this node and matching on their ethernet address. Barring that
68 # information order the remaining ethX numbering according to PCI
69 # enumeration order. This should be integrated with
70 # WriteNetworkConfig and integrate. For now lets just comment out
71 # the 'alias ethX a_mod' lines in modprobe.conf
73 for a_mod in sysmods[systeminfo.MODULE_CLASS_NETWORK]:
74 line="alias eth%d %s # Want to comment this out in the future.\n" % (count,a_mod)
75 modulesconf_file.write(line)
78 modulesconf_file.close()
79 modulesconf_file= None
81 # dump the modprobe.conf file to the log (not to screen)
82 log.write( "Contents of new modprobe.conf file:\n" )
83 modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "r" )
84 contents= modulesconf_file.read()
85 log.write( contents + "\n" )
86 modulesconf_file.close()
87 modulesconf_file= None
88 log.write( "End contents of new modprobe.conf file.\n" )
90 # before we do the real kexec, check to see if we had any
91 # network drivers written to modprobe.conf. if not, return -1,
92 # which will cause this node to be switched to a debug state.
93 scsi_count=len(sysmods[systeminfo.MODULE_CLASS_SCSI])
94 eth_count=len(sysmods[systeminfo.MODULE_CLASS_NETWORK])
96 log.write( "\nIt appears we don't have any network drivers. Aborting.\n" )
98 vars['BOOT_STATE']= 'failboot'
99 vars['STATE_CHANGE_NOTIFY']= 1
100 vars['STATE_CHANGE_NOTIFY_MESSAGE']= \
101 notify_messages.MSG_NO_DETECTED_NETWORK
102 raise BootManagerException, \
103 notify_messages.MSG_NO_DETECTED_NETWORK