2 # Thierry Parmentelat - INRIA
7 from PLC.Faults import *
8 from PLC.Method import Method
9 from PLC.Parameter import Parameter, Mixed
10 from PLC.Auth import Auth
12 from PLC.Ilinks import Ilink, Ilinks
13 from PLC.Interfaces import Interface, Interfaces
15 from PLC.Sites import Sites
17 class UpdateIlink(Method):
19 Updates the value of an existing ilink
21 Access rights depend on the ilink type.
23 Returns 1 if successful, faults otherwise.
26 roles = ['admin', 'pi', 'tech', 'user']
30 Ilink.fields['ilink_id'],
34 returns = Parameter(int, '1 if successful')
36 object_type = 'Interface'
38 def call(self, auth, ilink_id, value):
39 ilinks = Ilinks(self.api, [ilink_id])
41 raise PLCInvalidArgument, "No such ilink %r"%ilink_id
44 if 'admin' not in self.caller['roles']:
45 # # check permission : it not admin, is the user affiliated with the right site
47 # node = Nodes (self.api,[node['node_id']])[0]
49 # site = Sites (self.api, [node['site_id']])[0]
50 # # check caller is affiliated with this site
51 # if self.caller['person_id'] not in site['person_ids']:
52 # raise PLCPermissionDenied, "Not a member of the hosting site %s"%site['abbreviated_site']
54 required_min_role = link_type ['min_role_id']
55 if required_min_role is not None and \
56 min(self.caller['role_ids']) > required_min_role:
57 raise PLCPermissionDenied, "Not allowed to modify the specified ilink, requires role %d",required_min_role
59 ilink['value'] = value
62 self.object_ids = [ilink['src_interface_id'],ilink['dst_interface_id']]