]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/API2/Storage/Content.pm
PVE::Storage: new helper check_volume_access()
[pve-storage.git] / PVE / API2 / Storage / Content.pm
index 03f9b26741797d4f2006a4a698f28867f023ba7a..699823bf560a94cad864294a5a300a8ce0b27705 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 use Data::Dumper;
 
 use PVE::SafeSyslog;
-use PVE::Cluster qw(cfs_read_file);
+use PVE::Cluster;
 use PVE::Storage;
 use PVE::INotify;
 use PVE::Exception qw(raise_param_exc);
@@ -66,13 +66,13 @@ __PACKAGE__->register_method ({
 
        my $storeid = $param->{storage};
 
-       my $cfg = cfs_read_file("storage.cfg");
+       my $cfg = PVE::Storage::config();
 
        my $vollist = PVE::Storage::volume_list($cfg, $storeid, $param->{vmid}, $param->{content});
 
        my $res = [];
        foreach my $item (@$vollist) {
-           eval { $rpcenv->check_volume_access($authuser, $cfg, undef, $item->{volid}); };
+           eval {  PVE::Storage::check_volume_access($rpcenv, $authuser, $cfg, undef, $item->{volid}); };
            next if $@;
            push @$res, $item;
        }
@@ -150,7 +150,7 @@ __PACKAGE__->register_method ({
            $param->{format} = $fmt;
        }
 
-       my $cfg = cfs_read_file('storage.cfg');
+       my $cfg = PVE::Storage::config();
     
        my $volid = PVE::Storage::vdisk_alloc ($cfg, $storeid, $param->{vmid}, 
                                               $param->{format}, 
@@ -217,9 +217,9 @@ __PACKAGE__->register_method ({
 
        my ($volid, $storeid) = &$real_volume_id($param->{storage}, $param->{volume});
 
-       my $cfg = cfs_read_file('storage.cfg');
+       my $cfg = PVE::Storage::config();
 
-       $rpcenv->check_volume_access($authuser, $cfg, undef, $volid);
+       PVE::Storage::check_volume_access($rpcenv, $rpcenv->$authuser, $cfg, undef, $volid);
 
        my $path = PVE::Storage::path($cfg, $volid);
        my ($size, $format, $used, $parent) =  PVE::Storage::file_size_info($path);
@@ -267,7 +267,7 @@ __PACKAGE__->register_method ({
        my $rpcenv = PVE::RPCEnvironment::get();
        my $authuser = $rpcenv->get_user();
 
-       my $cfg = cfs_read_file('storage.cfg');
+       my $cfg = PVE::Storage::config();
 
        my ($volid, $storeid) = &$real_volume_id($param->{storage}, $param->{volume});
 
@@ -331,7 +331,7 @@ __PACKAGE__->register_method ({
 
        print "DEBUG: COPY $src_volid TO $dst_volid\n";
 
-       my $cfg = cfs_read_file('storage.cfg');
+       my $cfg = PVE::Storage::config();
 
        # do all parameter checks first