1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import os
18 from ConfigParser import SafeConfigParser
19
20
21
22 config = None
23
24
25 _default_values = {
26 'logs': {
27 'level': 'info',
28 'max_size': '1048576',
29 'backups': '4',
30 'pulp_file': '/var/log/pulp/pulp.log',
31 'grinder_file': '/var/log/pulp/grinder.log',
32 },
33 'auditing': {
34 'events_file': '/var/log/pulp/events.log',
35 'lifetime': '90',
36 'backups': '4',
37 },
38 'security': {
39 'cacert': '/etc/pki/pulp/ca.crt',
40 'cakey': '/etc/pki/pulp/ca.key',
41 },
42 }
43
44
45 _config_files = ['/etc/pulp/pulp.conf']
46
47
48
50 """
51 Check for read permissions on the configuration files. Raise a runtime error
52 if the file doesn't exist or the read permissions are lacking.
53 """
54 for file in _config_files:
55 if not os.access(file, os.F_OK):
56 raise RuntimeError('Cannot find configuration file: %s' % file)
57 if not os.access(file, os.R_OK):
58 raise RuntimeError('Cannot read configuration file: %s' % file)
59 return 'Yeah!'
60
61
76
77
79 """
80 Convenience function to add a new file to the list of configuration files,
81 then re-load the global config and re-configure logging.
82
83 @type file_path: str
84 @param file_path: full path to the new file to add
85 """
86 global _config_files
87 if file_path in _config_files:
88 raise RuntimeError('File, %s, already in configuration files' % file_path)
89 _config_files.append(file_path)
90 load_configuration()
91
92
94 """
95 Convenience function to remove a file from the list of configuration files,
96 then re-load the global config and re-configure logging.
97
98 @type file_path: str
99 @param file_path: full path to the file to remove
100 """
101 global _config_files
102 if file_path not in _config_files:
103 raise RuntimeError('File, %s, not in configuration files' % file_path)
104 _config_files.remove(file_path)
105 load_configuration()
106
107
108
109 load_configuration()
110