X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=trunk%2FPLC%2FMethods%2FSliceNodesList.py;fp=trunk%2FPLC%2FMethods%2FSliceNodesList.py;h=0c44f66e34e60657a6d96cb6ed2d1df658bf4d5b;hb=5a4c1b1278ffa01e630fde47f7c54888ed20a576;hp=0000000000000000000000000000000000000000;hpb=cee5ab52df1c9f38b6eaff2dd354cb22f59028c7;p=plcapi.git diff --git a/trunk/PLC/Methods/SliceNodesList.py b/trunk/PLC/Methods/SliceNodesList.py new file mode 100644 index 0000000..0c44f66 --- /dev/null +++ b/trunk/PLC/Methods/SliceNodesList.py @@ -0,0 +1,40 @@ +from PLC.Method import Method +from PLC.Parameter import Parameter, Mixed +from PLC.Filter import Filter +from PLC.Auth import Auth +from PLC.Slices import Slice, Slices +from PLC.Nodes import Node, Nodes +from PLC.Methods.GetSlices import GetSlices +from PLC.Methods.GetNodes import GetNodes + +class SliceNodesList(GetSlices, GetNodes): + """ + Deprecated. Can be implemented with GetSlices and GetNodes. + + """ + + status = "deprecated" + + roles = ['admin', 'pi', 'user'] + + accepts = [ + Auth(), + Slice.fields['name'] + ] + + returns = [Node.fields['hostname']] + + + def call(self, auth, slice_name): + slices = GetSlices.call(self, auth, [slice_name]) + if not slices: + return [] + + slice = slices[0] + nodes = GetNodes.call(self, auth, slice['node_ids']) + if not nodes: + return [] + + node_hostnames = [node['hostname'] for node in nodes] + + return node_hostnames