Package pulp :: Package client :: Package agent :: Package plugins :: Module actions
[hide private]
[frames] | no frames]

Source Code for Module pulp.client.agent.plugins.actions

 1  # 
 2  # Copyright (c) 2010 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU General Public License, 
 5  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 6  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 8  # along with this software; if not, see 
 9  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
10  # 
11  # Red Hat trademarks are not licensed under GPLv2. No permission is 
12  # granted to use or replicate Red Hat trademarks that are incorporated 
13  # in this software or its documentation. 
14  # 
15   
16  """ 
17  Action classes for pulp agent. 
18  ** Add custome actions here ** 
19  """ 
20   
21  from pulp.client import ConsumerId 
22  from pulp.client.agent.action import * 
23  from pulp.client.connection import ConsumerConnection, RestlibException 
24  from pulp.client.package_profile import PackageProfile 
25  from pulp.client.config import Config 
26  from logging import getLogger 
27   
28  log = getLogger(__name__) 
29  cfg = Config() 
30 31 32 @action(minutes=10) 33 -class TestAction(Action):
34
35 - def perform(self):
36 log.info('Hello')
37
38 39 @action(minutes=cfg.server.interval) 40 -class ProfileUpdateAction(Action):
41 """ 42 Package Profile Update Action to update installed package info for a 43 registered consumer 44 """ 45
46 - def perform(self):
47 """ 48 Looks up the consumer id and latest pkg profile info and cals 49 the api to update the consumer profile 50 """ 51 cid = ConsumerId() 52 if not cid.exists(): 53 log.error("Not Registered") 54 return 55 try: 56 cconn = ConsumerConnection(host=cfg.server.host or "localhost", 57 port=cfg.server.port or 443) 58 pkginfo = PackageProfile().getPackageList() 59 cconn.profile(cid.read(), pkginfo) 60 log.info("Profile updated successfully for consumer %s" % cid.read()) 61 except RestlibException, re: 62 log.error("Error: %s" % re) 63 except Exception, e: 64 log.error("Error: %s" % e)
65