blueprints: fix unbound error

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-08-23 21:15:48 +02:00
parent 13a302cdad
commit b9294fd9ad
1 changed files with 2 additions and 2 deletions

View File

@ -144,6 +144,8 @@ def apply_blueprint(self: MonitoredTask, instance_pk: str):
blueprint_content = instance.retrieve()
file_hash = sha512(blueprint_content.encode()).hexdigest()
importer = Importer(blueprint_content, instance.context)
if importer.blueprint.metadata:
instance.metadata = asdict(importer.blueprint.metadata)
valid, logs = importer.validate()
if not valid:
instance.status = BlueprintInstanceStatus.ERROR
@ -170,6 +172,4 @@ def apply_blueprint(self: MonitoredTask, instance_pk: str):
instance.status = BlueprintInstanceStatus.ERROR
self.set_status(TaskResult(TaskResultStatus.ERROR).with_error(exc))
finally:
if importer.blueprint.metadata:
instance.metadata = asdict(importer.blueprint.metadata)
instance.save()