Package backend :: Package server :: Package action :: Module script
[hide private]
[frames] | no frames]

Source Code for Module backend.server.action.script

 1  # 
 2  # Copyright (c) 2008--2015 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  # remote script functions 
16  # 
17   
18  from spacewalk.common.rhnLog import log_debug 
19  from spacewalk.server import rhnSQL 
20   
21  # the "exposed" functions 
22  __rhnexport__ = ['run'] 
23   
24  _query_action_script = rhnSQL.Statement(""" 
25      select script, username, groupname, timeout, 
26             TO_CHAR(current_timestamp, 'YYYY-MM-DD HH24:MI:SS') as now 
27        from rhnActionScript 
28       where action_id = :action_id 
29  """) 
30   
31   
32 -def run(server_id, action_id, dry_run=0):
33 log_debug(3, dry_run) 34 35 data = {} 36 37 h = rhnSQL.prepare(_query_action_script) 38 h.execute(action_id=action_id) 39 40 info = h.fetchone_dict() or [] 41 42 if info: 43 data['username'] = info['username'] 44 data['groupname'] = info['groupname'] 45 data['timeout'] = info['timeout'] or '' 46 data['script'] = rhnSQL.read_lob(info['script']) or '' 47 # used to make the resulting times make some sense in the db 48 data['now'] = info['now'] 49 50 return action_id, data
51