plugin: dir: implement import content type

in DirPlugin and not Plugin (because of cyclic dependency of
Plugin -> OVF -> Storage -> Plugin otherwise)

only ovf is currently supported (though ova will be shown in import
listing), expects the files to not be in a subdir, and adjacent to the
ovf file.

listed will be all ovf/qcow2/raw/vmdk files.
ovf because it can be imported, and the rest because they can be used
in the 'import-from' part of qemu-server.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Dominik Csapak
2024-11-18 16:29:04 +01:00
committed by Thomas Lamprecht
parent 4e97c507d2
commit d955a46a32
6 changed files with 83 additions and 3 deletions

View File

@ -86,6 +86,14 @@ my $tests = [
expected => ['snippets', 'hookscript.pl'],
},
#
# Import
#
{
description => "Import, ovf",
volname => 'import/import.ovf',
expected => ['import', 'import.ovf', undef, undef, undef ,undef, 'ovf'],
},
#
# failed matches
#
{
@ -123,6 +131,11 @@ my $tests = [
volname => "$vmid/base-$vmid-disk-0.qcow2/ssss/vm-$vmid-disk-0.qcow2",
expected => "unable to parse volume filename 'base-$vmid-disk-0.qcow2/ssss/vm-$vmid-disk-0.qcow2'\n",
},
{
description => "Failed match: import dir but no ova/ovf/disk image",
volname => "import/test.foo",
expected => "unable to parse directory volume name 'import/test.foo'\n",
},
];
# create more test cases for VM disk images matches

View File

@ -190,6 +190,14 @@ my @tests = (
'local:vztmpl/debian-10.0-standard_10.0-1_amd64.tar.xz',
],
},
{
description => 'Import, ovf',
volname => "$storage_dir/import/import.ovf",
expected => [
'import',
'local:import/import.ovf',
],
},
# no matches, path or files with failures
{
@ -237,6 +245,11 @@ my @tests = (
volname => "$storage_dir/images/ssss/vm-1234-disk-0.qcow2",
expected => [''],
},
{
description => 'Import, non ova/ovf/disk image in import dir',
volname => "$storage_dir/import/test.foo",
expected => [''],
},
);
plan tests => scalar @tests + 1;