univention package
Contents
univention package¶
Subpackages¶
- univention.admin package
- Subpackages
- univention.admin.handlers package
- Subpackages
- univention.admin.handlers.appcenter package
- univention.admin.handlers.computers package
- Submodules
- univention.admin.handlers.computers.computer module
- univention.admin.handlers.computers.domaincontroller_backup module
- univention.admin.handlers.computers.domaincontroller_master module
- univention.admin.handlers.computers.domaincontroller_slave module
- univention.admin.handlers.computers.ipmanagedclient module
- univention.admin.handlers.computers.linux module
- univention.admin.handlers.computers.macos module
- univention.admin.handlers.computers.memberserver module
- univention.admin.handlers.computers.trustaccount module
- univention.admin.handlers.computers.ubuntu module
- univention.admin.handlers.computers.windows module
- univention.admin.handlers.computers.windows_domaincontroller module
- univention.admin.handlers.container package
- univention.admin.handlers.dhcp package
- Submodules
- univention.admin.handlers.dhcp.dhcp module
- univention.admin.handlers.dhcp.host module
- univention.admin.handlers.dhcp.pool module
- univention.admin.handlers.dhcp.server module
- univention.admin.handlers.dhcp.service module
- univention.admin.handlers.dhcp.shared module
- univention.admin.handlers.dhcp.sharedsubnet module
- univention.admin.handlers.dhcp.subnet module
- univention.admin.handlers.dns package
- Submodules
- univention.admin.handlers.dns.alias module
- univention.admin.handlers.dns.dns module
- univention.admin.handlers.dns.forward_zone module
- univention.admin.handlers.dns.host_record module
- univention.admin.handlers.dns.ns_record module
- univention.admin.handlers.dns.ptr_record module
- univention.admin.handlers.dns.reverse_zone module
- univention.admin.handlers.dns.srv_record module
- univention.admin.handlers.dns.txt_record module
- univention.admin.handlers.groups package
- univention.admin.handlers.kerberos package
- univention.admin.handlers.mail package
- univention.admin.handlers.ms package
- Submodules
- univention.admin.handlers.ms.domainpolicy module
- univention.admin.handlers.ms.gpipsec-filter module
- univention.admin.handlers.ms.gpipsec-isakmp-policy module
- univention.admin.handlers.ms.gpipsec-negotiation-policy module
- univention.admin.handlers.ms.gpipsec-nfa module
- univention.admin.handlers.ms.gpipsec-policy module
- univention.admin.handlers.ms.gpsi-category-registration module
- univention.admin.handlers.ms.gpsi-class-store module
- univention.admin.handlers.ms.gpsi-package-registration module
- univention.admin.handlers.ms.gpwl-wired module
- univention.admin.handlers.ms.gpwl-wireless-blob module
- univention.admin.handlers.ms.gpwl-wireless module
- univention.admin.handlers.nagios package
- univention.admin.handlers.networks package
- univention.admin.handlers.policies package
- Submodules
- univention.admin.handlers.policies.admin_container module
- univention.admin.handlers.policies.desktop module
- univention.admin.handlers.policies.dhcp_boot module
- univention.admin.handlers.policies.dhcp_dns module
- univention.admin.handlers.policies.dhcp_dnsupdate module
- univention.admin.handlers.policies.dhcp_leasetime module
- univention.admin.handlers.policies.dhcp_netbios module
- univention.admin.handlers.policies.dhcp_routing module
- univention.admin.handlers.policies.dhcp_scope module
- univention.admin.handlers.policies.dhcp_statements module
- univention.admin.handlers.policies.ldapserver module
- univention.admin.handlers.policies.maintenance module
- univention.admin.handlers.policies.masterpackages module
- univention.admin.handlers.policies.memberpackages module
- univention.admin.handlers.policies.nfsmounts module
- univention.admin.handlers.policies.policy module
- univention.admin.handlers.policies.printserver module
- univention.admin.handlers.policies.pwhistory module
- univention.admin.handlers.policies.registry module
- univention.admin.handlers.policies.release module
- univention.admin.handlers.policies.repositoryserver module
- univention.admin.handlers.policies.repositorysync module
- univention.admin.handlers.policies.share_userquota module
- univention.admin.handlers.policies.slavepackages module
- univention.admin.handlers.policies.umc module
- univention.admin.handlers.saml package
- univention.admin.handlers.settings package
- Submodules
- univention.admin.handlers.settings.cn module
- univention.admin.handlers.settings.console_helpdesk module
- univention.admin.handlers.settings.data module
- univention.admin.handlers.settings.default module
- univention.admin.handlers.settings.directory module
- univention.admin.handlers.settings.extended_attribute module
- univention.admin.handlers.settings.extended_options module
- univention.admin.handlers.settings.ldapacl module
- univention.admin.handlers.settings.ldapschema module
- univention.admin.handlers.settings.license module
- univention.admin.handlers.settings.lock module
- univention.admin.handlers.settings.msprintconnectionpolicy module
- univention.admin.handlers.settings.mswmifilter module
- univention.admin.handlers.settings.packages module
- univention.admin.handlers.settings.portal module
- univention.admin.handlers.settings.portal_all module
- univention.admin.handlers.settings.portal_category module
- univention.admin.handlers.settings.portal_entry module
- univention.admin.handlers.settings.printermodel module
- univention.admin.handlers.settings.printeruri module
- univention.admin.handlers.settings.prohibited_username module
- univention.admin.handlers.settings.sambaconfig module
- univention.admin.handlers.settings.sambadomain module
- univention.admin.handlers.settings.service module
- univention.admin.handlers.settings.settings module
- univention.admin.handlers.settings.syntax module
- univention.admin.handlers.settings.udm_hook module
- univention.admin.handlers.settings.udm_module module
- univention.admin.handlers.settings.udm_syntax module
- univention.admin.handlers.settings.umc_operationset module
- univention.admin.handlers.settings.usertemplate module
- univention.admin.handlers.shares package
- univention.admin.handlers.test package
- univention.admin.handlers.users package
- Subpackages
- univention.admin.rest package
- univention.admin.handlers package
- Submodules
- univention.admin.allocators module
- univention.admin.config module
- univention.admin.cron module
- univention.admin.filter module
- univention.admin.hook module
- univention.admin.layout module
- univention.admin.license module
- univention.admin.license_data module
- univention.admin.localization module
- univention.admin.locking module
- univention.admin.mapping module
- univention.admin.modules module
- univention.admin.nagios module
- univention.admin.objects module
- univention.admin.password module
- univention.admin.policy module
- univention.admin.samba module
- univention.admin.syntax module
- univention.admin.types module
- univention.admin.uexceptions module
- univention.admin.uldap module
- Subpackages
- univention.admincli package
- univention.admindiary package
- univention.app_appliance package
- univention.appcenter package
- Subpackages
- univention.appcenter.actions package
- Submodules
- univention.appcenter.actions.configure module
- univention.appcenter.actions.credentials module
- univention.appcenter.actions.domain module
- univention.appcenter.actions.get module
- univention.appcenter.actions.info module
- univention.appcenter.actions.install module
- univention.appcenter.actions.install_base module
- univention.appcenter.actions.list_apps module
- univention.appcenter.actions.register module
- univention.appcenter.actions.remove module
- univention.appcenter.actions.stall module
- univention.appcenter.actions.update module
- univention.appcenter.actions.update_certificates module
- univention.appcenter.actions.update_check module
- univention.appcenter.actions.upgrade module
- univention.appcenter.actions.upgrade_search module
- univention.appcenter.actions package
- Submodules
- univention.appcenter.app module
- univention.appcenter.app_cache module
- univention.appcenter.database module
- univention.appcenter.exceptions module
- univention.appcenter.extended_attributes module
- univention.appcenter.ini_parser module
- univention.appcenter.install_checks module
- univention.appcenter.listener module
- univention.appcenter.log module
- univention.appcenter.meta module
- univention.appcenter.packages module
- univention.appcenter.settings module
- univention.appcenter.ucr module
- univention.appcenter.udm module
- univention.appcenter.utils module
- Subpackages
- univention.config_registry package
- univention.connector package
- univention.directory package
- Subpackages
- univention.directory.reports package
- Submodules
- univention.directory.reports.admin module
- univention.directory.reports.config module
- univention.directory.reports.document module
- univention.directory.reports.error module
- univention.directory.reports.filter module
- univention.directory.reports.interpreter module
- univention.directory.reports.output module
- univention.directory.reports.parser module
- univention.directory.reports.report module
- univention.directory.reports.tokens module
- univention.directory.reports package
- Subpackages
- univention.ipcalc package
- univention.l10n package
- univention.ldap_cache package
- univention.lib package
- Submodules
- univention.lib.account module
- univention.lib.admember module
- univention.lib.atjobs module
- univention.lib.fstab module
- univention.lib.i18n module
- univention.lib.ldap_extension module
- univention.lib.license_tools module
- univention.lib.listenerSharePath module
- univention.lib.locking module
- univention.lib.misc module
- univention.lib.package_manager module
- univention.lib.password module
- univention.lib.policy_result module
- univention.lib.s4 module
- univention.lib.share_restrictions module
- univention.lib.ucrLogrotate module
- univention.lib.ucs module
- univention.lib.umc module
- univention.lib.umc_module module
- univention.listener package
- univention.mail package
- univention.management package
- Subpackages
- univention.management.console package
- Subpackages
- univention.management.console.modules package
- univention.management.console.protocol package
- Data flow
- Authentication
- Message format
- Examples
- Submodules
- univention.management.console.protocol.client module
- univention.management.console.protocol.definitions module
- univention.management.console.protocol.message module
- univention.management.console.protocol.modserver module
- univention.management.console.protocol.server module
- univention.management.console.protocol.session module
- univention.management.console.protocol.version module
- Submodules
- univention.management.console.acl module
- univention.management.console.auth module
- univention.management.console.base module
- univention.management.console.category module
- univention.management.console.config module
- univention.management.console.error module
- univention.management.console.ldap module
- univention.management.console.locales module
- univention.management.console.log module
- univention.management.console.module module
- univention.management.console.pam module
- univention.management.console.resources module
- univention.management.console.tools module
- Subpackages
- univention.management.console package
- Subpackages
- univention.portal package
- univention.radius package
- univention.s4connector package
- Subpackages
- univention.s4connector.s4 package
- Submodules
- univention.s4connector.s4.computer module
- univention.s4connector.s4.dc module
- univention.s4connector.s4.dns module
- univention.s4connector.s4.main module
- univention.s4connector.s4.mapping module
- univention.s4connector.s4.ntsecurity_descriptor module
- univention.s4connector.s4.password module
- univention.s4connector.s4.query_config module
- univention.s4connector.s4.sid_mapping module
- univention.s4connector.s4.user module
- univention.s4connector.s4 package
- Submodules
- univention.s4connector.lockingdb module
- univention.s4connector.s4cache module
- Subpackages
- univention.saml package
- univention.testing package
- Subpackages
- univention.testing.format package
- univention.testing.selenium package
- univention.testing.ucsschool package
- Submodules
- univention.testing.ucsschool.acl module
- univention.testing.ucsschool.computerroom module
- univention.testing.ucsschool.conftest module
- univention.testing.ucsschool.distribution module
- univention.testing.ucsschool.exam module
- univention.testing.ucsschool.import_factory_test_classes module
- univention.testing.ucsschool.importcomputers module
- univention.testing.ucsschool.importgroups module
- univention.testing.ucsschool.importnetworks module
- univention.testing.ucsschool.importou module
- univention.testing.ucsschool.importprinters module
- univention.testing.ucsschool.importusers module
- univention.testing.ucsschool.importusers_cli_v2 module
- univention.testing.ucsschool.importusers_http module
- univention.testing.ucsschool.internetrule module
- univention.testing.ucsschool.kelvin_api module
- univention.testing.ucsschool.klasse module
- univention.testing.ucsschool.radius module
- univention.testing.ucsschool.randomdomain module
- univention.testing.ucsschool.school module
- univention.testing.ucsschool.schoolroom module
- univention.testing.ucsschool.simplecurl module
- univention.testing.ucsschool.test_samba4 module
- univention.testing.ucsschool.ucs_test_school module
- univention.testing.ucsschool.user module
- univention.testing.ucsschool.workgroup module
- Submodules
- univention.testing.apptest module
- univention.testing.codes module
- univention.testing.conftest module
- univention.testing.connector_common module
- univention.testing.coverage module
- univention.testing.data module
- univention.testing.debian_package module
- univention.testing.decorators module
- univention.testing.errors module
- univention.testing.internal module
- univention.testing.ldif module
- univention.testing.license_client module
- univention.testing.mail module
- univention.testing.network module
- univention.testing.pytest module
- univention.testing.strings module
- univention.testing.ucr module
- univention.testing.ucs_samba module
- univention.testing.udm module
- univention.testing.udm_extensions module
- univention.testing.umc module
- univention.testing.utils module
- Subpackages
- univention.ucslint package
- univention.udm package
- Subpackages
- univention.udm.modules package
- Submodules
- univention.udm.modules.appcenter_app module
- univention.udm.modules.computers_all module
- univention.udm.modules.container_cn module
- univention.udm.modules.container_dc module
- univention.udm.modules.container_ou module
- univention.udm.modules.generic module
- univention.udm.modules.groups_group module
- univention.udm.modules.mail_all module
- univention.udm.modules.nagios_service module
- univention.udm.modules.policies_registry module
- univention.udm.modules.policies_share_userquota module
- univention.udm.modules.policies_umc module
- univention.udm.modules.portal module
- univention.udm.modules.saml_serviceprovider module
- univention.udm.modules.settings_data module
- univention.udm.modules.settings_directory module
- univention.udm.modules.settings_portal module
- univention.udm.modules.settings_portal_category module
- univention.udm.modules.settings_portal_entry module
- univention.udm.modules.users_ldap_v0 module
- univention.udm.modules.users_ldap_v1 module
- univention.udm.modules.users_user module
- univention.udm.modules package
- Submodules
- univention.udm.base module
- univention.udm.binary_props module
- univention.udm.connections module
- univention.udm.encoders module
- univention.udm.exceptions module
- univention.udm.helpers module
- univention.udm.plugins module
- univention.udm.udm module
- univention.udm.utils module
- Subpackages
- univention.updater package
- Subpackages
- univention.updater.scripts package
- Submodules
- univention.updater.scripts.actualize module
- univention.updater.scripts.kernel module
- univention.updater.scripts.list_installed_unmaintained_packages module
- univention.updater.scripts.policy_maintenance module
- univention.updater.scripts.policy_repo_server module
- univention.updater.scripts.policy_repo_sync module
- univention.updater.scripts.repo_create module
- univention.updater.scripts.repo_update module
- univention.updater.scripts.statistics module
- univention.updater.scripts.updater module
- univention.updater.scripts.upgrade module
- univention.updater.scripts package
- Submodules
- univention.updater.commands module
- univention.updater.errors module
- univention.updater.locking module
- univention.updater.mirror module
- univention.updater.repo_url module
- univention.updater.repository module
- univention.updater.tools module
- Subpackages
Submodules¶
univention.config_registry_info module¶
- class univention.config_registry_info.Variable(registered=True)[source]¶
Bases:
univention.info_tools.LocalizedDictionary
UCR variable description.
- class univention.config_registry_info.Category[source]¶
Bases:
univention.info_tools.LocalizedDictionary
UCR category description.
- class univention.config_registry_info.ConfigRegistryInfo(install_mode=False, registered_only=True, load_customized=True)[source]¶
Bases:
object
UCR variable and category descriptions.
Initialize variable and category descriptions.
- Parameters
install_mode – True deactivates the use of an UCR instance.
registered_only – False creates synthetic entries for all undescribed but set variables.
load_customized – False deactivates loading customized descriptions.
- BASE_DIR = '/etc/univention/registry.info'¶
- CATEGORIES = 'categories'¶
- VARIABLES = 'variables'¶
- CUSTOMIZED = '_customized'¶
- FILE_SUFFIX = '.cfg'¶
- check_categories()[source]¶
Check all categories for completeness.
- Returns
dictionary of incomplete category descriptions.
- read_categories(filename)[source]¶
Load a single category description file.
- Parameters
filename – File to load.
- describe_search_term(term)[source]¶
Try to apply a description to a search term.
This is not complete, because it would require a complete “intersect two regular languages” algorithm.
- Parameters
term – Search term.
- Returns
Dictionary mapping variable pattern to Variable info blocks.
- read_variables(filename=None, package=None, override=False)[source]¶
Read variable descriptions.
- Parameters
filename – Explicit filename for loading.
package – Explicit package name.
override – True to overwrite already loaded descriptions.
- Raises
AttributeError – if neither filename nor package are given.
- get_category(name)[source]¶
Returns a category object associated with the given name or None.
- Parameters
name – Name of the category.
- Returns
- get_variables(category=None)[source]¶
Return dictionary of variable info blocks belonging to given category.
- Parameters
category – Name of the category. None defaults to all variables.
- Returns
Dictionary mapping variable-name to
Variable
instance.
univention.debhelper module¶
Debhelper compatible routines.
- univention.debhelper.doIt(*argv)[source]¶
Execute argv and wait.
- Parameters
args – List of command and arguments.
>>> doIt('true') 0
- univention.debhelper.binary_packages()[source]¶
Get list of binary packages from debian/control file.
>>> binary_packages() [...]
- univention.debhelper.parseRfc822(f)[source]¶
Parses string f as a RFC 822 conforming file and returns list of sections, each a dict mapping keys to lists of values. Splits file into multiple sections separated by blank line.
- Parameters
f – The messate to parse.
- Returns
A list of dictionaries.
Note
For real Debian files, use the
debian.deb822
module from the python-debian package.>>> res = parseRfc822('Type: file\nFile: /etc/fstab\n\nType: Script\nScript: /bin/false\n') >>> res == [{'Type': ['file'], 'File': ['/etc/fstab']}, {'Type': ['Script'], 'Script': ['/bin/false']}] True >>> parseRfc822('') [] >>> parseRfc822('\n') [] >>> parseRfc822('\n\n') []
univention.debug module¶
Univention debugging and logging library.
example:
>>> f = init('stdout', NO_FLUSH, FUNCTION)
... ... DEBUG_INIT
>>> set_level(LISTENER, ERROR)
- univention.debug.debug(category, level, message, utf8=True)[source]¶
Log message ‘message’ of severity ‘level’ to facility ‘category’.
- Parameters
>>> debug(LISTENER, ERROR, 'Fatal error: var=%s' % 42) ... ... LISTENER ( ERROR ) : Fatal error: var=42
- class univention.debug.function(fname, utf8=True)[source]¶
Bases:
object
Log function call begin and end.
- Parameters
Deprecated since version 4.4: Use function decorator
trace()
instead.>>> def my_func(agr1, agr2=None): ... _d = function('my_func(...)') # noqa: F841 ... return 'yes' >>> my_func(42) 'yes'
- univention.debug.trace(with_args=True, with_return=False, repr=<slot wrapper '__repr__' of 'object' objects>)[source]¶
Log function call, optional with arguments and result.
- Parameters
>>> @trace(with_args=True, with_return=True) ... def my_func(arg1, arg2=None): ... return 'yes' >>> my_func(42) 'yes' >>> class MyClass(object): ... @trace(with_args=True, with_return=True, repr=repr) ... def my_meth(self, arg1, arg2=None): ... return 'yes' >>> MyClass().my_meth(42) 'yes' >>> @trace() ... def my_bug(): ... 1 / 0 >>> my_bug() Traceback (most recent call last): ... ZeroDivisionError: integer division or modulo by zero
univention.debug2 module¶
Python native Univention debugging library.
See univention.debug
for an alternative being a wrapper for the C
implementation.
- univention.debug2.init(logfile, force_flush=0, enable_function=0, enable_syslog=0)[source]¶
Initialize debugging library for logging to ‘logfile’.
- Parameters
- Returns
output file or None.
- univention.debug2.set_level(category, level)[source]¶
Set minimum required severity ‘level’ for facility ‘category’.
- univention.debug2.get_level(category)[source]¶
Get minimum required severity for facility ‘category’.
- univention.debug2.set_function(activate)[source]¶
Enable or disable the logging of function begins and ends.
- Parameters
activate (bool) – enable (True) or disable (False) function tracing.
Deprecated since version 4.4: Use function decorator
trace()
instead.
- univention.debug2.debug(category, level, message, utf8=True)[source]¶
Log message ‘message’ of severity ‘level’ to facility ‘category’.
- class univention.debug2.function(fname, utf8=True)[source]¶
Bases:
object
Log function call begin and end.
- Parameters
Deprecated since version 4.4: Use function decorator
trace()
instead.>>> def my_func(agr1, agr2=None): ... _d = function('my_func(...)') # noqa: F841 ... return 'yes' >>> my_func(42) 'yes'
- univention.debug2.trace(with_args=True, with_return=False, repr=<slot wrapper '__repr__' of 'object' objects>)[source]¶
Log function call, optional with arguments and result.
- Parameters
>>> @trace(with_args=True, with_return=True) ... def my_func(arg1, arg2=None): ... return 'yes' >>> my_func(42) 'yes' >>> class MyClass(object): ... @trace(with_args=True, with_return=True, repr=repr) ... def my_meth(self, arg1, arg2=None): ... return 'yes' >>> MyClass().my_meth(42) 'yes' >>> @trace() ... def my_bug(): ... 1 / 0 >>> my_bug() Traceback (most recent call last): ... ZeroDivisionError: integer division or modulo by zero
univention.info_tools module¶
- class univention.info_tools.LocalizedValue(*args, **kwargs)[source]¶
Bases:
dict
Localized description entry.
- class univention.info_tools.LocalizedDictionary[source]¶
Bases:
dict
Localized descriptions.
- get(key)[source]¶
- get(key, default)
Return the value for key if key is in the dictionary, else default.
- has_key(key)¶
True if the dictionary has the specified key, else False.
- class univention.info_tools.UnicodeConfig[source]¶
Bases:
configparser.ConfigParser
- read(filename, encoding='UTF-8')[source]¶
Read and parse a filename or an iterable of filenames.
Files that cannot be opened are silently ignored; this is designed so that you can specify an iterable of potential configuration file locations (e.g. current directory, user’s home directory, systemwide directory), and all existing configuration files in the iterable will be read. A single filename may also be given.
Return list of successfully read files.
univention.ldif module¶
Univention LDIF tool
- univention.ldif.ldif_decode(src=<_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>, dst=<_io.BufferedWriter name='<stdout>'>)[source]¶
Decode bas64 in LDIF.
univention.password module¶
- univention.password.password_config(scope=None)[source]¶
Read password configuration options from UCR.
- univention.password.generate_password(digits=6, lower=6, other=0, upper=6, forbidden='', min_length=24)[source]¶
Generate random password using given parameters. Whitespaces are implicitly forbidden.
- Parameters
digits (
int
) – Minimal number of digits in generated password. 0 excludes it from the password.lower (
int
) – Minimal number of lowercase ASCII letters in generated password. 0 excludes it from the password.other (
int
) – Minimal number of special characters in generated password. 0 excludes it from the password.upper (
int
) – Minimal number of uppercase ASCII letters in generated password. 0 excludes it from the password.forbidden (
str
) – Forbidden characters in generated password.min_length (
int
) – Minimal length of generated password.
- Returns
Randomly generated password.
- Return type
- Raises
ValueError – In case any password quality precondition fails.
univention.pkgdb module¶
Univention Package Database python module for the package database
- univention.pkgdb.parse_options()[source]¶
- parse options and return <options> with
<options.debug> <options.action> <options.system> <options.db_server> set
- univention.pkgdb.sql_grant_system(connection, cursor, sysname)[source]¶
Datenbankbenutzer hinzufügen
- univention.pkgdb.sql_revoke_system(connection, cursor, sysname)[source]¶
Datenbankbenutzer entfernen
- univention.pkgdb.sql_put_sys_in_systems(cursor, sysname, sysversion, sysrole, ldaphostdn, architecture)[source]¶
insert a system name into the system-table (or update its data)
- univention.pkgdb.sql_put_sys_in_systems_no_architecture(cursor, sysname, sysversion, sysrole, ldaphostdn)[source]¶
insert a system name into the old system-table (or update its data)
- univention.pkgdb.sql_get_packages_in_systems_by_query(cursor, query, join_systems, limit=None, orderby='sysname, pkgname, vername')[source]¶
- univention.pkgdb.dump_systems(cursor)[source]¶
writes CSV with all systems and their system-specific information to stdout
- univention.pkgdb.action_remove_system(connection, cursor, sysname)[source]¶
removes system <sysname> from the database
- univention.pkgdb.scan_and_store_packages(cursor, sysname, fake_null=False, architecture=None)[source]¶
updates the system <sysname> with the current package state if <fake_null> is True put ‘’ instead of None in the vername field
- univention.pkgdb.action_fill_testdb(connection, cursor, config_registry)[source]¶
Fülle Testdatenbank
univention.service_info module¶
- exception univention.service_info.ServiceError[source]¶
Bases:
Exception
Error when starting, stopping or restarting a service.
- class univention.service_info.Service(*args, **kwargs)[source]¶
Bases:
univention.info_tools.LocalizedDictionary
Description for a system service.
- REQUIRED = frozenset({'description', 'programs'})¶
- OPTIONAL = frozenset({'icon', 'init_script', 'name', 'start_type', 'systemd'})¶
- KNOWN = frozenset({'description', 'icon', 'init_script', 'name', 'programs', 'start_type', 'systemd'})¶
- univention.service_info.pidof(name, docker='/var/run/docker.pid')[source]¶
Return list of process IDs matching name.
- Parameters
name – Procress name.
docker – File name containing process ID of docker process.
>>> import os,sys;os.getpid() in list(pidof(os.path.realpath(sys.executable))) + list(pidof(sys.executable)) + list(pidof(sys.argv[0])) True
- class univention.service_info.ServiceInfo(install_mode=False)[source]¶
Bases:
object
- BASE_DIR = '/etc/univention/service.info'¶
- SERVICES = 'services'¶
- CUSTOMIZED = '_customized'¶
- FILE_SUFFIX = '.cfg'¶
- check_services()[source]¶
Check service descriptions for completeness.
- Returns
dictionary of incomplete service descriptions.
- read_services(filename=None, package=None, override=False)[source]¶
Read start/stop levels of services.
- Parameters
filename – Explicit filename for loading.
package – Explicit package name.
override – True to overwrite already loaded descriptions.
- Raises
AttributeError – if neither filename nor package are given.
univention.uldap module¶
- univention.uldap.parentDn(dn, base='')[source]¶
Return the parent container of a distinguished name.
- univention.uldap.getRootDnConnection(start_tls=2, decode_ignorelist=[], reconnect=True)[source]¶
Open a LDAP connection to the local LDAP server with the LDAP root account.
- Parameters
- Returns
A LDAP access object.
- Return type
- univention.uldap.getAdminConnection(start_tls=2, decode_ignorelist=[], reconnect=True)[source]¶
Open a LDAP connection to the Primary Directory Node LDAP server using the admin credentials.
- Parameters
- Returns
A LDAP access object.
- Return type
- univention.uldap.getBackupConnection(start_tls=2, decode_ignorelist=[], reconnect=True)[source]¶
Open a LDAP connection to a Backup Directory Node LDAP server using the admin credentials.
- Parameters
- Returns
A LDAP access object.
- Return type
- univention.uldap.getMachineConnection(start_tls=2, decode_ignorelist=[], ldap_master=True, secret_file='/etc/machine.secret', reconnect=True, random_server=False)[source]¶
Open a LDAP connection using the machine credentials.
- Parameters
start_tls (int) – Negotiate TLS with server. If 2 is given, the command will require the operation to be successful.
decode_ignorelist (list[str]) – List of LDAP attribute names which shall be handled as binary attributes.
ldap_master (bool) – Open a connection to the Master if True, to the preferred LDAP server otherwise.
secret_file (str) – The name of a file containing the password credentials.
reconnect (bool) – Automatically reconnect if the connection fails.
random_server (bool) – Choose a random LDAP server from ldap/server/name and ldap/server/addition.
- Returns
A LDAP access object.
- Return type
- class univention.uldap.access(host='localhost', port=None, base='', binddn='', bindpw='', start_tls=2, ca_certfile=None, decode_ignorelist=[], use_ldaps=False, uri=None, follow_referral=False, reconnect=True)[source]¶
Bases:
object
The low-level class to access a LDAP server.
- Parameters
host (str) – host name of the LDAP server.
port (int) – TCP port of the LDAP server. Defaults to 7389 or 7636.
base (str) – LDAP base distinguished name.
binddn (str) – Distinguished name for simple authentication.
bindpw (str) – Password for simple authentication.
start_tls (int) – 0=no, 1=try StartTLS, 2=require StartTLS.
ca_certfile (str) – File name to CA certificate.
decode_ignorelist – List of LDAP attribute names which shall be handled as binary attributes.
use_ldaps (bool) – Connect to SSL port.
uri (str) – LDAP connection string.
follow_referral (bool) – Follow referrals and return result from other servers instead of returning the referral itself.
reconnect (bool) – Automatically re-establish connection to LDAP server if connection breaks.
- bind_saml(bindpw)[source]¶
Do LDAP bind using SAML message.
- Parameters
bindpw (str) – The SAML authentication cookie.
- whoami()[source]¶
Return the distinguished name of the authenticated user.
- Returns
The distinguished name.
- Return type
- get(dn, attr=[], required=False)[source]¶
Return multiple attributes of a single LDAP object.
- Parameters
- Returns
A dictionary mapping the requested attributes to a list of their values.
- Return type
- Raises
ldap.NO_SUCH_OBJECT – If the LDAP object is not accessible.
- getAttr(dn, attr, required=False)[source]¶
Return a single attribute of a single LDAP object.
- Parameters
- Returns
A list of values.
- Return type
- Raises
ldap.NO_SUCH_OBJECT – If the LDAP object is not accessible.
Warning
the attribute name is currently case sensitive and must be given as in the LDAP schema
Warning
when required=True it raises ldap.NO_SUCH_OBJECT even if the object exists but the attribute is not set
- search(filter='(objectClass=*)', base='', scope='sub', attr=[], unique=False, required=False, timeout=- 1, sizelimit=0, serverctrls=None, response=None)[source]¶
Perform LDAP search and return values.
- Parameters
filter (str) – LDAP search filter.
base (str) – the starting point for the search.
scope (str) – Specify the scope of the search to be one of base, base+one, one, sub, or domain to specify a base object, base plus one-level, one-level, subtree, or children search.
unique (bool) – Raise an exception if more than one object matches.
required (bool) – Raise an exception instead of returning an empty dictionary.
timeout (int) – wait at most timeout seconds for a search to complete. -1 for no limit.
sizelimit (int) – retrieve at most sizelimit entries for a search. 0 for no limit.
serverctrls (list[ldap.controls.LDAPControl]) – a list of
ldap.controls.LDAPControl
instances sent to the server along with the LDAP request.response (dict) – An optional dictionary to receive the server controls of the result.
- Returns
A list of 2-tuples (dn, values) for each LDAP object, where values is a dictionary mapping attribute names to a list of values.
- Return type
- Raises
ldap.NO_SUCH_OBJECT – Indicates the target object cannot be found.
ldap.INAPPROPRIATE_MATCHING – Indicates that the matching rule specified in the search filter does not match a rule defined for the attribute’s syntax.
- searchDn(filter='(objectClass=*)', base='', scope='sub', unique=False, required=False, timeout=- 1, sizelimit=0, serverctrls=None, response=None)[source]¶
Perform LDAP search and return distinguished names only.
- Parameters
filter (str) – LDAP search filter.
base (str) – the starting point for the search.
scope (str) – Specify the scope of the search to be one of base, base+one, one, sub, or domain to specify a base object, base plus one-level, one-level, subtree, or children search.
unique (bool) – Raise an exception if more than one object matches.
required (bool) – Raise an exception instead of returning an empty dictionary.
timeout (int) – wait at most timeout seconds for a search to complete. -1 for no limit.
sizelimit (int) – retrieve at most sizelimit entries for a search. 0 for no limit.
serverctrls (list[ldap.controls.LDAPControl]) – a list of
ldap.controls.LDAPControl
instances sent to the server along with the LDAP request.response (dict) – An optional dictionary to receive the server controls of the result.
- Returns
A list of distinguished names.
- Return type
- Raises
ldap.NO_SUCH_OBJECT – Indicates the target object cannot be found.
ldap.INAPPROPRIATE_MATCHING – Indicates that the matching rule specified in the search filter does not match a rule defined for the attribute’s syntax.
- getPolicies(dn, policies=None, attrs=None, result=None, fixedattrs=None)[source]¶
Return UCS policies for LDAP entry.
- get_schema()[source]¶
Retrieve LDAP schema information from LDAP server.
- Returns
The LDAP schema.
- Return type
ldap.schema.subentry.SubSchema
- add(dn, al, serverctrls=None, response=None)[source]¶
Add LDAP entry at distinguished name and attributes in add_list=(attribute-name, old-values. new-values) or (attribute-name, new-values).
- Parameters
dn (str) – The distinguished name of the object to add.
al – The add-list of 2-tuples (attribute-name, new-values).
serverctrls (list[ldap.controls.LDAPControl]) – a list of ldap.controls.LDAPControl instances sent to the server along with the LDAP request
response (dict) – An optional dictionary to receive the server controls of the result.
- modify(dn, changes, serverctrls=None, response=None, rename_callback=None)[source]¶
Modify LDAP entry DN with attributes in changes=(attribute-name, old-values, new-values).
- Parameters
dn (str) – The distinguished name of the object to modify.
changes – The modify-list of 3-tuples (attribute-name, old-values, new-values).
serverctrls (list[ldap.controls.LDAPControl]) – a list of ldap.controls.LDAPControl instances sent to the server along with the LDAP request
response (dict) – An optional dictionary to receive the server controls of the result.
- Returns
The distinguished name.
- Return type
- modify_s(dn, ml)[source]¶
Redirect modify_s directly to
lo
.- Parameters
dn (str) – The distinguished name of the object to modify.
ml – The modify-list of 3-tuples (attribute-name, old-values, new-values).
- modify_ext_s(dn, ml, serverctrls=None, response=None)[source]¶
Redirect modify_ext_s directly to
lo
.- Parameters
dn (str) – The distinguished name of the object to modify.
ml – The modify-list of 3-tuples (attribute-name, old-values, new-values).
serverctrls (list[ldap.controls.LDAPControl]) – a list of ldap.controls.LDAPControl instances sent to the server along with the LDAP request
response (dict) – An optional dictionary to receive the server controls of the result.
- rename(dn, newdn, serverctrls=None, response=None)[source]¶
Rename a LDAP object.
- Parameters
dn (str) – The old distinguished name of the object to rename.
newdn (str) – The new distinguished name of the object to rename.
serverctrls (list[ldap.controls.LDAPControl]) – a list of ldap.controls.LDAPControl instances sent to the server along with the LDAP request
response (dict) – An optional dictionary to receive the server controls of the result.
- rename_ext_s(dn, newrdn, newsuperior=None, serverctrls=None, response=None)[source]¶
Redirect rename_ext_s directly to
lo
.- Parameters
dn (str) – The old distinguished name of the object to rename.
newdn (str) – The new distinguished name of the object to rename.
newsuperior (str) – The distinguished name of the new container.
serverctrls (list[ldap.controls.LDAPControl]) – a list of ldap.controls.LDAPControl instances sent to the server along with the LDAP request
response (dict) – An optional dictionary to receive the server controls of the result.
- delete(dn)[source]¶
Delete a LDAP object.
- Parameters
dn (str) – The distinguished name of the object to remove.
- classmethod compare_dn(a, b)[source]¶
Test DNs are same
- Parameters
- Returns
True if the DNs are the same, False otherwise.
- Return type
>>> compare_dn = access.compare_dn >>> compare_dn('foo=1', 'foo=1') True >>> compare_dn('foo=1', 'foo=2') False >>> compare_dn('Foo=1', 'foo=1') True >>> compare_dn('Foo=1', 'foo=2') False >>> compare_dn('foo=1,bar=2', 'foo=1,bar=2') True >>> compare_dn('bar=2,foo=1', 'foo=1,bar=2') False >>> compare_dn('foo=1+bar=2', 'foo=1+bar=2') True >>> compare_dn('bar=2+foo=1', 'foo=1+bar=2') True >>> compare_dn('bar=2+Foo=1', 'foo=1+Bar=2') True >>> compare_dn(r'foo=\31', r'foo=1') True