1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 Contains REPO event handler classes.
19 """
20
21 from pulp.server.event.dispatcher import *
22 from pulp.server.api.repo import RepoApi
23 from pulp.messaging.producer import EventProducer
24 from logging import getLogger
25
26 log = getLogger(__name__)
27
28
29 @handler(entity='repo')
30 -class RepoEvent(EventHandler):
31 """
32 The I{repo} event handler.
33 @ivar rapi: The repo API object.
34 @type rapi: L{RepoApi}
35 """
36
40
41 @outbound(action='created')
42 - def create(self, *args, **kwargs):
43 """
44 Raise events when a repo is created.
45 Called when RepoApi.create() is called.
46 @param args: The arguments passed to RepoApi.create()
47 @type args: list
48 @param kwargs: The keyword arguments passed to RepoApi.create()
49 @type kwargs: list
50 """
51 event = dict(
52 id=args[1],
53 name=args[2],)
54 self.producer.send('repo.created', event)
55
56 @outbound(action='updated')
57 - def update(self, *args, **kwargs):
58 """
59 Raise events when a repo is updated.
60 Called when RepoApi.update() is called.
61 @param args: The arguments passed to RepoApi.update()
62 @type args: list
63 @param kwargs: The keyword arguments passed to RepoApi.update()
64 @type kwargs: list
65 """
66 pass
67
68 @outbound(action='deleted')
69 - def delete(self, *args, **kwargs):
70 """
71 Raise events when a repo is deleted.
72 Called when RepoApi.delete() is called.
73 @param args: The arguments passed to RepoApi.delete()
74 @type args: list
75 @param kwargs: The keyword arguments passed to RepoApi.delete()
76 @type kwargs: list
77 """
78 pass
79
80 @inbound(action='created')
82 """
83 The I{inbound} event handler for repo.created AMQP events.
84 Called when an AMQP event is received notifying that
85 a repo has been created. When received, the API is used
86 to create the specified repo in pulp.
87 @param event: The event payload.
88 @type event: dict.
89 """
90 id = event['id']
91 name = event['name']
92 arch = event.get('arch', 'noarch')
93 self.rapi.create(id, name, arch)
94
95 @inbound(action='updated')
97 """
98 The I{inbound} event handler for repo.updated AMQP events.
99 Called when an AMQP event is received notifying that
100 a repo has been created. When received, the API is used
101 to update the specified repo in pulp.
102 @param event: The event payload.
103 @type event: dict.
104 """
105 pass
106
107 @inbound(action='deleted')
109 """
110 The I{inbound} event handler for repo.deleted AMQP events.
111 Called when an AMQP event is received notifying that
112 a repo has been deleted. When received, the API is used
113 to delete the specified repo in pulp.
114 @param event: The event payload.
115 @type event: dict.
116 """
117 pass
118