Package pulp :: Package server :: Package event :: Package handler :: Module repo
[hide private]
[frames] | no frames]

Source Code for Module pulp.server.event.handler.repo

  1  #! /usr/bin/env python 
  2  # 
  3  # Copyright (c) 2010 Red Hat, Inc. 
  4  # 
  5  # This software is licensed to you under the GNU General Public License, 
  6  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
  7  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
  8  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
  9  # along with this software; if not, see 
 10  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
 11  # 
 12  # Red Hat trademarks are not licensed under GPLv2. No permission is 
 13  # granted to use or replicate Red Hat trademarks that are incorporated 
 14  # in this software or its documentation. 
 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
37 - def __init__(self):
38 self.rapi = RepoApi() 39 self.producer = EventProducer()
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')
81 - def created(self, event):
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')
96 - def updated(self, event):
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')
108 - def deleted(self, event):
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