1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.PCUs import PCU, PCUs
5 from PLC.Auth import Auth
7 class AdmGetPowerControlUnitNodes(Method):
9 Deprecated. See GetPCUs.
11 Returns a list of the nodes, and the ports they are assigned to,
14 Admin may query all PCUs. Non-admins may only query the PCUs at
20 roles = ['admin', 'pi', 'tech']
27 returns = [{'node_id': Parameter(int, "Node identifier"),
28 'port_number': Parameter(int, "Port number")}]
30 def call(self, auth, pcu_id):
31 pcus = PCUs(self.api, [pcu_id])
33 raise PLCInvalidArgument, "No such PCU"
36 if 'admin' not in self.caller['roles']:
37 if pcu['site_id'] not in self.caller['site_ids']:
38 raise PLCPermissionDenied, "Not allowed to view that PCU"
40 return [{'node_id': node_id, 'port_number': port} \
41 for (node_id, port) in zip(pcu['node_ids'], pcu['ports'])]