typo
[plcapi.git] / PLC / Methods / GetBootMedium.py
index e2d1ebf..89f2862 100644 (file)
@@ -1,4 +1,5 @@
 # $Id$
+# $URL$
 import random
 import base64
 import os
@@ -13,6 +14,7 @@ from PLC.Auth import Auth
 from PLC.Nodes import Node, Nodes
 from PLC.Interfaces import Interface, Interfaces
 from PLC.InterfaceTags import InterfaceTag, InterfaceTags
+from PLC.NodeTags import NodeTag, NodeTags
 
 # could not define this in the class..
 # create a dict with the allowed actions for each type of node
@@ -46,7 +48,7 @@ class GetBootMedium(Method):
     This method is a redesign based on former, supposedly dedicated, 
     AdmGenerateNodeConfFile
 
-    As compared with its ancestor, this method provides a much more detailed
+    As compared with its ancestor, this method provides a much more 
     detailed interface, that allows to
     (*) either just preview the node config file -- in which case 
         the node key is NOT recomputed, and NOT provided in the output
@@ -107,11 +109,15 @@ class GetBootMedium(Method):
         - 'partition' - for USB actions only
         - 'cramfs'
         - 'serial' or 'serial:<console_spec>'
-        - 'no-hangcheck'
         console_spec (or 'default') is passed as-is to bootcd/build.sh
         it is expected to be a colon separated string denoting
         tty - baudrate - parity - bits
         e.g. ttyS0:115200:n:8
+        - 'variant:<variantname>'
+        passed to build.sh as -V <variant> 
+        variants are used to run a different kernel on the bootCD
+        see kvariant.sh for how to create a variant
+        - 'no-hangcheck'
 
     Security:
         - Non-admins can only generate files for nodes at their sites.
@@ -231,7 +237,7 @@ class GetBootMedium(Method):
             if category_settings:
                 file += '### Category : %s\n'%category
                 for setting in category_settings:
-                    file += '%s_%s="%s"\n'%(category.upper(),setting['name'].upper(),setting['value'])
+                    file += '%s_%s="%s"\n'%(category.upper(),setting['tagname'].upper(),setting['value'])
 
         for interface in interfaces:
             if interface['method'] == 'ipmi':
@@ -333,6 +339,8 @@ class GetBootMedium(Method):
                 type += "_cramfs"
             if "serial" in build_sh_spec: 
                 build_sh_options += " -s %s"%build_sh_spec['serial']
+            if "variant" in build_sh_spec:
+                build_sh_options += " -V %s"%build_sh_spec['variant']
             
             for karg in build_sh_spec['kargs']:
                 build_sh_options += ' -k "%s"'%karg
@@ -414,10 +422,29 @@ class GetBootMedium(Method):
                     build_sh_spec['serial']='default'
                 elif option.find("serial:") == 0:
                     build_sh_spec['serial']=option.replace("serial:","")
+                elif option.find("variant:") == 0:
+                    build_sh_spec['variant']=option.replace("variant:","")
                 elif option == "no-hangcheck":
                     build_sh_spec['kargs'].append('hcheck_reboot0')
                 else:
                     raise PLCInvalidArgument, "unknown option %s"%option
+            # check for node tag equivalents
+            tags = NodeTags(self.api, {'node_id': node['node_id'], 'tagname': [
+                                       'serial', 'cramfs', 'kvariant',
+                                       'kargs', 'no-hangcheck']},
+                            ['tagname', 'value'])
+            if tags:
+                for tag in tags:
+                    if tag['tagname'] == 'serial':
+                        build_sh_spec['serial'] = tag['value']
+                    if tag['tagname'] == 'cramfs':
+                        build_sh_spec['cramfs'] = True
+                    if tag['tagname'] == 'kvariant':
+                        build_sh_spec['variant'] = tag['value']
+                    if tag['tagname'] == 'kargs':
+                        build_sh_spec['kargs'].append(tag['value'].split())
+                    if tag['tagname'] == 'no-hangcheck':
+                        build_sh_spec['kargs'].append('hcheck_reboot0')
 
         # compute nodename according the action
         if action.find("node-") == 0 or action.find("dummynet-") == 0: