X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FValidateNodeInstall.py;h=8ff7645d9522ec257cc0e0c656a7f4730707081b;hb=b278a18c073f5c12023f3c611c9b0c5921011eb6;hp=0d1d16561473a6e5a334e1feda721e6167f92b04;hpb=30cbd3c60178e01643ec5100a068ed82c8f38013;p=bootmanager.git diff --git a/source/steps/ValidateNodeInstall.py b/source/steps/ValidateNodeInstall.py index 0d1d165..8ff7645 100644 --- a/source/steps/ValidateNodeInstall.py +++ b/source/steps/ValidateNodeInstall.py @@ -1,5 +1,8 @@ #!/usr/bin/python - +# +# $Id$ +# $URL$ +# # Copyright (c) 2003 Intel Corporation # All rights reserved. # @@ -18,7 +21,7 @@ def Run( vars, log ): """ See if a node installation is valid. More checks should certainly be done in the future, but for now, make sure that the sym links kernel-boot - and initrd-boot exist in /boot + exist in /boot Expect the following variables to be set: SYSIMG_PATH the path where the system image will be mounted @@ -83,46 +86,59 @@ def Run( vars, log ): utils.makedirs( SYSIMG_PATH ) - try: - # first run fsck to prevent fs corruption from hanging mount... - log.write( "fsck root file system\n" ) - utils.sysexec("e2fsck -v -p %s" % (PARTITIONS["root"]),log) - - log.write( "fsck vserver file system\n" ) - utils.sysexec("e2fsck -v -p %s" % (PARTITIONS["vservers"]),log) - except BootManagerException, e: - log.write( "BootManagerException during fsck of /root and /vservers : %s\n" % - str(e) ) + for filesystem in ("root","vservers"): + try: + # first run fsck to prevent fs corruption from hanging mount... + log.write( "fsck %s file system\n" % filesystem ) + utils.sysexec("e2fsck -v -p %s" % (PARTITIONS[filesystem]),log) + except BootManagerException, e: + log.write( "BootManagerException during fsck of %s (%s) filesystem : %s\n" % + (filesystem, PARTITIONS[filesystem], str(e)) ) + try: + log.write( "Trying to recover filesystem errors on %s\n" % filesystem ) + utils.sysexec("e2fsck -v -y %s" % (PARTITIONS[filesystem]),log) + except BootManagerException, e: + log.write( "BootManagerException during trying to recover filesystem errors on %s (%s) filesystem : %s\n" % + (filesystem, PARTITIONS[filesystem], str(e)) ) + return -1 try: # then attempt to mount them log.write( "mounting root file system\n" ) utils.sysexec("mount -t ext3 %s %s" % (PARTITIONS["root"],SYSIMG_PATH),log) + except BootManagerException, e: + log.write( "BootManagerException during mount of /root: %s\n" % str(e) ) + return -2 + + try: + PROC_PATH = "%s/proc" % SYSIMG_PATH + utils.makedirs(PROC_PATH) + log.write( "mounting /proc\n" ) + utils.sysexec( "mount -t proc none %s" % PROC_PATH, log ) + except BootManagerException, e: + log.write( "BootManagerException during mount of /proc: %s\n" % str(e) ) + return -2 + try: + VSERVERS_PATH = "%s/vservers" % SYSIMG_PATH + utils.makedirs(VSERVERS_PATH) log.write( "mounting vserver partition in root file system\n" ) - utils.sysexec("mount -t ext3 %s %s/vservers" % \ - (PARTITIONS["vservers"], SYSIMG_PATH), log) - - log.write( "mounting /proc\n" ) - utils.sysexec( "mount -t proc none %s/proc" % SYSIMG_PATH, log ) + utils.sysexec("mount -t ext3 %s %s" % (PARTITIONS["vservers"], VSERVERS_PATH), log) except BootManagerException, e: - log.write( "BootManagerException during mount of /root, /vservers and /proc: %s\n" % - str(e) ) - return 0 + log.write( "BootManagerException during mount of /vservers: %s\n" % str(e) ) + return -2 ROOT_MOUNTED= 1 vars['ROOT_MOUNTED']= 1 - # check if the base kernel is installed # these 2 links are created by our kernel's post-install scriplet log.write("Checking for a custom kernel\n") try: os.stat("%s/boot/kernel-boot" % SYSIMG_PATH) - os.stat("%s/boot/initrd-boot" % SYSIMG_PATH) except OSError, e: log.write( "Couldn't locate base kernel (you might be using the stock kernel).\n") - return 0 + return -3 # check if the model specified kernel is installed option = '' @@ -130,7 +146,6 @@ def Run( vars, log ): option = 'smp' try: os.stat("%s/boot/kernel-boot%s" % (SYSIMG_PATH,option)) - os.stat("%s/boot/initrd-boot%s" % (SYSIMG_PATH,option)) except OSError, e: # smp kernel is not there; remove option from modeloptions # such that the rest of the code base thinks we are just