-
- log.write( "Writing network configuration\n" )
- write_network_configuration( vars, log )
-
- # write out the modprobe.conf file for the system. make sure
- # the order of the ethernet devices are listed in the same order
- # as the boot cd loaded the modules. this is found in /tmp/loadedmodules
- # ultimately, the order will only match the boot cd order if
- # the kernel modules have the same name - which should be true for the later
- # version boot cds because they use the same kernel version.
- # older boot cds use a 2.4.19 kernel, and its possible some of the network
- # module names have changed, in which case the system might not boot
- # if the network modules are activated in a different order that the
- # boot cd.
- log.write( "Writing /etc/modprobe.conf\n" )
-
- sysinfo= systeminfo()
- sysmods= sysinfo.get_system_modules(SYSIMG_PATH)
- if sysmods is None:
- raise BootManagerException, "Unable to get list of system modules."
-
- eth_count= 0
- scsi_count= 0
-
- modulesconf_file= file("%s/etc/modprobe.conf" % SYSIMG_PATH, "w" )
-
- for type in sysmods:
- if type == sysinfo.MODULE_CLASS_SCSI:
- for a_mod in sysmods[type]:
- if scsi_count == 0:
- modulesconf_file.write( "alias scsi_hostadapter %s\n" %
- a_mod )
- else:
- modulesconf_file.write( "alias scsi_hostadapter%d %s\n" %
- (scsi_count,a_mod) )
- scsi_count= scsi_count + 1
-
- elif type == sysinfo.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
-
-
- # dump the modprobe.conf file to the log (not to screen)
- log.write( "Contents of new modprobe.conf file:\n" )
- modulesconf_file= file("%s/etc/modprobe.conf" % SYSIMG_PATH, "r" )
- contents= modulesconf_file.read()
- log.write( contents + "\n" )
- modulesconf_file.close()
- modulesconf_file= None
- log.write( "End contents of new modprobe.conf file.\n" )
-
- log.write( "Writing system /etc/fstab\n" )
- fstab= file( "%s/etc/fstab" % SYSIMG_PATH, "w" )
- fstab.write( "%s none swap sw 0 0\n" % \
- PARTITIONS["mapper-swap"] )
- fstab.write( "%s / ext3 defaults 0 0\n" % \
- PARTITIONS["mapper-root"] )
- fstab.write( "%s /vservers ext3 tagxid,defaults 0 0\n" % \
- PARTITIONS["mapper-vservers"] )
- fstab.write( "none /proc proc defaults 0 0\n" )
- fstab.write( "none /dev/shm tmpfs defaults 0 0\n" )
- fstab.write( "none /dev/pts devpts defaults 0 0\n" )
- fstab.write( "none /rcfs rcfs defaults 0 0\n" )
- fstab.close()
-
-
- log.write( "Writing system /etc/issue\n" )
- issue= file( "%s/etc/issue" % SYSIMG_PATH, "w" )
- issue.write( "PlanetLab Node: \\n\n" )
- issue.write( "Kernel \\r on an \\m\n" )
- issue.write( "http://www.planet-lab.org\n\n" )
- issue.close()
-
- log.write( "Setting up authentication (non-ssh)\n" )
- utils.sysexec( "chroot %s authconfig --nostart --kickstart --enablemd5 " \
- "--enableshadow" % SYSIMG_PATH, log )
- utils.sysexec( "sed -e 's/^root\:\:/root\:*\:/g' " \
- "%s/etc/shadow > %s/etc/shadow.new" % \
- (SYSIMG_PATH,SYSIMG_PATH), log )
- utils.sysexec( "chroot %s mv " \
- "/etc/shadow.new /etc/shadow" % SYSIMG_PATH, log )
- utils.sysexec( "chroot %s chmod 400 /etc/shadow" % SYSIMG_PATH, log )
+ log.write("Writing system /etc/fstab\n")
+ with open("{}/etc/fstab".format(SYSIMG_PATH), "w") as fstab:
+ fstab.write("{} none swap sw 0 0\n"\
+ .format(PARTITIONS["swap"]))
+ fstab.write("{} / ext3 defaults 1 1\n"\
+ .format(PARTITIONS["root"]))
+ if (vars['ONE_PARTITION'] != '1'):
+ if vars['virt'] == 'vs':
+ fstab.write("{} /vservers ext3 tagxid,defaults 1 2\n"\
+ .format(PARTITIONS["vservers"]))
+ else:
+ fstab.write("{} /vservers btrfs defaults 1 2\n"\
+ .format(PARTITIONS["vservers"]))
+ fstab.write("none /proc proc defaults 0 0\n")
+ fstab.write("none /dev/shm tmpfs defaults 0 0\n")
+ fstab.write("none /dev/pts devpts defaults 0 0\n")
+
+ log.write("Writing system /etc/issue\n")
+ with open("{}/etc/issue".format(SYSIMG_PATH), "w") as issue:
+ issue.write("PlanetLab Node: \\n\n")
+ issue.write("Kernel \\r on an \\m\n")
+ issue.write("http://www.planet-lab.org\n\n")
+
+ if (vars['ONE_PARTITION'] != '1'):
+ log.write("Setting up authentication (non-ssh)\n")
+ utils.sysexec_chroot(SYSIMG_PATH, "authconfig --nostart --kickstart --enablemd5 " \
+ "--enableshadow", log)
+ utils.sysexec("sed -e 's/^root\:\:/root\:*\:/g' " \
+ "{}/etc/shadow > {}/etc/shadow.new".format(SYSIMG_PATH, SYSIMG_PATH), log)
+ utils.sysexec_chroot(SYSIMG_PATH, "mv " \
+ "/etc/shadow.new /etc/shadow", log)
+ utils.sysexec_chroot(SYSIMG_PATH, "chmod 400 /etc/shadow", log)