X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAdmGetPowerControlUnitNodes.py;h=af298ee0b208131505728b9370eaae19603bf949;hb=2c63f41e29a7ae2cea6546c06a1838a6fc2daccf;hp=9bd48f55d109c06dbfbf33320ab83cd4e75ba032;hpb=4a8cf62c77ad97f07c1bac37eb0cc5e8effe72f0;p=plcapi.git diff --git a/PLC/Methods/AdmGetPowerControlUnitNodes.py b/PLC/Methods/AdmGetPowerControlUnitNodes.py index 9bd48f5..af298ee 100644 --- a/PLC/Methods/AdmGetPowerControlUnitNodes.py +++ b/PLC/Methods/AdmGetPowerControlUnitNodes.py @@ -2,10 +2,9 @@ from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed from PLC.PCUs import PCU, PCUs -from PLC.Auth import PasswordAuth -from PLC.Methods.GetPCUs import GetPCUs +from PLC.Auth import Auth -class AdmGetPowerControlUnitNodes(GetPCUs): +class AdmGetPowerControlUnitNodes(Method): """ Deprecated. See GetPCUs. @@ -16,10 +15,12 @@ class AdmGetPowerControlUnitNodes(GetPCUs): their sites. """ + status = "deprecated" + roles = ['admin', 'pi', 'tech'] accepts = [ - PasswordAuth(), + Auth(), PCU.fields['pcu_id'] ] @@ -27,10 +28,14 @@ class AdmGetPowerControlUnitNodes(GetPCUs): 'port_number': Parameter(int, "Port number")}] def call(self, auth, pcu_id): - pcus = GetPCUs.call(self, auth, [pcu_id]) + pcus = PCUs(self.api, [pcu_id]) if not pcus: raise PLCInvalidArgument, "No such PCU" pcu = pcus[0] + if 'admin' not in self.caller['roles']: + if pcu['site_id'] not in self.caller['site_ids']: + raise PLCPermissionDenied, "Not allowed to view that PCU" + return [{'node_id': node_id, 'port_number': port} \ for (node_id, port) in zip(pcu['node_ids'], pcu['ports'])]