api: import-metadata: make warnings structured & merge ignored-volumes

This allows the frontends to translate them and avoids somewhat
duplicated info by having some warnings explicitly (ignored-volumes)
while others are in the warnings array.

By passing along the key and the value the frontend can also show the
warnings in-line, e.g. by marking a disk-entry in a grid as having
potential problems.

Ideally we'd have a central list of known types used for the API
return schema enum and to check when calling the $warn closure, but as
we only got three warnings keep this as is and only add a comment.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht
2024-03-10 19:25:34 +01:00
parent b628964289
commit 1a94dceb6f
2 changed files with 28 additions and 15 deletions

View File

@ -738,12 +738,6 @@ __PACKAGE__->register_method({
optional => 1,
description => 'Recognised network interfaces as `net$id` => { ...params } object.',
},
'ignored-volumes' => {
type => 'object',
additionalProperties => 1,
optional => 1,
description => 'Volumes that are explicitly ignored, like e.g., CDROM drives on ESXi.',
},
'warnings' => {
type => 'array',
description => 'List of known issues that can affect the import of a guest.'
@ -753,7 +747,24 @@ __PACKAGE__->register_method({
type => "object",
additionalProperties => 1,
properties => {
message => {
'type' => {
description => 'What this warning is about.',
enum => [
'cdrom-image-ignored',
'nvme-unsupported',
'ovmf-with-lsi-unsupported',
'serial-port-socket-only',
],
type => 'string',
},
'key' => {
description => 'Related subject (config) key of warning.',
optional => 1,
type => 'string',
},
'value' => {
description => 'Related subject (config) value of warning.',
optional => 1,
type => 'string',
},
},