3 from PLC.Method import Method
4 from PLC.Auth import Auth
5 from PLC.Faults import *
6 from PLC.Parameter import *
7 from PLC.Nodes import Node, Nodes
9 from PLC.Accessors.Accessors_standard import * # import node accessors
11 class GetNodeFlavour(Method):
13 Returns detailed information on a given node's flavour, i.e. its
16 This depends on the global PLC settings in the PLC_FLAVOUR area,
17 optionnally overridden by any of the following tags if set on that node:
19 'arch', 'pldistro', 'fcdistro', (xxx fcdistro not yet supported)
20 'deployment', 'extensions',
23 roles = ['admin', 'user', 'node']
27 Mixed(Node.fields['node_id'],
28 Node.fields['hostname']),
32 'nodefamily' : Parameter (str, "the node-family this node should be based upon"),
33 'extensions' : [ Parameter (str, "extensions to add to the base install") ],
34 'plain' : Parameter (bool, "use plain bootstrapfs image if set (for tests)" ) ,
39 def nodefamily (self, auth, node_id, arch):
41 # the deployment tag, if set, wins
42 deployment = GetNodeDeployment (self.api).call(auth,node_id)
43 if deployment: return deployment
45 pldistro = GetNodePldistro (self.api).call(auth, node_id)
46 if not pldistro: pldistro = self.api.config.PLC_FLAVOUR_NODE_PLDISTRO
48 ###fcdistro = GetNodeFcdistro (self.api).call(auth, node_id)
49 ###if not fcdistro: fcdistro = self.api.config.PLC_FLAVOUR_NODE_FCDISTRO
51 # xxx would make sense to check the corresponding bootstrapfs is available
52 ###return "%s-%s-%s"%(pldistro,fcdistro,arch)
53 return "%s-%s"%(pldistro,arch)
55 def extensions (self, auth, node_id, arch):
57 return [ "%s-%s"%(e,arch) for e in GetNodeExtensions(self.api).call(auth,node_id).split() ]
61 def plain (self, auth, node_id):
62 return not not GetNodePlainBootstrapfs(self.api).call(auth,node_id)
64 def call(self, auth, node_id_or_name):
65 # Get node information
66 nodes = Nodes(self.api, [node_id_or_name])
68 raise PLCInvalidArgument, "No such node %r"%node_id_or_name
70 node_id = node['node_id']
72 arch = GetNodeArch (self.api).call(auth,node_id)
73 if not arch: arch = self.api.config.PLC_FLAVOUR_NODE_ARCH
75 # xxx could use some sanity checking, and could provide fallbacks
76 return { 'nodefamily' : self.nodefamily(auth,node_id, arch),
77 'extensions' : self.extensions(auth,node_id, arch),
78 'plain' : self.plain(auth,node_id),