System Configuration
- class activelogic.Config
This is the resource that governs the system configuration database of an ActiveLogic system.
A configuration value essentially is a key-value pair, where the key serves as a unique identifier. All values are stored as strings in the configuration database, but config_type determines how it should be handled.
All configuration values comes with a default value as well as a min/max range. All these values may differ for different platforms.
Caution
Enforcement of min/max range can be disabled by setting
_VERIFY_MINMAX
toFalse
. This option is reserved for advanced users. Setting out-of-range configuration values may render the system unusable.Config is a database-bound resource. Thus changes will not take effect until the database transaction is committed.
- async Config.list(cls)
Generic list function for all kind of data that belongs to this resource.
- Parameters:
cls – Object type that determines what kind of data to get.
- Returns:
A list of given dataclass type.
- Raises:
ValueError – Invalid dataclass type.
PLDBNewDataCommitted – Conflict with new data committed by an other session.
The following data can be listed from this resource:
ConfigValue: Lists all configuration values.
ConfigCategory: Lists all configuration categories.
ConfigFlags: List all configuration flags.
List may or may not be cached, depending on if
cache_enabled
is set.>>> c.list(ConfigValue) [ConfigValue(key='ALLOW_FWD_ON_INJECT', value=False), ConfigValue(key='ALWAYS_FORWARD', value=True), ...] >>> c.list(ConfigCategory) [ConfigCategory(id=1, name='DRDL'), ConfigCategory(id=2, name='Packet Handling'), ...] >>> c.list(ConfigFlag) [ConfigFlag(bit=0, name='Restart Engine'), ConfigFlag(bit=1, name='Restart core services'), ...]
The result can be filtered using Python’s list comprehension syntax. For example, to list all changed configuration values:
>>> [v.key for v in c.list(ConfigValue) if v.value != v.default_value] ['SHAPING_OR_BORROWING', 'SHAPING_MAX_RULES_PER_CONNECTION', ...]
- class activelogic.ConfigType
Defines a set of numeric constants representing available configuration types:
- Variables:
INVISIBLE – Invisible configuration that cannot be set.
STRING – String value.
INTEGER – Integer value.
IPADDRESS – IP address represented as a string.
FLOAT – Float value.
BOOLEAN –
True
orFalse
- class activelogic.ConfigValue
Object representing a system configuration value.
- Parameters:
key (str) – Configuration key.
value (str, int, float or bool) – Configuration value.
config_type (int) – Configuration type. See
activelogic.ConfigType
.str (relates_to) – Parent configuration.
str – Related configurations.
min_value (str, int, float or bool) – Minimum allowed value for the configuration.
max_value (str, int, float or bool) – Maximum allowed value for the configuration.
default_value (str, int, float or bool) – Default value for the configuration.
description (str) – Configuration description.
visible (bool) – Configuration visibility. Hidden configurations typically are reserved for advanced usage or debugging.
category (int) – Configuration category.
flags (int) – Configuration flags. Typically restart options.
modified_by (str) – User that made the most recent modification.
modification_date (str) – Modification date.
Reading Configurations
- async Config.get(key)
Gets the configuration value object for a given key.
- Parameters:
key (str) – The configuration key.
- Returns:
The
ConfigValue
for the given key.- Raises:
ValueError – Config key was not found.
PLDBNewDataCommitted – Conflict with new data committed by another session.
- async Config.get_value(key)
Gets the configuration value for a given key.
- Parameters:
key (str) – The configuration key.
- Returns:
The configuration value for the given key.
- Return type:
str, int, float or bool
- Raises:
see
Config.get()
.
Updating Configurations
- async Config.update(key, value)
Locks the System Configuration resource on the connected system and updates a configuration with the given value.
- Parameters:
key (str or
ConfigValue
) – The key or object to update.value (str, int, float or bool) – The new configuration value.
- Raises:
KeyError – The config key was not found.
TypeError – Value is of incorrect type.
ValueError – Numeric value is not within configuration’s min/max range.
PLDBError – The current user lacks write permissions on this resource.
PLDBError – Resource is locked for writing by another user.
PLDBNewDataCommitted – Conflict with new data committed by an other session.
Categories
- class activelogic.ConfigCategory
Object representing a configuration category.
- Parameters:
id (int) – Category ID.
name (str) – Category name.
- class activelogic.ConfigFlag
Object representing a configuration flag.
- Parameters:
bit (int) – Bit position in
ConfigValue
’s flags field.name (str) – Flag description.