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