Package gofer :: Module proxy
[hide private]
[frames] | no frames]

Source Code for Module gofer.proxy

 1  # 
 2  # Copyright (c) 2011 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU Lesser General Public 
 5  # License as published by the Free Software Foundation; either version 
 6  # 2 of the License (LGPLv2) or (at your option) any later version. 
 7  # There is NO WARRANTY for this software, express or implied, 
 8  # including the implied warranties of MERCHANTABILITY, 
 9  # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should 
10  # have received a copy of LGPLv2 along with this software; if not, see 
11  # http://www.gnu.org/licenses/old-licenses/lgpl-2.0.txt. 
12  # 
13  # Jeff Ortel <jortel@redhat.com> 
14  # 
15   
16  from gofer.rmi.container import Container 
17  from gofer.messaging.producer import Producer 
18  from logging import getLogger 
19   
20  log = getLogger(__name__) 
21   
22   
23 -def Agent(uuid, **options):
24 """ backwards compat """ 25 return agent(uuid, **options)
26 27
28 -def agent(uuid, **options):
29 """ 30 Get a proxy for the remote Agent. 31 @param uuid: An agent ID. 32 May be tuple (<container>,<agent>) 33 @type uuid: (str|tuple) 34 @return: An agent (proxy). 35 @rtype: L{Container} 36 """ 37 if not isinstance(uuid, tuple): 38 uuid = (None, uuid) 39 url = options.pop('url', None) 40 p = Producer(uuid=uuid[0], url=url) 41 return Container(uuid[1], p, **options)
42 43
44 -def delete(agent):
45 """ 46 Delete associated AMQP resources. 47 @param agent: A gofer agent. 48 @type agent: L{Container} 49 """ 50 if isinstance(agent, Container): 51 queue = agent._Container__destination() 52 method = agent._Container__options.method 53 session = method.producer.session() 54 queue.delete(session) 55 else: 56 pass
57