1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 from twisted.internet import defer
20
21 from flumotion.common import log
22
23 __version__ = "$Rev$"
24
25
26 -class Plug(object, log.Loggable):
27 """
28 Base class for plugs. Provides an __init__ method that receives the
29 plug args and sets them to the 'args' attribute.
30 """
31
33 """
34 @param args: The plug args
35 @type args: dict with keys 'socket', 'type', and 'properties'.
36 'properties' has the same format as component
37 properties.
38 """
39 self.args = args
40
41
43 """
44 Base class for plugs that live in a component. Subclasses can
45 implement the start and stop vmethods, which will be called with the
46 component as an argument. Both of them can return a deferred.
47 """
48
49 - def start(self, component):
51
52 - def stop(self, component):
54
58
59
61 """
62 Base class for plugs that live in the manager. Subclasses can
63 implement the start and stop vmethods, which will be called with the
64 manager vishnu as an argument.
65 """
66
69
70 - def stop(self, vishnu):
72
76
77
79 """
80 Example implementation of the ManagerLifecyle socket, just prints
81 things on the console. Pretty stupid!
82 """
83
85 info = vishnu.connectionInfo
86 print ('started manager running on %s:%d (%s)'
87 % (info['host'], info['port'],
88 info['using_ssl'] and 'with ssl' or 'without ssl'))
89
90 - def stop(self, vishnu):
91 info = vishnu.connectionInfo
92 print ('stopped manager running on %s:%d (%s)'
93 % (info['host'], info['port'],
94 info['using_ssl'] and 'with ssl' or 'without ssl'))
95
96
98 """
99 Example implementation of the ComponentLifecyle socket, just prints
100 things on the console. Pretty stupid!
101 """
102
103 - def start(self, component):
104 print 'Component has been started'
105
106 - def stop(self, component):
107 print 'Component is stopping'
108