X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=source%2Fsteps%2FValidateNodeInstall.py;h=111ba2610226d6cb917449eafb5edbb002945c8b;hb=22a4de46644673c2cdac84adb2da900020e657d6;hp=5f9784705af1ceb3df6c0adc076d781da87b8ac3;hpb=9807dbe301e4e078c07bff4df81ff33811a5cca7;p=bootmanager.git diff --git a/source/steps/ValidateNodeInstall.py b/source/steps/ValidateNodeInstall.py index 5f97847..111ba26 100644 --- a/source/steps/ValidateNodeInstall.py +++ b/source/steps/ValidateNodeInstall.py @@ -1,5 +1,5 @@ #!/usr/bin/python - +# # Copyright (c) 2003 Intel Corporation # All rights reserved. # @@ -83,15 +83,30 @@ def Run( vars, log ): utils.makedirs( SYSIMG_PATH ) - for filesystem in ("root","vservers"): + # xxx - TODO - need to fsck the btrfs partition + if vars['virt'] == 'vs': + filesystems_tocheck = ['root', 'vservers'] + else: + filesystems_tocheck = ['root'] + + for filesystem in filesystems_tocheck: 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) + utils.sysexec("e2fsck -v -p %s" % (PARTITIONS[filesystem]), log, fsck=True) except BootManagerException, e: log.write( "BootManagerException during fsck of %s (%s) filesystem : %s\n" % (filesystem, PARTITIONS[filesystem], str(e)) ) - return -1 + try: + log.write( "Trying to recover filesystem errors on %s\n" % filesystem ) + utils.sysexec("e2fsck -v -y %s" % (PARTITIONS[filesystem]),log, fsck=True) + 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 + else: + # disable time/count based filesystems checks + utils.sysexec_noerr( "tune2fs -c -1 -i 0 %s" % PARTITIONS[filesystem], log) try: # then attempt to mount them @@ -110,14 +125,21 @@ def Run( vars, log ): 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" % (PARTITIONS["vservers"], VSERVERS_PATH), log) - except BootManagerException, e: - log.write( "BootManagerException during mount of /vservers: %s\n" % str(e) ) - return -2 + + one_partition = vars['ONE_PARTITION']=='1' + + if (not one_partition): + try: + VSERVERS_PATH = "%s/vservers" % SYSIMG_PATH + utils.makedirs(VSERVERS_PATH) + log.write( "mounting vservers partition in root file system\n" ) + if vars['virt']=='vs': + utils.sysexec("mount -t ext3 %s %s" % (PARTITIONS["vservers"], VSERVERS_PATH), log) + else: + utils.sysexec("mount -t btrfs %s %s" % (PARTITIONS["vservers"], VSERVERS_PATH), log) + except BootManagerException, e: + log.write( "BootManagerException during mount of /vservers: %s\n" % str(e) ) + return -2 ROOT_MOUNTED= 1 vars['ROOT_MOUNTED']= 1 @@ -126,7 +148,15 @@ def Run( vars, log ): # 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) + if vars['virt'] == 'vs': + os.stat("%s/boot/kernel-boot" % SYSIMG_PATH) + else: + try: + kversion = os.popen("chroot %s rpm -qa kernel | tail -1 | cut -c 8-" % SYSIMG_PATH).read().rstrip() + os.stat("%s/boot/vmlinuz-%s" % (SYSIMG_PATH,kversion)) + major_version = int(kversion[0]) # Check if the string looks like a kernel version + except: + kversion = os.popen("ls -lrt /lib/modules | tail -1 | awk '{print $9;}'").read().rstrip() except OSError, e: log.write( "Couldn't locate base kernel (you might be using the stock kernel).\n") return -3