1
2
3
4
5
6
7
8
9
10
11
12
13
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
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