590181a0b525092d6a313278082ab4da2bf0fe9a
[plcapi.git] / PLC / Methods / SliceNodesList.py
1 # $Id$
2 # $URL$
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Filter import Filter
6 from PLC.Auth import Auth
7 from PLC.Slices import Slice, Slices
8 from PLC.Nodes import Node, Nodes
9 from PLC.Methods.GetSlices import GetSlices
10 from PLC.Methods.GetNodes import GetNodes
11
12 class SliceNodesList(GetSlices, GetNodes):
13     """
14     Deprecated. Can be implemented with GetSlices and GetNodes.
15
16     """
17   
18     status = "deprecated"
19
20     roles = ['admin', 'pi', 'user']
21
22     accepts = [
23         Auth(),
24         Slice.fields['name']
25         ]
26
27     returns = [Node.fields['hostname']]
28     
29
30     def call(self, auth, slice_name):
31         slices = GetSlices.call(self, auth, [slice_name])
32         if not slices:
33             return []
34
35         slice = slices[0]
36         nodes = GetNodes.call(self, auth, slice['node_ids'])
37         if not nodes:
38             return []
39         
40         node_hostnames = [node['hostname'] for node in nodes]           
41         
42         return node_hostnames