we're finding nodes that have old material from their time at PLC
[bootmanager.git] / source / steps / ReadNodeConfiguration.py
index caef8fe..aadef79 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/python
-
+#
 # Copyright (c) 2003 Intel Corporation
 # All rights reserved.
 #
@@ -50,8 +50,6 @@ def Run( vars, log ):
     and read, return 1.
 
     Expect the following variables from the store:
-    SUPPORT_FILE_DIR         directory on the boot servers containing
-                             scripts and support files
     
     Sets the following variables from the configuration file:
     WAS_NODE_ID_IN_CONF         Set to 1 if the node id was in the conf file
@@ -83,16 +81,6 @@ def Run( vars, log ):
 
 
     # make sure we have the variables we need
-    try:
-        SUPPORT_FILE_DIR= vars["SUPPORT_FILE_DIR"]
-        if SUPPORT_FILE_DIR == None:
-            raise ValueError, "SUPPORT_FILE_DIR"
-
-    except KeyError, var:
-        raise BootManagerException, "Missing variable in vars: %s\n" % var
-    except ValueError, var:
-        raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
-
 
     INTERFACE_SETTINGS= {}
     INTERFACE_SETTINGS['method']= "dhcp"
@@ -134,7 +122,7 @@ def Run( vars, log ):
 
     conf_file_path= "%s/%s" % (mount_point,NEW_CONF_FILE_NAME)
     
-    log.write( "Checking for existence of %s\n" % conf_file_path )
+#    log.write( "Checking for existence of %s\n" % conf_file_path )
     if os.access( conf_file_path, os.R_OK ):
         try:
             conf_file= file(conf_file_path,"r")
@@ -147,6 +135,7 @@ def Run( vars, log ):
 
         utils.sysexec_noerr( "umount %s" % mount_point, log )
         if __parse_configuration_file( vars, log, conf_file_contents):
+            log.write("ReadNodeConfiguration: [1] using %s from floppy /dev/fd0\n"%NEW_CONF_FILE_NAME)
             return 1
         else:
             raise BootManagerException( "Found configuration file plnode.txt " \
@@ -158,7 +147,8 @@ def Run( vars, log ):
     # try to parse it later...
     conf_file_path= "%s/%s" % (mount_point,OLD_CONF_FILE_NAME)
 
-    log.write( "Checking for existence of %s (used later)\n" % conf_file_path )
+# this message really does not convey any useful information
+#    log.write( "Checking for existence of %s (used later)\n" % conf_file_path )
     if os.access( conf_file_path, os.R_OK ):
         try:
             old_conf_file= file(conf_file_path,"r")
@@ -236,8 +226,7 @@ def Run( vars, log ):
                     log.write( "Read in contents of file %s\n" % \
                                conf_file_path )
 
-                    if __parse_configuration_file( vars, log, \
-                                                   conf_file_contents):
+                    if __parse_configuration_file( vars, log, conf_file_contents):
                         parsed_file= 1
                 except IOError, e:
                     log.write( "Unable to read file %s\n" % conf_file_path )
@@ -245,20 +234,21 @@ def Run( vars, log ):
             utils.sysexec_noerr( "umount %s" % mount_point, log )
             if found_file:
                 if parsed_file:
+                    log.write("ReadNodeConfiguration: [2] using %s from partition %s\n"%\
+                                  (NEW_CONF_FILE_NAME,full_device))
                     return 1
                 else:
                     raise BootManagerException( \
-                        "Found configuration file plnode.txt " \
-                        "on floppy, but was unable to parse it.")
+                        "Found configuration file on %s, but was unable to parse it."%full_device)
 
 
             
     # 3. check standard floppy disk for old file name planet.cnf
-    log.write( "Checking standard floppy disk for planet.cnf file " \
-               "(for legacy nodes).\n" )
+    log.write( "Checking standard floppy disk for planet.cnf file (for legacy nodes).\n" )
 
     if old_conf_file_contents:
         if __parse_configuration_file( vars, log, old_conf_file_contents):
+            log.write("ReadNodeConfiguration: [3] using %s from floppy /dev/fd0\n"%OLD_CONF_FILE_NAME)
             return 1
         else:
             raise BootManagerException( "Found configuration file planet.cnf " \
@@ -282,6 +272,7 @@ def Run( vars, log ):
             pass
     
         if __parse_configuration_file( vars, log, conf_file_contents):            
+            log.write("ReadNodeConfiguration: [4] using %s from ramdisk\n"%NEW_CONF_FILE_NAME)
             return 1
         else:
             raise BootManagerException( "Found configuration file plnode.txt " \
@@ -305,6 +296,7 @@ def Run( vars, log ):
             pass
     
         if __parse_configuration_file( vars, log, conf_file_contents):            
+            log.write("ReadNodeConfiguration: [5] using %s from CD in /usr/boot\n"%NEW_CONF_FILE_NAME)
             return 1
         else:
             raise BootManagerException( "Found configuration file plnode.txt " \
@@ -329,6 +321,7 @@ def Run( vars, log ):
             pass    
     
         if __parse_configuration_file( vars, log, conf_file_contents):            
+            log.write("ReadNodeConfiguration: [6] using %s from /usr\n"%NEW_CONF_FILE_NAME)
             return 1
         else:
             raise BootManagerException( "Found configuration file plnode.txt " \
@@ -348,7 +341,6 @@ def __parse_configuration_file( vars, log, file_contents ):
     of the configuration file is completed.
     """
 
-    SUPPORT_FILE_DIR= vars["SUPPORT_FILE_DIR"]
     INTERFACE_SETTINGS= vars["INTERFACE_SETTINGS"]
     
     if file_contents is None:
@@ -473,11 +465,10 @@ def __parse_configuration_file( vars, log, file_contents ):
         log.write( "Configuration file does not contain the node_id value.\n" )
         log.write( "Querying PLC for node_id.\n" )
 
-        bs_request= BootServerRequest.BootServerRequest()
+        bs_request= BootServerRequest.BootServerRequest(vars)
         
         postVars= {"mac_addr" : INTERFACE_SETTINGS["mac"]}
-        result= bs_request.DownloadFile( "%s/getnodeid.php" %
-                                         SUPPORT_FILE_DIR,
+        result= bs_request.DownloadFile( "/boot/getnodeid.php",
                                          None, postVars, 1, 1,
                                          "/tmp/node_id")
         if result == 0:
@@ -599,7 +590,8 @@ def __parse_configuration_file( vars, log, file_contents ):
         
     vars["INTERFACE_SETTINGS"]= INTERFACE_SETTINGS
 
-    if not hostname_resolve_ok and not vars['DISCONNECTED_OPERATION']:
+    if (not hostname_resolve_ok and not vars['DISCONNECTED_OPERATION'] and
+        'NAT_MODE' not in vars):
         log.write( "Hostname does not resolve correctly, will not continue.\n" )
 
         if can_make_api_call:
@@ -624,4 +616,9 @@ def __parse_configuration_file( vars, log, file_contents ):
         raise BootManagerException, \
               "Configured node hostname does not resolve."
     
+    try:
+        log.write("Using NODE_ID %d\n"%vars['NODE_ID'])
+    except:
+        log.write("Unknown NODE_ID")
+
     return 1