Package flumotion :: Package component :: Package plugs :: Module identity
[hide private]

Source Code for Module flumotion.component.plugs.identity

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3   
 4  # Flumotion - a streaming media server 
 5  # Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L. 
 6  # Copyright (C) 2010,2011 Flumotion Services, S.A. 
 7  # All rights reserved. 
 8  # 
 9  # This file may be distributed and/or modified under the terms of 
10  # the GNU Lesser General Public License version 2.1 as published by 
11  # the Free Software Foundation. 
12  # This file is distributed without any warranty; without even the implied 
13  # warranty of merchantability or fitness for a particular purpose. 
14  # See "LICENSE.LGPL" in the source distribution for more information. 
15  # 
16  # Headers in this file shall remain intact. 
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   
29 -class IdentityProviderPlug(base.ManagerPlug):
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
36 - def computeIdentity(self, keycard, remoteHost):
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
49 -class IdentityProviderExamplePlug(IdentityProviderPlug):
50 """ 51 Example implementation of the IdentityProviderPlug socket, randomly 52 chooses an identity for the remote host. 53 """ 54
55 - def computeIdentity(self, keycard, remoteHost):
56 i = RemoteIdentity(random.choice(['larry', 'curly', 'moe']), 57 random.choice(['chicago', 'detroit'])) 58 return defer.succeed(i)
59