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 v2:
  * rename helper from *_supported to *_available
  * lower/remove storage_check_enabled to storage_config where possible
    due to the helper already checking that

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

diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm
index 5c6ee57..947021a 100644
--- a/src/PVE/API2/LXC.pm
+++ b/src/PVE/API2/LXC.pm
@@ -317,10 +317,10 @@ __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};
+           eval {
+               PVE::Storage::assert_content_type_available($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