From: Thierry Parmentelat Date: Mon, 25 Jan 2010 15:12:06 +0000 (+0000) Subject: new GetNodeFlavour method based on PLC_FLAVOUR category + optional node tags X-Git-Tag: PLCAPI-5.0-1^2~15 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=de3dd4fa24a3757d47b1d8b979b49054281da3a6;p=plcapi.git new GetNodeFlavour method based on PLC_FLAVOUR category + optional node tags --- diff --git a/PLC/Methods/GetNodeFlavour.py b/PLC/Methods/GetNodeFlavour.py new file mode 100644 index 00000000..bcc60ca1 --- /dev/null +++ b/PLC/Methods/GetNodeFlavour.py @@ -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), + } diff --git a/PLC/Methods/GetSliceFamily.py b/PLC/Methods/GetSliceFamily.py index eea8a8d5..5428ba19 100644 --- a/PLC/Methods/GetSliceFamily.py +++ b/PLC/Methods/GetSliceFamily.py @@ -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' diff --git a/PLC/Methods/__init__.py b/PLC/Methods/__init__.py index e5344f04..f885d107 100644 --- a/PLC/Methods/__init__.py +++ b/PLC/Methods/__init__.py @@ -104,6 +104,7 @@ GetKeys GetMessages GetNetworkMethods GetNetworkTypes +GetNodeFlavour GetNodeGroups GetNodeTags GetNodeTypes