+#!/usr/bin/python
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
import os
from Exceptions import *
import utils
-from systeminfo import systeminfo
-import compatibility
-from GetAndUpdateNodeDetails import SMP_OPT
+import systeminfo
+import ModelOptions
def Run( vars, log ):
Expect the following variables to be set:
SYSIMG_PATH the path where the system image will be mounted
(always starts with TEMP_PATH)
- BOOT_CD_VERSION A tuple of the current bootcd version
ROOT_MOUNTED the node root file system is mounted
NODE_ID The db node_id for this machine
PLCONF_DIR The directory to store the configuration file in
# make sure we have the variables we need
try:
- BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
- if BOOT_CD_VERSION == "":
- raise ValueError, "BOOT_CD_VERSION"
-
SYSIMG_PATH= vars["SYSIMG_PATH"]
if SYSIMG_PATH == "":
raise ValueError, "SYSIMG_PATH"
NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"]
+ PARTITIONS= vars["PARTITIONS"]
+ if PARTITIONS == None:
+ raise ValueError, "PARTITIONS"
+
except KeyError, var:
raise BootManagerException, "Missing variable in vars: %s\n" % var
except ValueError, var:
ROOT_MOUNTED= 0
- if 'ROOT_MOUNTED' in vars.keys():
+ if vars.has_key('ROOT_MOUNTED'):
ROOT_MOUNTED= vars['ROOT_MOUNTED']
# mount the root system image if we haven't already.
# capture BootManagerExceptions during the vgscan/change and mount
# calls, so we can return 0 instead
if ROOT_MOUNTED == 0:
- # old cds need extra utilities to run lvm
- if BOOT_CD_VERSION[0] == 2:
- compatibility.setup_lvm_2x_cd( vars, log )
# simply creating an instance of this class and listing the system
# block devices will make them show up so vgscan can find the planetlab
# volume group
- systeminfo().get_block_device_list()
+ systeminfo.get_block_device_list(vars, log)
try:
utils.sysexec( "vgscan", log )
utils.makedirs( SYSIMG_PATH )
try:
- utils.sysexec( "mount /dev/planetlab/root %s" % SYSIMG_PATH, log )
- utils.sysexec( "mount /dev/planetlab/vservers %s/vservers" %
- SYSIMG_PATH, log )
- utils.sysexec( "mount -t proc none %s/proc" % SYSIMG_PATH, log )
+ # 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 vgscan/vgchange: %s\n" %
+ log.write( "BootManagerException during fsck of /root and /vservers : %s\n" %
+ str(e) )
+
+ 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)
+
+ 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)
+
+ 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 /root, /vservers and /proc: %s\n" %
str(e) )
return 0
vars['ROOT_MOUNTED']= 1
- # get the kernel version
- option = ''
- if NODE_MODEL_OPTIONS & SMP_OPT:
- option = 'smp'
-
- files = ("kernel-boot%s" % option, "initrd-boot%s" % option)
- valid= 1
- for filepath in files:
- if not os.access("%s/boot/%s"%(SYSIMG_PATH,filepath),os.F_OK|os.R_OK):
- log.write( "Node not properly installed:\n")
- log.write( "\tmissing file /boot/%s\n" % filepath )
- valid= 0
-
- if not valid:
+ # 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
+ # check if the model specified kernel is installed
+ option = ''
+ if NODE_MODEL_OPTIONS & ModelOptions.SMP:
+ 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
+ # using the base kernel.
+ NODE_MODEL_OPTIONS = NODE_MODEL_OPTIONS & ~ModelOptions.SMP
+ vars["NODE_MODEL_OPTIONS"] = NODE_MODEL_OPTIONS
+ log.write( "WARNING: Couldn't locate smp kernel.\n")
+
# write out the node id to /etc/planetlab/node_id. if this fails, return
# 0, indicating the node isn't a valid install.
try:
node_id_file.write( str(NODE_ID) )
node_id_file.close()
node_id_file= None
- log.write( "Updated /etc/planetlab/node_id" )
+ log.write( "Updated /etc/planetlab/node_id\n" )
except IOError, e:
- log.write( "Unable to write out /etc/planetlab/node_id" )
+ log.write( "Unable to write out /etc/planetlab/node_id\n" )
return 0
- log.write( "Everything appears to be ok\n" )
+ log.write( "Node installation appears to be ok\n" )
return 1