The extensions variable is not expected to be in the configuration file if the latest...
[bootmanager.git] / source / steps / GetAndUpdateNodeDetails.py
index a548888..78d77f6 100644 (file)
@@ -1,11 +1,12 @@
-#!/usr/bin/python2
-
+#!/usr/bin/python
+#
 # Copyright (c) 2003 Intel Corporation
 # All rights reserved.
 #
 # Copyright (c) 2004-2006 The Trustees of Princeton University
 # All rights reserved.
 
+import sys, traceback
 import string
 
 from Exceptions import *
@@ -23,7 +24,6 @@ def Run( vars, log ):
     broadcast, netmask, dns1/2, and the hostname/domainname.
 
     Expect the following keys to be set:
-    BOOT_CD_VERSION                     A tuple of the current bootcd version
     SKIP_HARDWARE_REQUIREMENT_CHECK     Whether or not we should skip hardware
                                         requirement checks
                                         
@@ -48,10 +48,6 @@ def Run( vars, log ):
 
     # 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"
-
         SKIP_HARDWARE_REQUIREMENT_CHECK= vars["SKIP_HARDWARE_REQUIREMENT_CHECK"]
         if SKIP_HARDWARE_REQUIREMENT_CHECK == "":
             raise ValueError, "SKIP_HARDWARE_REQUIREMENT_CHECK"
@@ -78,6 +74,7 @@ def Run( vars, log ):
                                               ['boot_state', 'nodegroup_ids', 'interface_ids', 'model', 'site_id']))[0]
 
     vars['BOOT_STATE']= node_details['boot_state']
+    vars['RUN_LEVEL']= node_details['boot_state']
     vars['NODE_MODEL']= string.strip(node_details['model'])
     vars['SITE_ID'] = node_details['site_id'] 
     log.write( "Successfully retrieved node record.\n" )
@@ -109,4 +106,38 @@ def Run( vars, log ):
 
     vars['INTERFACES']= interfaces
     
+    # call getNodeFlavour and store in VARS['node_flavour']
+    try:
+        node_flavour = BootAPI.call_api_function(vars, "GetNodeFlavour", (vars['NODE_ID'], ) )
+    except:
+        log.write("GetNodeFlavour failed, not fatal if the node flavor is available in ``configuration''\n")
+        pass
+    
+    flavour_keys = [
+            'virt',# 'vs' or 'lxc'
+            'nodefamily',# the basename for downloading nodeimage
+            'extensions',# extensions to be applied on top of the base nodeimage
+            'plain'# false if compressed image, true if not
+            ]
+
+    # MyPLC 5.0 workaround
+    try:
+        if (vars['extensions']==''):
+            vars['extensions']=[]
+    except:
+        pass
+
+    for k in flavour_keys:
+        # Support MyPLC <5.2
+        if (not vars.has_key(k)):
+            try:
+                vars[k] = node_flavour[k]
+            except:
+                exc_type, exc_value, exc_traceback = sys.exc_info()
+                lines=traceback.format_exception(exc_type,exc_value,exc_traceback)
+                for line in lines: log.write(line)
+                raise BootManagerException ("Could not call GetNodeFlavour - need PLCAPI-5.2")
+
+    log.write ("NodeFlavour as returned from PLC: %s\n"%node_flavour)
+
     return 1