1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Filter import Filter
5 from PLC.Nodes import Node, Nodes
6 from PLC.Persons import Person, Persons
7 from PLC.Auth import Auth
9 class GetNodes(Method):
11 Returns an array of structs containing details about nodes. If
12 node_filter is specified and is an array of node identifiers or
13 hostnames, or a struct of node attributes, only nodes matching the
14 filter will be returned. If return_fields is specified, only the
15 specified details will be returned.
17 Some fields may only be viewed by admins.
20 roles = ['admin', 'pi', 'user', 'tech', 'node', 'anonymous']
24 Mixed([Mixed(Node.fields['node_id'],
25 Node.fields['hostname'])],
27 Parameter([str], "List of fields to return", nullok = True),
30 returns = [Node.fields]
33 def call(self, auth, node_filter = None, return_fields = None):
34 # Get node information
35 nodes = Nodes(self.api, node_filter, return_fields)
37 # Remove admin only fields
38 if not isinstance(self.caller, Person) or \
39 'admin' not in self.caller['roles']:
41 for field in ['boot_nonce', 'key', 'session', 'root_person_ids']: