univention.management.console.modules.setup package#
- exception univention.management.console.modules.setup.RequestTimeout(message=None, status=None, result=None, headers=None, traceback=None, reason=None)[source]#
Bases:
UMC_Error- msg = 'Request Timeout'#
- status = 408#
- class univention.management.console.modules.setup.Instance(*args, **kwargs)[source]#
Bases:
Base,ProgressMixin- load(request, *args, **kwargs)[source]#
Return a dict with all necessary values for system-setup read from the current status of the system.
- save_keymap(request, *args, **kwargs)[source]#
Set the systems x-keymap according to request.options[keymap]
- save(request)[source]#
Reconfigures the system according to the values specified in the dict given as option named “values”.
- join(request, *args, **kwargs)[source]#
Join and reconfigure the system according to the values specified in the dict given as option named “values”.
- check_finished(request, *args, **kwargs)[source]#
Check whether the join/setup scripts are finished. This method implements a long polling request, i.e., the request is only finished at the moment when all scripts have been executed or due to a timeout. If it returns because of the timeout, a new try can be started.
- validate(request, *args, **kwargs)[source]#
Validate the specified values given in the dict as option named “values”. Return a dict (with variable names as key) of dicts with the structure: { “valid”: True/False, “message”: “…” }
- lang_keyboard_model(request, *args, **kwargs)[source]#
Return a list of all available keyboard models.
- lang_keyboard_layout(request, *args, **kwargs)[source]#
Return a list of all available keyboard layouts.
- lang_countrycodes(request)[source]#
Return a list of all countries with their two letter chcountry codes.
- net_interfaces(request, *args, **kwargs)[source]#
Return a list of all available network interfaces.
Subpackages#
- univention.management.console.modules.setup.checks package
- univention.management.console.modules.setup.netconf package
ChangeSetSkipPhasePhase- Subpackages
- univention.management.console.modules.setup.netconf.modules package
RunPhases- Submodules
- univention.management.console.modules.setup.netconf.modules.FlushOldAddresses module
- univention.management.console.modules.setup.netconf.modules.KernelModules module
PhaseKernelModulesPhaseKernelModules.variable_namePhaseKernelModules.variable_separatorPhaseKernelModules.module_optionPhaseKernelModules.priorityPhaseKernelModules.executablePhaseKernelModules.pre()PhaseKernelModules.get_configured_modules()PhaseKernelModules.clean_known_modules()PhaseKernelModules.scan_required_modules()PhaseKernelModules.set_configured_modules()PhaseKernelModules.load_modules()
- univention.management.console.modules.setup.netconf.modules.LdapDhcp module
- univention.management.console.modules.setup.netconf.modules.LdapDns module
- univention.management.console.modules.setup.netconf.modules.LdapNetwork module
- univention.management.console.modules.setup.netconf.modules.LdapReferences module
- univention.management.console.modules.setup.netconf.modules.LdapSSO module
- univention.management.console.modules.setup.netconf.modules.LdapSamba module
- univention.management.console.modules.setup.netconf.modules.LdapSelf module
- univention.management.console.modules.setup.netconf.modules.ResolvConf module
- univention.management.console.modules.setup.netconf.modules.RestartAllInterfaces module
- univention.management.console.modules.setup.netconf.modules.RestartBind module
- univention.management.console.modules.setup.netconf.modules.RestartCups module
- univention.management.console.modules.setup.netconf.modules.RestartDhcp module
- univention.management.console.modules.setup.netconf.modules.RestartKerberos module
- univention.management.console.modules.setup.netconf.modules.RestartListener module
- univention.management.console.modules.setup.netconf.modules.RestartNscd module
- univention.management.console.modules.setup.netconf.modules.RestartPostgresql module
- univention.management.console.modules.setup.netconf.modules.RestartSamba module
- univention.management.console.modules.setup.netconf.modules.RestartSamba4 module
- univention.management.console.modules.setup.netconf.modules.RewritePxe module
- univention.management.console.modules.setup.netconf.modules.RewriteUcr module
- univention.management.console.modules.setup.netconf.modules.RewriteWins module
- univention.management.console.modules.setup.netconf.modules.SaveOldApplianceAddress module
- univention.management.console.modules.setup.netconf.modules package
- Submodules
- univention.management.console.modules.setup.netconf.common module
- univention.management.console.modules.setup.netconf.conditions module
Submodules#
univention.management.console.modules.setup.network module#
Univention Management Console Module System-Setup Network interfaces
- exception univention.management.console.modules.setup.network.DeviceError(msg: str, device: str | None = None)[source]#
Bases:
ValueError
- class univention.management.console.modules.setup.network.Interfaces[source]#
-
All network interfaces
Loads all network devices from UCR variables
- from_dict(interfaces: Mapping[str, str]) None[source]#
Replaces all interfaces with the given interfaces and removes non existing interfaces
- class univention.management.console.modules.setup.network.Device(name: str, interfaces: Any)[source]#
Bases:
objectAbstract base class for network interfaces
- Parameters:
name – the interface name, e.g. wlan0, eth0, br0, eth0.2, bond0
interfaces (Interfaces) – a Interfaces instance
- property subdevices: set[Device]#
Returns a set of subdevices of this device if there are any, leavong out not existing devices
- validate_name() None[source]#
Valid interface name: max 15 characters, no slash, no space, not . or .. See linux/net/core/dev.c:933#dev_valid_name() >>> Device(‘eth0’, {}).validate_name() >>> Device(’0a1b2c3d4e5f_-:’, {}).validate_name() >>> Device(‘’, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘’ >>> Device(‘.’, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘.’ >>> Device(‘..’, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘..’ >>> Device(’ ‘, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘ ‘ >>> Device(‘abcdefghijklmnop’, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘abcdefghijklmnop’
- to_ucr() dict[str, str | None][source]#
Returns a dict of UCR variables to set or unset. Values which are None should be unset.
- property dict#
- class univention.management.console.modules.setup.network.Ethernet(name: str, interfaces: Any)[source]#
Bases:
DeviceA physical network interface
- Parameters:
name – the interface name, e.g. wlan0, eth0, br0, eth0.2, bond0
interfaces (Interfaces) – a Interfaces instance
- class univention.management.console.modules.setup.network.VLAN(name: str, interfaces: Any)[source]#
Bases:
DeviceA virtual network interface (VLAN)
- Parameters:
name – the interface name, e.g. wlan0, eth0, br0, eth0.2, bond0
interfaces (Interfaces) – a Interfaces instance
- validate_name() None[source]#
Valid interface name: max 15 characters, no slash, no space, not . or .. See linux/net/core/dev.c:933#dev_valid_name() >>> Device(‘eth0’, {}).validate_name() >>> Device(’0a1b2c3d4e5f_-:’, {}).validate_name() >>> Device(‘’, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘’ >>> Device(‘.’, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘.’ >>> Device(‘..’, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘..’ >>> Device(’ ‘, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘ ‘ >>> Device(‘abcdefghijklmnop’, {}).validate_name() Traceback (most recent call last):
…
DeviceError: Invalid device name: ‘abcdefghijklmnop’
- class univention.management.console.modules.setup.network.Bond(name: str, interfaces: Any)[source]#
Bases:
DeviceA network bonding interface
- Parameters:
name – the interface name, e.g. wlan0, eth0, br0, eth0.2, bond0
interfaces (Interfaces) – a Interfaces instance
- MODES = {'802.3ad': 4, 'active-backup': 1, 'balance-alb': 6, 'balance-rr': 0, 'balance-tlb': 5, 'balance-xor': 2, 'broadcast': 3}#
- MODES_R = {0: 'balance-rr', 1: 'active-backup', 2: 'balance-xor', 3: 'broadcast', 4: '802.3ad', 5: 'balance-tlb', 6: 'balance-alb'}#
univention.management.console.modules.setup.setup_script module#
- Univention System Setup
Python setup script base
- univention.management.console.modules.setup.setup_script.setup_i18n() Translation[source]#
- class univention.management.console.modules.setup.setup_script.TransactionalUcr[source]#
Bases:
object- set(key: str, value: str) None[source]#
Set the value of key of UCR. Does not save immediately. commit() is called at the end of inner_run(). If you need to commit changes immediately, you can call commit() at any time.
- class univention.management.console.modules.setup.setup_script.SetupScript(*args, **kwargs)[source]#
Bases:
objectBaseclass for all Python-based Setup-Scripts.
Script lifecycle:
__init__() -> up() run() -> (inner_run() -> commit()) -> down()
up(), (inner_run() -> commit()), and down() and encapsulated by try-blocks, so the script should under no cirucumstances break.
You should define name and script_name class (or instance) variables where name is localised and will show up at top of the progress and script_name is for logging and internal infos found at univention.management.console.modules.setup.util.ProgressParser.FRACTIONS.
You should define your own inner_run-method, and, if needed, override (initially dummy) up() and down().
You should execute a script like so:
script = MySetupScript() script.run()
Or maybe even better like so, as it calls sys.exit:
if __name__ == '__main__': script = MySetupScript() main(script) # helper function defined in here
You may control the progress parser with these methods: * self.header(msg) # automatically called by run() * self.message(msg) * self.error(msg) * self.join_error(msg) * self.steps(steps) * self.step(step)
Initialise Script. Will call self.up() with same *args and **kwargs as __init__() (which itself will leave them untouched)
So don’t override this method, instead write your own up(). The default up()-method does nothing.
self.up() is called in a try-except-block. If an exception was raised by up(), it will be saved and raised as soon as run() is called. You should make sure that this does not happen.
- name = ''#
- inform_progress_parser(progress_attribute: str, msg: object) None[source]#
Internal method to inform progress parser.
At the moment it writes info in a file which will be read by the parser. In a more advanced version, the script could change the state of the progress directly.
- header(msg: object) None[source]#
Write header info of this script (for log file and parser).
Called automatically by run(). Probably unneeded for developers
- error(msg: object) None[source]#
Write a non-critical __ERR__: for the parser The parser will save the error and inform the frontend that something went wrong
- join_error(msg: object) None[source]#
Write a critical __JOINERR__: for the parser. The parser will save it and inform the frontend that something went terribly wrong leaving the system in an unjoined state
- steps(steps: int) None[source]#
Total number of __STEPS__: to come throughout the whole script. Progress within the script should be done with step() which is relative to steps()
- step(step: int | None = None) None[source]#
Inform parser that the next __STEP__: in this script was done. You can provide an exact number or None in which case an internal counter will be incremented
- run() bool[source]#
Run the SetupScript. Don’t override this method, instead define your own
inner_run().Call
header()If up() failed raise its exception. Run inner_run() in a try-except-block Return False if an exception occurred Otherwise return True/False depending on return code of inner_run itself. In any case, run self.down() in a try-except-block afterwards. If this should fail, return False.
- inner_run() bool | None[source]#
Main function, called by run(). Override this method in your SetupScriptClass. You may return True or False which will be propagated to run() itself. If you don’t return False, True will be used implicitly.
- class univention.management.console.modules.setup.setup_script.AptScript(*args, **kwargs)[source]#
Bases:
SetupScriptMore or less just a wrapper around univention.lib.package_manager.PackageManager with SetupScript capabilities.
Initialise Script. Will call self.up() with same *args and **kwargs as __init__() (which itself will leave them untouched)
So don’t override this method, instead write your own up(). The default up()-method does nothing.
self.up() is called in a try-except-block. If an exception was raised by up(), it will be saved and raised as soon as run() is called. You should make sure that this does not happen.
- brutal_apt_options = True#
- up(*args, **kwargs) None[source]#
Override this method if needed. It is called during __init__ with the very same parameters as __init__ was called.
- finish_task(*log_msgs: object) None[source]#
Task is finished. Increment counter and inform the progress parser. Reopen the cache (maybe unneeded but does not slow us down too much).
- commit(install: Iterable[str] = [], remove: Iterable[str] = [], msg_if_failed: str = '') bool[source]#
- univention.management.console.modules.setup.setup_script.main(setup_script: SetupScript, exit: bool = True) int[source]#
Helper function to run the setup_script and evaluate its return code as a “shell-compatible” one. You may sys.exit immediately
univention.management.console.modules.setup.util module#
- Univention Management Console
module: system setup
- univention.management.console.modules.setup.util.load_values(lang: str | None = None) dict[str, str][source]#
- univention.management.console.modules.setup.util.auto_complete_values_for_join(newValues: dict[str, str], current_locale: Locale | None = None) dict[str, str][source]#
- univention.management.console.modules.setup.util.pre_save(newValues: dict[str, str]) None[source]#
Modify the final dict before saving it to the profile file.
- univention.management.console.modules.setup.util.write_profile(values: dict[str, str]) None[source]#
- univention.management.console.modules.setup.util.run_networkscrips(demo_mode: bool = False) None[source]#
- univention.management.console.modules.setup.util.written_profile(values: dict[str, str]) Iterator[None][source]#
- class univention.management.console.modules.setup.util.ProgressParser[source]#
Bases:
object- NAME = re.compile('^__NAME__: *(?P<key>[^ ]*) (?P<name>.*)\n$')#
- MSG = re.compile('^__MSG__: *(?P<message>.*)\n$')#
- STEPS = re.compile('^__STEPS__: *(?P<steps>.*)\n$')#
- STEP = re.compile('^__STEP__: *(?P<step>.*)\n$')#
- JOINERROR = re.compile('^__JOINERR__: *(?P<error_message>.*)\n$')#
- ERROR = re.compile('^__ERR__: *(?P<error_message>.*)\n$')#
- FRACTIONS = {'05_role/10role': 30, '10_basis/12domainname': 15, '10_basis/14ldap_basis': 20, '20_language/11default_locale': 5, '30_net/10interfaces': 20, '30_net/12gateway': 10, '30_net/13ipv6gateway': 10, '40_ssl/10ssl': 10, '50_software/10software': 30, '90_postjoin/10admember': 30, '90_postjoin/20upgrade': 10}#
- univention.management.console.modules.setup.util.sorted_files_in_subdirs(directory: str, allowed_subdirs: Container[str] | None = None) Iterator[str][source]#
- univention.management.console.modules.setup.util.run_scripts(progressParser: ProgressParser, restartServer: bool = False, allowed_subdirs: Container[str] | None = None, lang: str = 'C', args: list[str] = []) None[source]#
- univention.management.console.modules.setup.util.run_joinscript(progressParser: ProgressParser, values: dict[str, str], _username: str, password: str, dcname: str | None = None, lang: str = 'C') None[source]#
- univention.management.console.modules.setup.util.cleanup(with_appliance_hooks: bool = False) None[source]#
- univention.management.console.modules.setup.util.run_scripts_in_path(path: str, logfile: IO[str], category_name: str = '') None[source]#
- univention.management.console.modules.setup.util.detect_interfaces() list[dict[str, str | None]][source]#
Function to detect network interfaces in local sysfs. The loopback interface “lo” will be filtered out. Returns a list of dicts with the entries ‘name’ and ‘mac’.
- univention.management.console.modules.setup.util.dhclient(interface: str, timeout: float = 10.0) dict[str, str][source]#
perform DHCP request for specified interface. If successful, returns a dict similar to the following:
{ 'address': '10.200.26.51', 'broadcast': '10.200.26.255', 'domainname': 'univention.qa', 'gateway': '', 'nameserver_1': '10.200.26.27', 'nameserver_2': '', 'nameserver_3': '', 'netmask': '255.255.255.0' }
- univention.management.console.modules.setup.util.get_apps(no_cache: bool = False) list[dict[str, Any]][source]#
- univention.management.console.modules.setup.util.is_domainname(domainname: str) bool[source]#
Check if domainname is a valid DNS domainname according to RFC952/1123. >>> is_domainname(‘foo’) True >>> is_domainname(‘f00.bar’) True >>> is_domainname(‘-f.bar’) False >>> is_domainname(‘f-.bar’) False >>> is_domainname(‘f..bar’) False >>> is_domainname(‘#.bar’) False >>> is_domainname(‘1234567890123456789012345678901234567890123456789012345678901234.bar’) False
- univention.management.console.modules.setup.util.is_windowsdomainname(domainname: str) bool[source]#
- univention.management.console.modules.setup.util.is_domaincontroller(domaincontroller: str) bool[source]#
- univention.management.console.modules.setup.util.is_ldap_base(ldap_base: str) bool[source]#
>>> is_ldap_base('dc=foo,dc=bar') True >>> is_ldap_base('cn=foo,c=De,dc=foo,dc=bar') True >>> is_ldap_base('cn=foo,c=DED,dc=foo,dc=bar') False >>> is_ldap_base('dc=foo,') False >>> is_ldap_base(',dc=bar') False >>> is_ldap_base('dc=foo') False >>> is_ldap_base('cn=foo,c=ZZ,dc=foo,dc=bar') False
- univention.management.console.modules.setup.util.is_ucs_domain(nameserver: str, domain: str) bool[source]#
- univention.management.console.modules.setup.util.get_ucs_domaincontroller_master_query(nameserver: str, domain: str) Answer | None[source]#
- univention.management.console.modules.setup.util.resolve_domaincontroller_master_srv_record(nameserver: str, domain: str) bool[source]#
- univention.management.console.modules.setup.util.get_available_locales(pattern: Pattern[str], category: str = 'language_en') list[dict[str, str]] | None[source]#
Return a list of all available locales.