oops, undefined variable
[plcapi.git] / PLC / Methods / UpdateIlink.py
1 #
2 # Thierry Parmentelat - INRIA
3 #
4 # $Revision: 9423 $
5 #
6
7 from PLC.Faults import *
8 from PLC.Method import Method
9 from PLC.Parameter import Parameter, Mixed
10 from PLC.Auth import Auth
11
12 from PLC.Ilinks import Ilink, Ilinks
13 from PLC.Interfaces import Interface, Interfaces
14
15 from PLC.Sites import Sites
16
17 class UpdateIlink(Method):
18     """
19     Updates the value of an existing ilink
20
21     Access rights depend on the tag type.
22
23     Returns 1 if successful, faults otherwise.
24     """
25
26     roles = ['admin', 'pi', 'tech', 'user']
27
28     accepts = [
29         Auth(),
30         Ilink.fields['ilink_id'],
31         Ilink.fields['value']
32         ]
33
34     returns = Parameter(int, '1 if successful')
35
36     object_type = 'Interface'
37
38     def call(self, auth, ilink_id, value):
39         ilinks = Ilinks(self.api, [ilink_id])
40         if not ilinks:
41             raise PLCInvalidArgument, "No such ilink %r"%ilink_id
42         ilink = ilinks[0]
43
44         # xxx see AddIlink for this - should be written once in the Ilink class I guess
45         # checks rights and stuff
46
47         ilink['value'] = value
48         ilink.sync()
49
50         self.object_ids = [ilink['src_interface_id'],ilink['dst_interface_id']]
51         return 1