Skip to content

Commit

Permalink
Document Metadata more clearly
Browse files Browse the repository at this point in the history
The Metadata model stores the metadata of entities such as Actor or
Workflow. This data is stored in a new table of the `leapp.db` file
called `metadata`.

For an actor, the metadata stored contain:

  `class_name` 	- the name of the actor class
  `name` 	- the name given to the actor
  `description` - the actor's description
  `phase` 	- phase of execution of the actor
  `tags` 	- names of any tags associated with an actor
  `consumes` 	- list of all messages the actor consumes
  `produces`	- list of all messages the actor produces
  `path`	- the path to the actor source file

For a workflow, the metadata stored contain:

  `name` 	- name of the workflow
  `short_name` 	- short name of the workflow
  `tag` 	- workflow tag
  `description`	- workflow description
  `phases` 	- all phases associated with the workflow
  • Loading branch information
dkubek committed Jan 31, 2024
1 parent 3873556 commit a0ec081
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion leapp/utils/audit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def do_store(self, connection):

class Metadata(Host):
"""
Entity metadata
Metadata of an entity (e.g. actor, workflow)
"""

def __init__(self, context=None, hostname=None, kind=None, metadata=None, name=None):
Expand All @@ -232,6 +232,12 @@ def __init__(self, context=None, hostname=None, kind=None, metadata=None, name=N
:type context: str
:param hostname: Hostname of the system that produced the entry
:type hostname: str
:param kind: Kind of the entity for which metadata is stored
:type kind: str
:param metadata: Actual metadata
:type metadata: dict
:param name: Name of the entity
:type name: str
"""
super(Metadata, self).__init__(context=context, hostname=hostname)
self.kind = kind
Expand Down
8 changes: 6 additions & 2 deletions leapp/workflows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,15 @@ def run(self, context=None, until_phase=None, until_actor=None, skip_phases_unti
'consumes': [model.__name__ for model in metadata.get('consumes', ())],
'produces': [model.__name__ for model in metadata.get('produces', ())],
'tags': [tag.__name__ for tag in metadata.get('tags', ())],
'dialogs': [dialog.serialize() for dialog in metadata.get('dialogs', ())],
'phase': phase[0].name,
})

metadata_fields = (
'class_name', 'name', 'description', 'phase', 'tags', 'consumes', 'produces', 'path'
)
md = Metadata(kind='actor', name=actor.name, context=context,
hostname=os.environ['LEAPP_HOSTNAME'], metadata=metadata)
hostname=os.environ['LEAPP_HOSTNAME'],
metadata={field: metadata[field] for field in metadata_fields})
md.store()

self._stop_after_phase_requested = False
Expand Down

0 comments on commit a0ec081

Please sign in to comment.