ceph tools: make rados open if not reused shorter

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-04-28 19:39:52 +02:00
parent 0ac20586ac
commit 24f3f2bc29

View File

@ -257,10 +257,7 @@ sub set_pool {
sub create_pool { sub create_pool {
my ($pool, $param, $rados) = @_; my ($pool, $param, $rados) = @_;
$rados = PVE::RADOS->new() if !defined($rados);
if (!defined($rados)) {
$rados = PVE::RADOS->new();
}
my $pg_num = $param->{pg_num} || 128; my $pg_num = $param->{pg_num} || 128;
@ -277,10 +274,7 @@ sub create_pool {
sub ls_pools { sub ls_pools {
my ($pool, $rados) = @_; my ($pool, $rados) = @_;
$rados = PVE::RADOS->new() if !defined($rados);
if (!defined($rados)) {
$rados = PVE::RADOS->new();
}
my $res = $rados->mon_command({ prefix => "osd lspools" }); my $res = $rados->mon_command({ prefix => "osd lspools" });
@ -289,10 +283,7 @@ sub ls_pools {
sub destroy_pool { sub destroy_pool {
my ($pool, $rados) = @_; my ($pool, $rados) = @_;
$rados = PVE::RADOS->new() if !defined($rados);
if (!defined($rados)) {
$rados = PVE::RADOS->new();
}
# fixme: '--yes-i-really-really-mean-it' # fixme: '--yes-i-really-really-mean-it'
$rados->mon_command({ $rados->mon_command({
@ -314,10 +305,7 @@ sub destroy_pool {
#}] #}]
sub ls_fs { sub ls_fs {
my ($rados) = @_; my ($rados) = @_;
$rados = PVE::RADOS->new() if !defined($rados);
if (!defined($rados)) {
$rados = PVE::RADOS->new();
}
my $res = $rados->mon_command({ prefix => "fs ls" }); my $res = $rados->mon_command({ prefix => "fs ls" });
@ -342,10 +330,7 @@ sub create_fs {
sub destroy_fs { sub destroy_fs {
my ($fs, $rados) = @_; my ($fs, $rados) = @_;
$rados = PVE::RADOS->new() if !defined($rados);
if (!defined($rados)) {
$rados = PVE::RADOS->new();
}
$rados->mon_command({ $rados->mon_command({
prefix => "fs rm", prefix => "fs rm",