- class activelogic.Resource
This is the parent class for all resources.
Connectioninstantiates all resources:
c = await conn.config() rs = await conn.ruleset()
Each resource defines a subset of the system’s configuration and has its own set of privileges in the user database:
None - User can’t access the resource at all.
Read - User can run read-only commands on the resource.
Write - User can run all commands on the resource.
A session attached to the resource will always be in a transaction. There is also implicit locks on each resource that are taken when the first manipulative command is sent, and released when changes are committed or rolled back.
# Alt 1. async with await conn.config() as c: await c.update('DRDL_ENABLED', True) # Alt 2. await c.update('DRDL_ENABLED', True) await c.commit()
Issuing commands on an outdated resource will result in that
- class activelogic.Flag
Object representing a flag definition.
name (str) – Name of the flag definition.
- class activelogic.Service
Object representing a service definition.
name (str) – Name of the service definition.
The machine id of the system that owns the resource.
>>> res.machineid '001122334455'
The firmware version running on the system that owns the resource.
>>> res.distversion '22.20.06.1'
- async Resource.list(cls)
Generic list function for definitions that does not belong to any specific resource.
cls – Object type that determines what kind of data to get.
A list of given dataclass type.
ValueError – Invalid dataclass type.
PLDBNewDataCommitted – Conflict with new data committed by an other session.
Resources may override this method, but will fallback to this generic method if cls does not match any resource-specific type. Definitions listen in this method cannot be modified:
List may or may not be cached, depending on if
Sets the commit message of the next commit.
commit_message (str) –
This function is typically used for setting proper commit message in context manager-based commits:
>>> with conn.config() as c: ... c.update("GEOLOGIC_ENABLED", True) ... c.set_commit_message("Enable GeoLogic function")
- async Resource.commit(commit_message=None)
Stores the current transaction to the database.
commit_message (str) – Message recorded in the commit log.
This command makes your changes visible to others.
It is usually a good practice to commit changes in batches. In particular if changes are committed to
Ruleset. This will reload the ruleset and take a lot of CPU resources from the system.
- async Resource.rollback()
Aborts the current transaction and discards the changes.
This also automatically happens if your connection drops or you exit the program without committing your changes.
Enables or disables the caching mechanism for the resource.
enable (bool) –
For optimal performance, caching should always be enabled. All resources have their caching enabled by default.
Invalidates a specific cache, or all caches tied to the current resource.
The cache is always invalidated if the current transaction is rolled back or committed.
cache_id (str) – Id of the cache to invalidate, or empty if all caches should be invalidated.
- async Resource.ping(data)
Sends a message to session to test if it is up.
data (bytes) – Data to send.
The echo reply from remote session.
>>> res.ping(b"hello") b'hello'