tweaks for reservable nodes
[plcapi.git] / PLC / Methods / GetBootMedium.py
index e314122..64458e2 100644 (file)
@@ -16,17 +16,26 @@ from PLC.Interfaces import Interface, Interfaces
 from PLC.InterfaceTags import InterfaceTag, InterfaceTags
 from PLC.NodeTags import NodeTag, NodeTags
 
+from PLC.Accessors.Accessors_standard import *                 # import node accessors
+
 # could not define this in the class..
 # create a dict with the allowed actions for each type of node
+# reservable nodes being more recent, we do not support the floppy stuff anymore
 allowed_actions = {
-                'regular' : [ 'node-preview',
-                              'node-floppy',
-                              'node-iso',
-                              'node-usb',
-                              'generic-iso',
-                              'generic-usb',
-                               ],
-                }
+    'regular' : 
+    [ 'node-preview',
+      'node-floppy',
+      'node-iso',
+      'node-usb',
+      'generic-iso',
+      'generic-usb',
+      ],
+    'reservable': 
+    [ 'node-preview',
+      'node-iso',
+      'node-usb',
+      ],
+    }
 
 # compute a new key
 def compute_key():
@@ -68,6 +77,8 @@ class GetBootMedium(Method):
 
     Apart for the preview mode, this method generates a new node key for the
     specified node, effectively invalidating any old boot medium.
+    Note that 'reservable' nodes do not support 'node-floppy', 
+    'generic-iso' nor 'generic-usb'.
 
     In addition, two return mechanisms are supported.
     (*) The default behaviour is that the file's content is returned as a 
@@ -241,26 +252,27 @@ class GetBootMedium(Method):
 
         return file
 
-    # see also InstallBootstrapFS in bootmanager that does similar things
-    def get_nodefamily (self, node):
-        # get defaults from the myplc build
-        try:
-            (pldistro,arch) = file("/etc/planetlab/nodefamily").read().strip().split("-")
-        except:
-            (pldistro,arch) = ("planetlab","i386")
-            
-        # with no valid argument, return system-wide defaults
+    # see also GetNodeFlavour that does similar things
+    def get_nodefamily (self, node, auth):
+        pldistro = self.api.config.PLC_FLAVOUR_NODE_PLDISTRO
+        fcdistro = self.api.config.PLC_FLAVOUR_NODE_FCDISTRO
+        arch = self.api.config.PLC_FLAVOUR_NODE_ARCH
         if not node:
-            return (pldistro,arch)
-
+            return (pldistro,fcdistro,arch)
+        
         node_id=node['node_id']
+        
+        # no support for deployment-based BootCD's, use kvariants instead
+        node_pldistro = GetNodePldistro (self.api).call(auth, node_id)
+        if node_pldistro: pldistro = node_pldistro
 
-        tag=Nodes(self.api,[node_id],['arch'])[0]['arch']
-        if tag: arch=tag
-        tag=Nodes(self.api,[node_id],['pldistro'])[0]['pldistro']
-        if tag: pldistro=tag
+        node_fcdistro = GetNodeFcdistro (self.api).call(auth, node_id)
+        if node_fcdistro: fcdistro = node_fcdistro
 
-        return (pldistro,arch)
+        node_arch = GetNodeArch (self.api).call(auth,node_id)
+        if node_arch: arch = node_arch
+        
+        return (pldistro,fcdistro,arch)
 
     def bootcd_version (self):
         try:
@@ -325,7 +337,7 @@ class GetBootMedium(Method):
 
         # regular node, make build's arguments
         # and build the full command line to be called
-        if node_type == 'regular':
+        if node_type in [ 'regular', 'reservable' ]:
 
             build_sh_options=""
             if "cramfs" in build_sh_spec: 
@@ -404,7 +416,7 @@ class GetBootMedium(Method):
                     if tag['tagname'] == 'kvariant':
                         build_sh_spec['variant'] = tag['value']
                     if tag['tagname'] == 'kargs':
-                        build_sh_spec['kargs'].append(tag['value'].split())
+                        build_sh_spec['kargs'] += tag['value'].split()
                     if tag['tagname'] == 'no-hangcheck':
                         build_sh_spec['kargs'].append('hcheck_reboot0')
             # then options can override tags
@@ -438,8 +450,8 @@ class GetBootMedium(Method):
             nodename = "".join(map(hexa2,tempbytes))
 
         # get nodefamily
-        (pldistro,arch) = self.get_nodefamily(node)
-        self.nodefamily="%s-%s"%(pldistro,arch)
+        (pldistro,fcdistro,arch) = self.get_nodefamily(node,auth)
+        self.nodefamily="%s-%s-%s"%(pldistro,fcdistro,arch)
 
         # apply on globals
         for attr in [ "BOOTCDDIR", "BOOTCDBUILD", "GENERICDIR" ]: