[pve-devel] [PATCH 3/6] rbd : volume_size_info

Alexandre Derumier aderumier at odiso.com
Sun Aug 5 10:16:47 CEST 2012


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

diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 7b6597e..76ab9b2 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -249,7 +249,21 @@ sub deactivate_volume {
 sub volume_size_info {
     my ($class, $scfg, $storeid, $volname, $timeout) = @_;
 
-    return undef;
+    my $cmd = &$rbd_cmd($scfg, $storeid, 'info', $volname);
+    my $size = undef;
+    my $parser = sub {
+        my $line = shift;
+
+        if ($line =~ m/size (\d+) MB in (\d+) objects/) {
+            $size = $1;
+        }
+    };
+
+    run_command($cmd, errmsg => "rbd error", errfunc => sub {}, outfunc => $parser);
+
+    $size = $size*1024*1024 if $size;
+
+    return $size;
 }
 
 1;
-- 
1.7.2.5




More information about the pve-devel mailing list