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