rbd_unittobytes: use a local var instead of a sub
This commit is contained in:
@ -10,13 +10,11 @@ use PVE::JSONSchema qw(get_standard_option);
|
|||||||
|
|
||||||
use base qw(PVE::Storage::Plugin);
|
use base qw(PVE::Storage::Plugin);
|
||||||
|
|
||||||
sub rbd_unittobytes {
|
my $rbd_unittobytes = {
|
||||||
{
|
"M" => 1024*1024,
|
||||||
"M" => 1024*1024,
|
"G" => 1024*1024*1024,
|
||||||
"G" => 1024*1024*1024,
|
"T" => 1024*1024*1024*1024,
|
||||||
"T" => 1024*1024*1024*1024,
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
my $add_pool_to_disk = sub {
|
my $add_pool_to_disk = sub {
|
||||||
my ($scfg, $disk) = @_;
|
my ($scfg, $disk) = @_;
|
||||||
@ -189,7 +187,7 @@ sub rbd_ls {
|
|||||||
|
|
||||||
$list->{$pool}->{$image} = {
|
$list->{$pool}->{$image} = {
|
||||||
name => $image,
|
name => $image,
|
||||||
size => $size*rbd_unittobytes()->{$unit},
|
size => $size*$rbd_unittobytes->{$unit},
|
||||||
parent => $parent,
|
parent => $parent,
|
||||||
vmid => $owner
|
vmid => $owner
|
||||||
};
|
};
|
||||||
@ -226,7 +224,7 @@ sub rbd_volume_info {
|
|||||||
my $line = shift;
|
my $line = shift;
|
||||||
|
|
||||||
if ($line =~ m/size (\d+) (M|G|T)B in (\d+) objects/) {
|
if ($line =~ m/size (\d+) (M|G|T)B in (\d+) objects/) {
|
||||||
$size = $1 * rbd_unittobytes()->{$2} if ($1);
|
$size = $1 * $rbd_unittobytes->{$2} if ($1);
|
||||||
} elsif ($line =~ m/parent:\s(\S+)\/(\S+)/) {
|
} elsif ($line =~ m/parent:\s(\S+)\/(\S+)/) {
|
||||||
$parent = $2;
|
$parent = $2;
|
||||||
} elsif ($line =~ m/format:\s(\d+)/) {
|
} elsif ($line =~ m/format:\s(\d+)/) {
|
||||||
|
|||||||
Reference in New Issue
Block a user