Make use of newly introduced content type assertion helpers in the
preconditions check path in the API handler for creating a container.

Signed-off-by: Daniel Kral <d.k...@proxmox.com>
---
changes since v1:
- new!

 src/PVE/API2/LXC.pm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 7cb5122..8e5e6a6 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -306,10 +306,9 @@ __PACKAGE__->register_method({
        my $check_and_activate_storage = sub {
            my ($sid) = @_;
 
-           my $scfg = PVE::Storage::storage_check_enabled($storage_cfg, $sid, 
$node);
-
-           raise_param_exc({ storage => "storage '$sid' does not support 
container directories"})
-               if !$scfg->{content}->{rootdir};
+           PVE::Storage::storage_check_enabled($storage_cfg, $sid, $node);
+           eval { PVE::Storage::assert_content_type_supported($storage_cfg, 
$sid, 'rootdir', $node) };
+           raise_param_exc({ storage => "$@" }) if $@;
 
            $rpcenv->check($authuser, "/storage/$sid", 
['Datastore.AllocateSpace']);
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to