1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import time
23
24 from twisted.python import reflect
25
26 from flumotion.common import errors, log, common
27 from flumotion.component.plugs import base
28
29 __version__ = "$Rev: 6125 $"
30
31
33 """
34 Base class for plugs that can react to actions by an admin. For
35 example, some plugs might want to check that the admin in question
36 has the right permissions, and some others might want to log the
37 action to a database. Defines the admin action API methods.
38 """
39 - def action(self, identity, method, args, kwargs):
40 """
41 @type identity: L{flumotion.common.identity.Identity}
42 @type method: str
43 @type args: list
44 @type kwargs: dict
45 """
46 raise NotImplementedError('subclasses have to override me')
47
48
50 filename = None
51 file = None
52
61
62 - def stop(self, vishnu):
63 self.file.close()
64 self.file = None
65
66 - def action(self, identity, method, args, kwargs):
67
68 s = ('[%04d-%02d-%02d %02d:%02d:%02d] %s: %s: %r %r\n'
69 % (time.gmtime()[:6] +
70 ((identity, method, args, kwargs))))
71 self.file.write(s)
72 self.file.flush()
73