[pve-devel] [PATCH] rbd : rbd_ls: doesn't throw error if pool doesn't contain image

Alexandre Derumier aderumier at odiso.com
Sat Jun 16 11:43:52 CEST 2012


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Storage/RBDPlugin.pm |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 83c6774..fc264d0 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -19,19 +19,29 @@ sub rbd_ls{
 
     my $cmd = ['/usr/bin/rbd', '-p', $rbdpool, '-m', $monhost, '-n', "client.".$scfg->{username} ,'--keyfile', '/etc/pve/priv/ceph/'.$storeid.'.'.$scfg->{username}.'.key', '--auth_supported',$scfg->{authsupported}, 'ls' ];
     my $list = {};
-    run_command($cmd, errfunc => sub {},outfunc => sub {
+
+    my $errfunc = sub {
         my $line = shift;
+	die $line;	
+    };
 
-        $line = trim($line);
-        my ($image) = $line;
+    eval {   
+	run_command($cmd, errmsg => "rbd error", errfunc => $errfunc,outfunc => sub {
+            my $line = shift;
+
+            $line = trim($line);
+            my ($image) = $line;
 	
-        $list->{$rbdpool}->{$image} = {
-            name => $image,
-            size => "",
-        };
+	    $list->{$rbdpool}->{$image} = {
+                name => $image,
+	        size => "",
+            };
 
-    });
+	});
+    };
 
+    my $err = $@;
+    die $err if ($err !~ m/doesn't contain rbd images/) ;
 
     return $list;
 
-- 
1.7.2.5




More information about the pve-devel mailing list