univention.config_registry package¶
Univention Configuration Registry module.
Submodules¶
univention.config_registry.backend module¶
Univention Configuration Registry backend for data storage.
-
exception
univention.config_registry.backend.
StrictModeException
[source]¶ Bases:
exceptions.Exception
Attempt to store non-UTF-8 characters in strict UTF-8 mode.
-
univention.config_registry.backend.
exception_occured
(out=<open file '<stderr>', mode 'w'>)[source]¶ Print exception message and exit.
Parameters: out – Output stream for message.
-
class
univention.config_registry.backend.
ConfigRegistry
(filename=None, write_registry=0)[source]¶ Bases:
_abcoll.MutableMapping
Merged persistent value store. This is a merged view of several sub-registries.
Parameters: - filename – File name for text database file.
- write_registry – The UCR level used for writing.
-
BASES
= {0: 'base.conf', 1: 'base-ldap.conf', 2: 'base-schedule.conf', 3: 'base-forced.conf'}¶
-
CUSTOM
= 4¶
-
FORCED
= 3¶
-
LAYER_PRIORITIES
= (3, 2, 1, 0, 4)¶
-
LDAP
= 1¶
-
NORMAL
= 0¶
-
PREFIX
= '/etc/univention'¶
-
SCHEDULE
= 2¶
-
_abc_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache
= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version
= 31¶
-
_abc_registry
= <_weakrefset.WeakSet object>¶
-
_create_registry
(reg)[source]¶ Create internal sub registry.
Parameters: reg – UCR level. Returns: UCR instance.
-
_merge
(getscope=False)[source]¶ Merge sub registry.
Parameters: getscope – True makes the method return the scope level in addition to the value itself. Returns: A mapping from varibal ename to eiter the value (if getscope is False) or a 2-tuple (level, value).
-
get
(key, default=None, getscope=False)[source]¶ Return registry value (including optional scope).
Parameters: - key – UCR variable name.
- default – Default value when the UCR variable is not set.
- getscope – True makes the method return the scope level in addition to the value itself.
Returns: the value or a 2-tuple (level, value) or the default.
-
has_key
(key, write_registry_only=False)[source]¶ Check if registry key is set.
Deprecated since version 3.1: Use in.
-
is_false
(key=None, default=False, value=None)[source]¶ Return if the strings value of key is considered as false.
Parameters: - key – UCR variable name.
- default – Default value to return, if UCR variable is not set.
- value – text string to directly evaulate instead of looking up the key.
Returns: True when the value is one of no, false, 0, disable, disabled, off.
>>> ucr = ConfigRegistry('/dev/null') >>> ucr['key'] = 'no' >>> ucr.is_false('key') True >>> ucr.is_false('other') False >>> ucr.is_false('other', True) True >>> ucr.is_false(value='0') True
-
is_true
(key=None, default=False, value=None)[source]¶ Return if the strings value of key is considered as true.
Parameters: - key – UCR variable name.
- default – Default value to return, if UCR variable is not set.
- value – text string to directly evaulate instead of looking up the key.
Returns: True when the value is one of yes, true, 1, enable, enabled, on.
>>> ucr = ConfigRegistry('/dev/null') >>> ucr['key'] = 'yes' >>> ucr.is_true('key') True >>> ucr.is_true('other') False >>> ucr.is_true('other', True) True >>> ucr.is_true(value='1') True
-
items
(getscope=False)[source]¶ Return all registry entries a 2-tuple (key, value) or (key, (scope, value)) if getscope is True.
Parameters: getscope – True makes the method return the scope level in addition to the value itself. Returns: A mapping from varibal ename to eiter the value (if getscope is False) or a 2-tuple (level, value).
univention.config_registry.filters module¶
Univention Configuration Registry output filters.
-
univention.config_registry.filters.
filter_shell
(args, text)[source]¶ Filter output for shell: escape keys.
Parameters: - args – UNUSED.
- text – Text as list of lines.
Returns: Filteres list of lines.
univention.config_registry.frontend module¶
Univention Configuration Registry command line implementation.
-
exception
univention.config_registry.frontend.
UnknownKeyException
(value)[source]¶ Bases:
exceptions.Exception
Query for unknown key: no info file nor set.
-
univention.config_registry.frontend.
handler_set
(args, opts={}, quiet=False)[source]¶ Set config registry variables in args. Args is an array of strings ‘key=value’ or ‘key?value’.
Parameters: - args – Command line arguments.
- opts – Command line options.
- quiet – Hide output.
-
univention.config_registry.frontend.
handler_unset
(args, opts={})[source]¶ Unset config registry variables in args.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_dump
(args, opts={})[source]¶ Dump all variables.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_update
(args, opts={})[source]¶ Update handlers.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_commit
(args, opts={})[source]¶ Commit all registered templated files.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_register
(args, opts={})[source]¶ Register new .info file.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_unregister
(args, opts={})[source]¶ Unregister old .info file.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_filter
(args, opts={})[source]¶ Run filter on STDIN to STDOUT.
-
univention.config_registry.frontend.
handler_search
(args, opts={})[source]¶ Search for registry variable.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_get
(args, opts={})[source]¶ Return config registry variable.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_info
(args, opts={})[source]¶ Print variable info.
Parameters: - args – Command line arguments.
- opts – Command line options.
-
univention.config_registry.frontend.
handler_version
(args, opts={})[source]¶ Print version info.
Parameters: - args – Command line arguments.
- opts – Command line options.
univention.config_registry.handler module¶
Univention Configuration Registry handlers.
-
class
univention.config_registry.handler.
ConfigHandlers
[source]¶ Manage handlers for configuration variables.
-
CACHE_FILE
= '/var/cache/univention-config/cache'¶
-
VERSION
= 3¶
-
VERSION_MAX
= 3¶
-
VERSION_MIN
= 3¶
-
VERSION_NOTICE
= 'univention-config cache, version 3\n'¶
-
VERSION_RE
= <_sre.SRE_Pattern object>¶
-
VERSION_TEXT
= 'univention-config cache, version'¶
-
static
_get_cache_version
(cache_file)[source]¶ Read cached .info data.
Parameters: cache_file – Opened cache file. Returns: Version.
-
_get_handler_file
(entry)[source]¶ Parse file entry and return Handler instance.
Parameters: entry – .info file entry dictionary. Returns: An instance of None.
-
_get_handler_module
(entry)[source]¶ Parse module entry and return Handler instance.
Parameters: entry – .info file entry dictionary. Returns: An instance of None.
-
_get_handler_multifile
(entry)[source]¶ Parse multifile entry and return Handler instance.
Parameters: entry – .info file entry dictionary. Returns: An instance of None.
-
_get_handler_script
(entry)[source]¶ Parse script entry and return Handler instance.
Parameters: entry – .info file entry dictionary. Returns: An instance of None.
-
_get_handler_subfile
(entry)[source]¶ Parse subfile entry and return Handler instance.
Parameters: entry – .info file entry dictionary. Returns: An instance of None.
-
_handlers
= {}¶
-
_multifiles
= {}¶
-
_parse_common_file_handler
(handler, entry)[source]¶ Parse common file and multifile entries.
Parameters: - handler – Handler instance.
- entry – .info file entry dictionary.
-
_subfiles
= {}¶
-
call_handler
(ucr, handler)[source]¶ Call handler passing current configuration variables.
Parameters: - ucr – UCR instance.
- handler – The handler to call.
-
commit
(ucr, filelist=[])[source]¶ Call handlers to (re-)generate files.
Parameters: - ucr – UCR instance.
- filelist – List of files to re-generate. By default all files will be re-generated and all modules and scripts will we re-invoked!
-
get_handler
(entry)[source]¶ Parse entry and return Handler instance.
Parameters: entry – .info file entry dictionary. Returns: An instance of None.
-
register
(package, ucr)[source]¶ Register new info file for package.
Parameters: - package – Name of the package to register.
- ucr – UCR instance.
Returns: Set of (new) handlers.
-
strip_basepath
(path, basepath)[source]¶ Strip basepath prefix from path.
Parameters: - path – The path to strip from.
- basepath – The path to strip off.
Returns: The stripped path.
Deprecated since version 4.4: Better use
os.path.relpath()
.
-
univention.config_registry.interfaces module¶
Handle UCR network configuration.
-
univention.config_registry.interfaces.
forgiving
(translation=None)[source]¶ Decorator to translate exceptions into return values.
Parameters: translation – Mapping from Exception class to return value.
-
univention.config_registry.interfaces.
cmp_alnum
(value)[source]¶ Sort value split by digits / non-digits.
Parameters: value – The value to sort. Returns: value split into tuple.
-
class
univention.config_registry.interfaces.
Interfaces
(ucr=None)[source]¶ Bases:
object
Handle network interfaces configured by UCR.
Parameters: ucr – UCR instance. -
_cmp_order
(iface)[source]¶ Compare interfaces by order.
Parameters: iface – Other interface. Returns: A tuple to be used as a key for sorting.
-
_cmp_primary
(iface)[source]¶ Compare interfaces by primary.
Parameters: iface – Other interface. Returns: 3-tuple to be used as a key for sorting.
-
_cmp_name
(iname)[source]¶ Compare IPv6 sub-interfaces by name.
Parameters: name – Interface name. Returns: string used as a key for sorting.
-
all_interfaces
¶ Yield IPv4 interfaces.
-
ipv4_interfaces
¶ Yield IPv4 interfaces.
-
ipv6_interfaces
¶ Yield names of IPv6 interfaces.
-
univention.config_registry.misc module¶
Univention Configuration Registry helper functions.
-
univention.config_registry.misc.
replace_dict
(line, dictionary)[source]¶ Map any character from line to its value from dictionary.
>>> replace_dict('kernel', {'e': 'E', 'k': '', 'n': 'pp'}) 'ErppEl'
-
univention.config_registry.misc.
replace_umlaut
(line)[source]¶ Replace german umlauts.
>>> replace_umlaut(u'überschrieben') == u'ueberschrieben' True
-
univention.config_registry.misc.
directory_files
(directory)[source]¶ Return a list of all files below the given directory.
Parameters: directory – Base directory path. Returns: List of absolute file names.
-
univention.config_registry.misc.
escape_value
(file)¶ Return a shell-escaped version of the file string.
-
univention.config_registry.misc.
key_shell_escape
(line)[source]¶ Escape variable name by substituting shell invalid characters by ‘_’.
Parameters: line – UCR variable name. Returns: substitued variable name
-
univention.config_registry.misc.
validate_key
(key, out=<open file '<stderr>', mode 'w'>)[source]¶ Check if key consists of only shell valid characters.
Parameters: - key – UCR variable name to check.
- out – Output stream where error message is printed to.
Returns: True if the name is valid, False otherwise.