summaryrefslogtreecommitdiffstats
path: root/ipalib/constants.py
blob: 494e51a3cda0fa44281ecb1adbd458647e4660d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Authors:
#   Martin Nagy <mnagy@redhat.com>
#   Jason Gerard DeRose <jderose@redhat.com>
#
# Copyright (C) 2008  Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; version 2 only
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

"""
All constants centralised in one file.
"""

# The parameter system treats all these values as None:
NULLS = (None, '', u'', tuple(), [])

# regular expression NameSpace member names must match:
NAME_REGEX = r'^[a-z][_a-z0-9]*[a-z0-9]$'

# Format for ValueError raised when name does not match above regex:
NAME_ERROR = 'name must match %r; got %r'

# Standard format for TypeError message:
TYPE_ERROR = '%s: need a %r; got %r (a %r)'

# Stardard format for TypeError message when a callable is expected:
CALLABLE_ERROR = '%s: need a callable; got %r (which is a %r)'

# Standard format for StandardError message when overriding an attribute:
OVERRIDE_ERROR = 'cannot override %s.%s value %r with %r'

# Standard format for AttributeError message when a read-only attribute is
# already locked:
SET_ERROR = 'locked: cannot set %s.%s to %r'
DEL_ERROR = 'locked: cannot delete %s.%s'

# Used for a tab (or indentation level) when formatting for CLI:
CLI_TAB = '  '  # Two spaces

# The section to read in the config files, i.e. [global]
CONFIG_SECTION = 'global'

# Log format for stderr:
FORMAT_STDERR = ': '.join([
    'ipa',
    '%(levelname)s',
    '%(message)s',
])

# Log format for log file:
FORMAT_FILE = '\t'.join([
    '%(created)f',
    '%(process)d',
    '%(threadName)s',
    '%(levelname)s',
    '%(message)r', # Using %r for repr() so message is a single line
])


# The default configuration for api.env
# This is a tuple instead of a dict so that it is immutable.
# To create a dict with this config, just "d = dict(DEFAULT_CONFIG)".
DEFAULT_CONFIG = (
    # Domain, realm, basedn:
    ('domain', 'example.com'),
    ('realm', 'EXAMPLE.COM'),
    ('basedn', 'dc=example,dc=com'),

    # LDAP containers:
    ('container_accounts', 'cn=accounts'),
    ('container_user', 'cn=users,cn=accounts'),
    ('container_group', 'cn=groups,cn=accounts'),
    ('container_service', 'cn=services,cn=accounts'),
    ('container_host', 'cn=computers,cn=accounts'),
    ('container_hostgroup', 'cn=hostgroups,cn=accounts'),
    ('container_automount', 'cn=automount'),

    # Ports, hosts, and URIs:
    ('lite_xmlrpc_port', 8888),
    ('lite_webui_port', 9999),
    ('xmlrpc_uri', 'http://localhost:8888'),
    ('ldap_uri', 'ldap://localhost:389'),
    ('ldap_host', 'localhost'),
    ('ldap_port', 389),

    # Debugging:
    ('verbose', False),
    ('debug', False),
    ('mode', 'production'),

    # CA plugin:
    ('ca_host', object),  # Set in Env._finalize_core()
    ('ca_port', 9180),
    ('ca_ssl_port', 9443),

    # Special CLI:
    ('prompt_all', False),
    ('interactive', True),

    # ********************************************************
    #  The remaining keys are never set from the values here!
    # ********************************************************
    #
    # Env.__init__() or Env._bootstrap() or Env._finalize_core()
    # will have filled in all the keys below by the time DEFAULT_CONFIG
    # is merged in, so the values below are never actually used. They are
    # listed both to provide a big picture and also so DEFAULT_CONFIG contains
    # at least all the keys that should be present after Env._finalize_core()
    # is called.
    #
    # Each environment variable below is sent to ``object``, which just happens
    # to be an invalid value for an environment variable, so if for some reason
    # any of these keys were set from the values here, an exception will be
    # raised.

    # Set in Env.__init__():
    ('host', object),
    ('ipalib', object), # The directory containing ipalib/__init__.py
    ('site_packages', object), # The directory contaning ipalib
    ('script', object), # sys.argv[0]
    ('bin', object), # The directory containing script
    ('home', object), # The home directory of user underwhich process is running
    ('dot_ipa', object), # ~/.ipa directory

    # Set in Env._bootstrap():
    ('in_tree', object), # Whether or not running in-tree (bool)
    ('context', object), # Name of context, default is 'default'
    ('conf', object), # Path to config file
    ('conf_default', object), # Path to common default config file
    ('conf_dir', object), # Directory containing config files

    # Set in Env._finalize_core():
    ('in_server', object), # Whether or not running in-server (bool)
    ('log', object), # Path to log file

)