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 PasswordAuth
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
18 roles = ['admin', 'pi', 'tech']
25 returns = [{'node_id': Parameter(int, "Node identifier"),
26 'port_number': Parameter(int, "Port number")}]
28 def call(self, auth, pcu_id):
29 pcus = PCUs(self.api, [pcu_id]).values()
31 raise PLCInvalidArgument, "No such PCU"
34 if 'admin' not in self.caller['roles']:
35 if pcu['site_id'] not in self.caller['site_ids']:
36 raise PLCPermissionDenied, "Not allowed to view that PCU"
38 return [{'node_id': node_id, 'port_number': port} \
39 for (node_id, port) in zip(pcu['node_ids'], pcu['ports'])]