leapp.utils.audit package
Module contents
- class leapp.utils.audit.ActorConfig(context=None, config=None)
Bases:
StorableActor configuration
- Parameters:
context (str) – The execution context
config (
leapp.utils.audit.ActorConfigData) – Actor configuration
- property actor_config_id
Returns the id of the entry, which is only set when already stored. :return: Integer id or None
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- class leapp.utils.audit.ActorConfigData(config=None, hash_id=None)
Bases:
StorableActor configuration data
- Parameters:
config (str) – Actor configuration
hash_id (str) – SHA256 hash in hexadecimal representation of config
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- class leapp.utils.audit.Audit(event=None, stamp=None, message=None, data=None, actor=None, phase=None, hostname=None, context=None)
Bases:
DataSource- Parameters:
event (str) – Type of this event e.g. new-message or log-message but can be anything
stamp (str) – Timestamp string of the event creation in iso format
message (
leapp.utils.audit.Messageor None) – A message object, if this audit entry represents a message otherwise Nonedata (str or None) – If message is None this has to be the data for the audit entry
actor (str) – Name of the actor that triggered the entry
phase (str) – In which phase of the workflow execution the data entry was created
context (str) – The execution context
hostname (str) – Hostname of the system that produced the entry
- property audit_id
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- class leapp.utils.audit.DataSource(actor=None, phase=None, context=None, hostname=None)
Bases:
Host- Parameters:
actor (str) – Name of the actor that triggered the entry
phase (str) – In which phase of the workflow execution the data entry was created
context (str) – The execution context
hostname (str) – Hostname of the system that produced the entry
- property data_source_id
Returns the id of the entry, which is only set when already stored. :return: Integer id or None
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- class leapp.utils.audit.Dialog(scope=None, data=None, actor=None, phase=None, hostname=None, context=None)
Bases:
DataSourceStores information about dialog questions and their answers
- Parameters:
scope (str) – Dialog scope
data (dict) – Payload data
actor (str) – Name of the actor that triggered the entry
phase (str) – In which phase of the workflow execution the dialog was triggered
hostname (str) – Hostname of the system that produced the message
context (str) – The execution context
- property dialog_id
Returns the id of the entry, which is only set when already stored. :return: Integer id or None
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- class leapp.utils.audit.Entity(context=None, hostname=None, kind=None, metadata=None, name=None)
Bases:
HostLeapp framework entity (e.g. actor, workflow)
- Parameters:
context (str) – The execution context
hostname (str) – Hostname of the system that produced the entry
kind (str) – Kind of the entity for which metadata is stored
metadata (
leapp.utils.audit.Metadata) – Entity metadataname (str) – Name of the entity
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- property entity_id
Returns the id of the entry, which is only set when already stored. :return: Integer id or None
- class leapp.utils.audit.Execution(context=None, kind=None, configuration=None, stamp=None)
Bases:
StorableStores information about the current execution
- Parameters:
context (str) – Execution context identifier
kind (str) – Execution kind - Can be any string and used for filtering
configuration (str, dict, list or tuple) –
stamp (str) – Timestamp string of the execution start in iso format
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- property execution_id
Returns the id of the entry, which is only set when already stored. :return: Integer id or None
- class leapp.utils.audit.Host(context=None, hostname=None)
Bases:
StorableHost information
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- property host_id
Returns the id of the entry, which is only set when already stored. :return: Integer id or None
- class leapp.utils.audit.Message(stamp=None, msg_type=None, topic=None, data=None, actor=None, phase=None, hostname=None, context=None)
Bases:
DataSource- Parameters:
stamp (str) – Timestamp string of the message creation in iso format
msg_type (str) – Name of the model that represents the message payload
topic (str) – Topic for this message
data (
leapp.utils.audit.MessageData) – Payload dataactor (str) – Name of the actor that triggered the entry
phase (str) – In which phase of the workflow execution the message was created
context (str) – The execution context
hostname (str) – Hostname of the system that produced the message
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- property message_id
Returns the id of the entry, which is only set when already stored. :return: Integer id or None
- class leapp.utils.audit.MessageData(data=None, hash_id=None)
Bases:
StorableMessage data
- Parameters:
data (str) – Message payload
hash_id (str) – SHA256 hash in hexadecimal representation of data
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- class leapp.utils.audit.Metadata(metadata=None, hash_id=None)
Bases:
StorableMetadata of an Entity
- Parameters:
metadata (str) – Entity metadata
hash_id (str) – SHA256 hash in hexadecimal representation of data
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- class leapp.utils.audit.Storable
Bases:
objectBase class for database storables
- do_store(connection)
Performs the actual storing of the data
- Parameters:
connection – Database connection to use (Can be a transaction cursor)
- Returns:
None
- store(db=None)
Stores the data within a transaction :param db: Database object (optional) :return: None
- leapp.utils.audit.checkpoint(actor, phase, context, hostname)
Creates a checkpoint audit entry
- Parameters:
actor (str) – Name of the actor that triggered the entry
phase (str) – In which phase of the workflow execution the data entry was created
context (str) – The execution context
hostname (str) – Hostname of the system that produced the entry
- Returns:
None
- leapp.utils.audit.create_audit_entry(event, data, message=None)
Create an audit entry
- Parameters:
event – Event type identifier
data – Data related to Type of the event, e.g. a command and its arguments
message – An optional message.
- Returns:
- leapp.utils.audit.create_connection(path)
Creates a database connection to the path and ensures it’s initialized and up to date.
- Parameters:
path – Path to the database
- Returns:
Connection object
- leapp.utils.audit.dict_factory(cursor, row)
- leapp.utils.audit.get_audit_entry(event, context)
Retrieve audit entries stored in the database for the given context
- Parameters:
event (str) – Event type identifier
context (str) – The execution context
- Returns:
list of dicts with id, time stamp, actor and phase fields
- leapp.utils.audit.get_checkpoints(context)
Retrieve all checkpoints stored in the database for the given context
- Parameters:
context (str) – The execution context
- Returns:
list of dicts with id, timestamp, actor and phase fields
- leapp.utils.audit.get_connection(db)
Get the database connection or passes it through if it is already set
- Parameters:
db – Database connection to be passed through in case it exists already
- Returns:
database object initialized and migrated to the latest schema version
- leapp.utils.audit.get_errors(context)
Queries all error messages from the database for the given context
- Parameters:
context (str) – The execution context
- Returns:
List of error messages
- leapp.utils.audit.get_messages(names, context, connection=None)
Queries all messages from the database for the given context and the list of model names :param names: List of names that should be messages returned for :type names: list or tuple of str :param context: Execution id the message should be queried from. :param connection: Database connection to use instead of the default one. :return: Iterable with messages :rtype: iterable
- leapp.utils.audit.store_actor_metadata(actor_definition, phase)
Store the metadata of the given actor given as an
actor_definitionobject into the database.- Parameters:
actor_definition (
leapp.repository.actor_definition.ActorDefinition) – Actor to store
- leapp.utils.audit.store_dialog(dialog, answer)
Store
dialogwith accompanyinganswer.- Parameters:
dialog (
leapp.dialogs.Dialog) – instance of a workflow to store.answer (dict) – Answer to for each component of the dialog
- leapp.utils.audit.store_workflow_metadata(workflow)
Store the metadata of the given
workflowinto the database.- Parameters:
workflow (
leapp.workflows.Workflow) – Workflow to store.