1
2
3
4
5
6
7
8
9
10
11
12
13
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
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
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