1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import random
20
21 from flumotion.twisted import defer
22
23 from flumotion.common.identity import RemoteIdentity
24 from flumotion.component.plugs import base
25
26 __version__ = "$Rev$"
27
28
30 """
31 Base class for plugs can calculate an identity of a remote host. See
32 L{flumotion.manager.manager.Vishnu.computeIdentity} for more
33 information.
34 """
35
37 """
38 @param keycard: the keycard that the remote host used to log in.
39 @type keycard: L{flumotion.common.keycards.Keycard}
40 @param remoteHost: the ip of the remote host
41 @type remoteHost: str
42
43 @rtype: a deferred that will fire a
44 L{flumotion.common.identity.RemoteIdentity}
45 """
46 raise NotImplementedError
47
48
50 """
51 Example implementation of the IdentityProviderPlug socket, randomly
52 chooses an identity for the remote host.
53 """
54
56 i = RemoteIdentity(random.choice(['larry', 'curly', 'moe']),
57 random.choice(['chicago', 'detroit']))
58 return defer.succeed(i)
59