Allow setting context in the imported MMD file.

We always set the "context" to DEFAULT_MODULE_CONTEXT from the historical
reasons - the context was not stored in the database before and we stored
just the build_context/runtime_context. But this is no longer true for
some time.

In this commit, the context is respected and stored in the database when
importing module using the `import_mmd` method. If the context is not set
in the imported MMD, the DEFAULT_MODULE_CONTEXT is used.
This commit is contained in:
Jan Kaluza
2019-01-28 12:16:07 +01:00
parent 26d707cb8e
commit 642c8406ca
2 changed files with 23 additions and 7 deletions

View File

@@ -277,17 +277,12 @@ def import_mmd(session, mmd):
The ModuleBuild.rebuild_strategy is set to "all".
The ModuleBuild.owner is set to "mbs_import".
TODO: The "context" is not stored directly in database. We only store
build_context and runtime_context and compute context, but when importing
the module, we have no idea what build_context or runtime_context is - we only
know the resulting "context", but there is no way to store it into do DB.
By now, we just ignore mmd.get_context() and use default 00000000 context instead.
:return: module build (ModuleBuild),
log messages collected during import (list)
:rtype: tuple
"""
mmd.set_context(models.DEFAULT_MODULE_CONTEXT)
if not mmd.get_context():
mmd.set_context(models.DEFAULT_MODULE_CONTEXT)
name = mmd.get_name()
stream = mmd.get_stream()
version = str(mmd.get_version())