new GetNodeFlavour method based on PLC_FLAVOUR category + optional node tags
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 25 Jan 2010 15:12:06 +0000 (15:12 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Mon, 25 Jan 2010 15:12:06 +0000 (15:12 +0000)
PLC/Methods/GetNodeFlavour.py [new file with mode: 0644]
PLC/Methods/GetSliceFamily.py
PLC/Methods/__init__.py

diff --git a/PLC/Methods/GetNodeFlavour.py b/PLC/Methods/GetNodeFlavour.py
new file mode 100644 (file)
index 0000000..bcc60ca
--- /dev/null
@@ -0,0 +1,74 @@
+# $Id$
+# $URL$
+from PLC.Method import Method
+from PLC.Auth import Auth
+from PLC.Faults import *
+from PLC.Parameter import *
+from PLC.Nodes import Node, Nodes
+
+from PLC.Accessors.Accessors_standard import *                 # import node accessors
+
+class GetNodeFlavour(Method):
+    """
+    Returns detailed information on a given node's flavour, i.e. its
+    base installation. 
+
+    This depends on the global PLC settings in the PLC_FLAVOUR area,
+    optionnally overridden by any of the following tags if set on that node:
+
+    'arch', 'pldistro', 'fcdistro', (xxx fcdistro not yet supported)
+    'deployment', 'extensions',
+    """
+
+    roles = ['admin', 'user', 'node']
+
+    accepts = [
+        Auth(),
+        Mixed(Node.fields['node_id'],
+              Node.fields['name']),
+        ]
+
+    returns = { 'nodefamily' : Parameter (str, "the node-family this node should be based upon"),
+                'extensions' : [ Parameter (str, "extension to add to the base install") ],
+                'uncompressed' : Parameter (bool, "for tests : use uncompressed bootstrapfs" ) ,
+                }
+
+    
+    ########## nodefamily
+    def nodefamily (self, auth, nodeid):
+
+        # the deployment tag, if set, wins
+        deployment = GetNodeDeployment (self.api).call(auth,node_id)
+        if deployment: return deployment
+
+        arch = GetNodeArch (self.api).call(auth,node_id)
+        if not arch: arch = self.api.config.PLC_FLAVOUR_NODE_ARCH
+
+        pldistro = GetNodePldistro (self.api).call(auth, node_id)
+        if not pldistro: pldistro = self.api.config.PLC_FLAVOUR_NODE_PLDISTRO
+
+        ###fcdistro = GetNodeFcdistro (self.api).call(auth, node_id)
+        ###if not fcdistro: fcdistro = self.api.config.PLC_FLAVOUR_NODE_FCDISTRO
+
+        # xxx would make sense to check the corresponding bootstrapfs is available
+        ###return "%s-%s-%s"%(pldistro,fcdistro,arch)
+        return "%s-%s"%(pldistro,arch)
+
+    def extensions (self, auth, node_id):
+        return GetNodeExtensions(self.api).call(auth,node_id).split()
+
+    def compressed (self, auth, node_id):
+        return not PlainBootstrapfs(self.api).call(auth,node_id)
+
+    def call(self, auth, node_id_or_name):
+        # Get node information
+        nodes = Nodes(self.api, [node_id_or_name])
+        if not nodes:
+            raise PLCInvalidArgument, "No such node %r"%node_id_or_name
+        node = nodes[0]
+        node_id = node['node_id']
+
+        return { 'nodefamily' : self.nodefamily(auth,node_id),
+                 'extensions' : self.extensions(auth,node_id),
+                 'compressed' : self.compressed(auth,node_id),
+                 }
index eea8a8d..5428ba1 100644 (file)
@@ -25,7 +25,7 @@ class GetSliceFamily(Method):
               Slice.fields['name']),
         ]
 
-    returns = Parameter (str, "the slice-family this slice should be based upon")
+    returns = Parameter (str, "the slicefamily this slice should be based upon")
 
     # 
     ### system slices - at least planetflow - still rely on 'vref'
index e5344f0..f885d10 100644 (file)
@@ -104,6 +104,7 @@ GetKeys
 GetMessages
 GetNetworkMethods
 GetNetworkTypes
+GetNodeFlavour
 GetNodeGroups
 GetNodeTags
 GetNodeTypes