From c95c307373260b659a0e7623081e7d3637faa2c3 Mon Sep 17 00:00:00 2001 From: Alexandre Derumier Date: Sun, 5 Aug 2012 10:16:47 +0200 Subject: [PATCH] rbd : volume_size_info Signed-off-by: Alexandre Derumier --- PVE/Storage/RBDPlugin.pm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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;