applied, thanks > -----Original Message----- > From: pve-devel-boun...@pve.proxmox.com [mailto:pve-devel- > boun...@pve.proxmox.com] On Behalf Of Alexandre Derumier > Sent: Dienstag, 16. Oktober 2012 16:38 > To: pve-devel@pve.proxmox.com > Subject: [pve-devel] [PATCH] rbd: get volume size for volumes list > > > Signed-off-by: Alexandre Derumier <aderum...@odiso.com> > --- > PVE/Storage/RBDPlugin.pm | 38 ++++++++++++++++++++++---------------- > 1 file changed, 22 insertions(+), 16 deletions(-) > > diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm index > b05d299..33ae853 100644 > --- a/PVE/Storage/RBDPlugin.pm > +++ b/PVE/Storage/RBDPlugin.pm > @@ -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 { > -- > 1.7.10.4 > > _______________________________________________ > pve-devel mailing list > pve-devel@pve.proxmox.com > http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
_______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel