1 from PLC.Method import Method
2 from PLC.Auth import Auth
3 from PLC.Faults import *
4 from PLC.Parameter import *
5 from PLC.Nodes import Node, Nodes
7 from PLC.Accessors.Accessors_standard import * # import node accessors
9 class GetNodeFlavour(Method):
11 Returns detailed information on a given node's flavour, i.e. its
14 This depends on the global PLC settings in the PLC_FLAVOUR area,
15 optionnally overridden by any of the following tags if set on that node:
17 'arch', 'pldistro', 'fcdistro',
18 'deployment', 'extensions',
21 roles = ['admin', 'user', 'node']
25 Mixed(Node.fields['node_id'],
26 Node.fields['hostname']),
30 'nodefamily' : Parameter (str, "the nodefamily this node should be based upon"),
31 'fcdistro': Parameter (str, "the fcdistro this node should be based upon"),
32 'extensions' : [ Parameter (str, "extensions to add to the base install") ],
33 'plain' : Parameter (bool, "use plain bootstrapfs image if set (for tests)" ) ,
38 def nodefamily (self, auth, node_id, fcdistro, arch):
40 # the deployment tag, if set, wins
41 # xxx Thierry: this probably is wrong; we need fcdistro to be set anyway
42 # for generating the proper yum config....
43 deployment = GetNodeDeployment (self.api,self.caller).call(auth,node_id)
44 if deployment: return deployment
46 pldistro = GetNodePldistro (self.api,self.caller).call(auth, node_id)
48 pldistro = self.api.config.PLC_FLAVOUR_NODE_PLDISTRO
49 SetNodePldistro(self.api,self.caller).call(auth,node_id,pldistro)
51 # xxx would make sense to check the corresponding bootstrapfs is available
52 return "%s-%s-%s"%(pldistro,fcdistro,arch)
54 def extensions (self, auth, node_id, fcdistro, arch):
56 return [ "%s-%s-%s"%(e,fcdistro,arch) for e in GetNodeExtensions(self.api,self.caller).call(auth,node_id).split() ]
60 def plain (self, auth, node_id):
61 return not not GetNodePlainBootstrapfs(self.api,self.caller).call(auth,node_id)
63 def call(self, auth, node_id_or_name):
64 # Get node information
65 nodes = Nodes(self.api, [node_id_or_name])
67 raise PLCInvalidArgument, "No such node %r"%node_id_or_name
69 node_id = node['node_id']
71 arch = GetNodeArch (self.api,self.caller).call(auth,node_id)
72 # if not set, use the global default and tag the node, in case the global default changes later on
74 arch = self.api.config.PLC_FLAVOUR_NODE_ARCH
75 SetNodeArch (self.api,self.caller).call(auth,node_id,arch)
77 fcdistro = GetNodeFcdistro (self.api,self.caller).call(auth, node_id)
79 fcdistro = self.api.config.PLC_FLAVOUR_NODE_FCDISTRO
80 SetNodeFcdistro (self.api,self.caller).call (auth, node_id, fcdistro)
82 # xxx could use some sanity checking, and could provide fallbacks
83 return { 'nodefamily' : self.nodefamily(auth,node_id, fcdistro, arch),
84 'fcdistro' : fcdistro,
85 'extensions' : self.extensions(auth,node_id, fcdistro, arch),
86 'plain' : self.plain(auth,node_id),