- MyPLC 0.4 RC2
[bootmanager.git] / source / steps / ValidateNodeInstall.py
index aea2e17..7b7ed8a 100644 (file)
@@ -4,6 +4,7 @@ from Exceptions import *
 import utils
 from systeminfo import systeminfo
 import compatibility
+import ModelOptions
 
 
 def Run( vars, log ):
@@ -44,6 +45,8 @@ def Run( vars, log ):
         if PLCONF_DIR == "":
             raise ValueError, "PLCONF_DIR"
         
+        NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"]
+
     except KeyError, var:
         raise BootManagerException, "Missing variable in vars: %s\n" % var
     except ValueError, var:
@@ -81,6 +84,7 @@ def Run( vars, log ):
             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 )
         except BootManagerException, e:
             log.write( "BootManagerException during vgscan/vgchange: %s\n" %
                        str(e) )
@@ -89,17 +93,30 @@ def Run( vars, log ):
         ROOT_MOUNTED= 1
         vars['ROOT_MOUNTED']= 1
         
-    valid= 0
     
-    if os.access("%s/boot/kernel-boot" % SYSIMG_PATH, os.F_OK | os.R_OK) and \
-           os.access("%s/boot/initrd-boot" % SYSIMG_PATH, os.F_OK | os.R_OK):
-        valid= 1
-
-    if not valid:
-        log.write( "Node does not appear to be installed correctly:\n" )
-        log.write( "missing file /boot/ initrd-boot or kernel-boot\n" )
+    # check if the base kernel is installed
+    try:
+        os.stat("%s/boot/kernel-boot" % SYSIMG_PATH)
+        os.stat("%s/boot/initrd-boot" % SYSIMG_PATH)
+    except OSError, e:            
+        log.write( "FATAL: Couldn't locate base 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:
@@ -108,9 +125,9 @@ def Run( vars, log ):
         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" )