]> git.proxmox.com Git - pve-storage.git/commitdiff
pvesm list fix
authorAlen Grizonic <a.grizonic@proxmox.com>
Mon, 28 Sep 2015 08:16:33 +0000 (10:16 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 29 Sep 2015 15:25:05 +0000 (17:25 +0200)
PVE/API2/Storage/Content.pm

index a7e9fe3be0ceb75edaf37ac88f64f863b033f60d..63dc0a44cd21369af6de7e83fec4365688334ced 100644 (file)
@@ -67,6 +67,8 @@ __PACKAGE__->register_method ({
 
        my $storeid = $param->{storage};
 
+       my $vmid = $param->{vmid};
+
        my $cfg = cfs_read_file("storage.cfg");
 
        my $scfg = PVE::Storage::storage_config($cfg, $storeid);
@@ -74,14 +76,19 @@ __PACKAGE__->register_method ({
        my $res = [];
        foreach my $ct (@$cts) {
            my $data;
-           if ($ct eq 'images' || defined($param->{vmid})) {
+           if ($ct eq 'images') {
                $data = PVE::Storage::vdisk_list ($cfg, $storeid, $param->{vmid});
-           } elsif ($ct eq 'iso') {
+           } elsif ($ct eq 'iso' && !defined($param->{vmid})) {
                $data = PVE::Storage::template_list ($cfg, $storeid, 'iso');
-           } elsif ($ct eq 'vztmpl') {
+           } elsif ($ct eq 'vztmpl'&& !defined($param->{vmid})) {
                $data = PVE::Storage::template_list ($cfg, $storeid, 'vztmpl');
            } elsif ($ct eq 'backup') {
                $data = PVE::Storage::template_list ($cfg, $storeid, 'backup');
+               foreach my $item (@{$data->{$storeid}}) {
+                   if (defined($vmid)) {
+                       @{$data->{$storeid}} = grep { $_->{volid} =~ m/\S+-$vmid-\S+/ } @{$data->{$storeid}};
+                   }
+               }
            }
 
            next if !$data || !$data->{$storeid};