3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.NodeNetworks import NodeNetwork, NodeNetworks
7 from PLC.Nodes import Node, Nodes
8 from PLC.Auth import PasswordAuth
10 class AdmGetAllNodeNetworks(Method):
12 Returns all the networks this node is connected to, as an array of
17 roles = ['admin', 'pi', 'user', 'tech']
21 Mixed(Node.fields['node_id'],
22 Node.fields['hostname'])
25 returns = [NodeNetwork.all_fields]
27 def call(self, auth, node_id_or_hostname):
28 # Authenticated function
29 assert self.caller is not None
31 # Get node information
32 nodes = Nodes(self.api, [node_id_or_hostname], NodeNetwork.all_fields).values()
34 raise PLCInvalidArgument, "No such node"
37 # Get node networks for this node
38 nodenetwork_ids = node['nodenetwork_ids']
39 if not nodenetwork_ids:
40 raise PLCInvalidArgument, "Node has no node networks"
41 nodenetworks = NodeNetworks(self.api, nodenetwork_ids).values()