From de3dd4fa24a3757d47b1d8b979b49054281da3a6 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 25 Jan 2010 15:12:06 +0000 Subject: [PATCH] new GetNodeFlavour method based on PLC_FLAVOUR category + optional node tags --- PLC/Methods/GetNodeFlavour.py | 74 +++++++++++++++++++++++++++++++++++ PLC/Methods/GetSliceFamily.py | 2 +- PLC/Methods/__init__.py | 1 + 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 PLC/Methods/GetNodeFlavour.py diff --git a/PLC/Methods/GetNodeFlavour.py b/PLC/Methods/GetNodeFlavour.py new file mode 100644 index 0000000..bcc60ca --- /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 eea8a8d..5428ba1 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 e5344f0..f885d10 100644 --- a/PLC/Methods/__init__.py +++ b/PLC/Methods/__init__.py @@ -104,6 +104,7 @@ GetKeys GetMessages GetNetworkMethods GetNetworkTypes +GetNodeFlavour GetNodeGroups GetNodeTags GetNodeTypes -- 2.43.0