[pve-devel] [PATCH] pvesm list fix

Alen Grizonic a.grizonic at proxmox.com
Mon Sep 28 10:16:33 CEST 2015


---
 PVE/API2/Storage/Content.pm | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/PVE/API2/Storage/Content.pm b/PVE/API2/Storage/Content.pm
index a7e9fe3..63dc0a4 100644
--- a/PVE/API2/Storage/Content.pm
+++ b/PVE/API2/Storage/Content.pm
@@ -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};
-- 
2.1.4





More information about the pve-devel mailing list