5
0
mirror of git://git.proxmox.com/git/pve-storage.git synced 2024-12-22 13:34:16 +03:00

rbd: get volume size for volumes list

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
Alexandre Derumier 2012-10-16 16:38:13 +02:00 committed by Dietmar Maurer
parent 6958944439
commit e110213e71

View File

@ -56,7 +56,7 @@ sub rbd_ls {
$list->{$scfg->{pool}}->{$image} = {
name => $image,
size => 0,
size => rbd_volume_size($scfg, $storeid, $image),
vmid => $owner
};
}
@ -72,6 +72,26 @@ sub rbd_ls {
return $list;
}
sub rbd_volume_size {
my ($scfg, $storeid, $volname) = @_;
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;
}
sub addslashes {
my $text = shift;
$text =~ s/;/\\;/g;
@ -282,21 +302,7 @@ sub deactivate_volume {
sub volume_size_info {
my ($class, $scfg, $storeid, $volname, $timeout) = @_;
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;
return rbd_volume_size($scfg, $storeid, $volname);
}
sub volume_resize {