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."
57 modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "w" )
60 if type == systeminfo.MODULE_CLASS_SCSI:
61 for a_mod in sysmods[type]:
63 modulesconf_file.write( "alias scsi_hostadapter %s\n" %
66 modulesconf_file.write( "alias scsi_hostadapter%d %s\n" %
68 scsi_count= scsi_count + 1
70 elif type == systeminfo.MODULE_CLASS_NETWORK:
71 for a_mod in sysmods[type]:
72 modulesconf_file.write( "alias eth%d %s\n" %
74 eth_count= eth_count + 1
76 modulesconf_file.close()
77 modulesconf_file= None
79 # dump the modprobe.conf file to the log (not to screen)
80 log.write( "Contents of new modprobe.conf file:\n" )
81 modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "r" )
82 contents= modulesconf_file.read()
83 log.write( contents + "\n" )
84 modulesconf_file.close()
85 modulesconf_file= None
86 log.write( "End contents of new modprobe.conf file.\n" )
88 # before we do the real kexec, check to see if we had any
89 # network drivers written to modprobe.conf. if not, return -1,
90 # which will cause this node to be switched to a debug state.
92 log.write( "\nIt appears we don't have any network drivers. Aborting.\n" )
94 vars['BOOT_STATE']= 'dbg'
95 vars['STATE_CHANGE_NOTIFY']= 1
96 vars['STATE_CHANGE_NOTIFY_MESSAGE']= \
97 notify_messages.MSG_NO_DETECTED_NETWORK
98 raise BootManagerException, \
99 notify_messages.MSG_NO_DETECTED_NETWORK