introduce 'pve-storage-image-format' standard option for image format
The new 'pve-storage-image-format' standard option uses a simple enum instead of a subroutine verifier. Since the 'pve-storage-format' format that is replaced by it was used in pve-guest-common's StorageTunnel, the format cannot be removed without a versioned breaks. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Acked-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
559867f79b
commit
2569cb4604
@ -6,7 +6,7 @@ use warnings;
|
||||
use PVE::SafeSyslog;
|
||||
use PVE::Cluster;
|
||||
use PVE::Storage;
|
||||
use PVE::Storage::Plugin; # for 'pve-storage-format' format
|
||||
use PVE::Storage::Common; # for 'pve-storage-image-format' standard option
|
||||
use PVE::INotify;
|
||||
use PVE::Exception qw(raise_param_exc);
|
||||
use PVE::RPCEnvironment;
|
||||
@ -178,12 +178,10 @@ __PACKAGE__->register_method ({
|
||||
type => 'string',
|
||||
pattern => '\d+[MG]?',
|
||||
},
|
||||
'format' => {
|
||||
type => 'string',
|
||||
format => 'pve-storage-format',
|
||||
format => get_standard_option('pve-storage-image-format', {
|
||||
requires => 'size',
|
||||
optional => 1,
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
returns => {
|
||||
|
||||
@ -3,6 +3,8 @@ package PVE::Storage::Common;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use PVE::JSONSchema;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
@ -25,6 +27,31 @@ be grouped in a submodule can also be found here.
|
||||
|
||||
=back
|
||||
|
||||
=head1 STANDARD OPTIONS FOR JSON SCHEMA
|
||||
|
||||
=over
|
||||
|
||||
=back
|
||||
|
||||
=head3 pve-storage-image-format
|
||||
|
||||
Possible formats a guest image can have.
|
||||
|
||||
=cut
|
||||
|
||||
# TODO PVE 9 - Note that currently, qemu-server allows more formats for VM images, so third party
|
||||
# storage plugins might potentially allow more too, but none of the plugins we are aware of do that.
|
||||
# Those formats should either be allowed here or support for them should be phased out (at least in
|
||||
# the storage layer). Can still be added again in the future, should any plugin provider request it.
|
||||
|
||||
PVE::JSONSchema::register_standard_option('pve-storage-image-format', {
|
||||
type => 'string',
|
||||
enum => ['raw', 'qcow2', 'subvol', 'vmdk'],
|
||||
description => "Format of the image.",
|
||||
});
|
||||
|
||||
=pod
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=cut
|
||||
|
||||
@ -184,11 +184,10 @@ my $defaultData = {
|
||||
type => 'string', format => 'pve-storage-path',
|
||||
optional => 1,
|
||||
},
|
||||
'format' => {
|
||||
format => get_standard_option('pve-storage-image-format', {
|
||||
description => "Default image format.",
|
||||
type => 'string', format => 'pve-storage-format',
|
||||
optional => 1,
|
||||
},
|
||||
}),
|
||||
preallocation => {
|
||||
description => "Preallocation mode for raw and qcow2 images. " .
|
||||
"Using 'metadata' on raw images results in preallocation=off.",
|
||||
@ -342,6 +341,10 @@ sub verify_content {
|
||||
return $ct;
|
||||
}
|
||||
|
||||
# NOTE the 'pve-storage-format' is deprecated, use the 'pve-storage-image-format' standard option
|
||||
# from Storage/Common.pm instead
|
||||
# TODO PVE 9 - remove after doing a versioned breaks for pve-guest-common, which was using this
|
||||
# format.
|
||||
PVE::JSONSchema::register_format('pve-storage-format', \&verify_format);
|
||||
sub verify_format {
|
||||
my ($fmt, $noerr) = @_;
|
||||
|
||||
Reference in New Issue
Block a user