3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
11 from Exceptions import *
17 def Run( vars, log, filename = "/etc/modprobe.conf"):
19 write out the system file /etc/modprobe.conf with the current
22 returns a tuple of the number of network driver lines and storage
23 driver lines written as (networkcount,storagecount)
26 # write out the modprobe.conf file for the system. make sure
27 # the order of the ethernet devices are listed in the same order
28 # as the boot cd loaded the modules. this is found in /tmp/loadedmodules
29 # ultimately, the order will only match the boot cd order if
30 # the kernel modules have the same name - which should be true for the later
31 # version boot cds because they use the same kernel version.
32 # older boot cds use a 2.4.19 kernel, and its possible some of the network
33 # module names have changed, in which case the system might not boot
34 # if the network modules are activated in a different order that the
37 # make sure we have this class loaded
40 SYSIMG_PATH= vars["SYSIMG_PATH"]
42 raise ValueError, "SYSIMG_PATH"
45 raise BootManagerException, "Missing variable in vars: %s\n" % var
46 except ValueError, var:
47 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
49 sysmods= systeminfo.get_system_modules(vars, log)
51 raise BootManagerException, "Unable to get list of system modules."
56 modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "w" )
59 if type == systeminfo.MODULE_CLASS_SCSI:
60 for a_mod in sysmods[type]:
62 modulesconf_file.write( "alias scsi_hostadapter %s\n" %
65 modulesconf_file.write( "alias scsi_hostadapter%d %s\n" %
67 scsi_count= scsi_count + 1
69 elif type == systeminfo.MODULE_CLASS_NETWORK:
70 for a_mod in sysmods[type]:
71 modulesconf_file.write( "alias eth%d %s\n" %
73 eth_count= eth_count + 1
75 modulesconf_file.close()
76 modulesconf_file= None
78 # dump the modprobe.conf file to the log (not to screen)
79 log.write( "Contents of new modprobe.conf file:\n" )
80 modulesconf_file= file("%s/%s" % (SYSIMG_PATH,filename), "r" )
81 contents= modulesconf_file.read()
82 log.write( contents + "\n" )
83 modulesconf_file.close()
84 modulesconf_file= None
85 log.write( "End contents of new modprobe.conf file.\n" )
87 # before we do the real kexec, check to see if we had any
88 # network drivers written to modprobe.conf. if not, return -1,
89 # which will cause this node to be switched to a debug state.
91 log.write( "\nIt appears we don't have any network drivers. Aborting.\n" )
93 vars['BOOT_STATE']= 'dbg'
94 vars['STATE_CHANGE_NOTIFY']= 1
95 vars['STATE_CHANGE_NOTIFY_MESSAGE']= \
96 notify_messages.MSG_NO_DETECTED_NETWORK
97 raise BootManagerException, \
98 notify_messages.MSG_NO_DETECTED_NETWORK