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

Source Code for Module backend.server.action.scap

 1  # 
 2  # Copyright (c) 2012--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   
16  from spacewalk.common.rhnLog import log_debug 
17  from spacewalk.server import rhnSQL 
18  from spacewalk.server.rhnLib import InvalidAction 
19   
20  __rhnexport__ = ['xccdf_eval'] 
21   
22   
23 -def xccdf_eval(server_id, action_id, dry_run=0):
24 log_debug(3) 25 statement = """ 26 select path, parameters 27 from rhnActionScap 28 where action_id = :action_id""" 29 h = rhnSQL.prepare(statement) 30 h.execute(action_id=action_id) 31 d = h.fetchone_dict() 32 if not d: 33 raise InvalidAction("scap.xccdf_eval: Unknown action id " 34 "%s for server %s" % (action_id, server_id)) 35 return ({ 36 'path': d['path'], 37 'id': action_id, 38 'file_size': _scap_file_limit(server_id), 39 'params': rhnSQL.read_lob(d['parameters']) or '' 40 },)
41 42
43 -def _scap_file_limit(server_id):
44 statement = """ 45 select roc.scap_file_sizelimit as limit, roc.scapfile_upload_enabled as enabled 46 from rhnOrgConfiguration roc, 47 rhnServer rs 48 where rs.id = :server_id 49 and rs.org_id = roc.org_id""" 50 h = rhnSQL.prepare(statement) 51 h.execute(server_id=server_id) 52 d = h.fetchone_dict() 53 if not d or d['enabled'] != 'Y': 54 return 0 55 return d['limit']
56