From 80deebd9c5b212b251ca2e4c3962c55f89fce46d Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Thu, 17 Nov 2022 14:23:50 +0100 Subject: [PATCH] create new mon_cmd method for new behavior with compat wrapper Rename the $noerr param to $no_result_catch while changing the method name, as it was a bit confusing because we only ever adhere to it for the actual command result, not other die's. Signed-off-by: Thomas Lamprecht --- PVE/RADOS.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/PVE/RADOS.pm b/PVE/RADOS.pm index 3ee7ab8..aba6653 100644 --- a/PVE/RADOS.pm +++ b/PVE/RADOS.pm @@ -242,10 +242,8 @@ sub cluster_stat { # example1: { prefix => 'get_command_descriptions'}) # example2: { prefix => 'mon dump', format => 'json' } -sub mon_command { - my ($self, $cmd, $noerr) = @_; - - $noerr = 0 if !$noerr; +sub mon_cmd { + my ($self, $cmd, $no_result_catch) = @_; $cmd->{format} = 'json' if !$cmd->{format}; @@ -256,8 +254,8 @@ sub mon_command { my $raw = decode_json($ret); - die "error with '$cmd->{prefix}': mon_command failed - $raw->{status_message}\n" - if !$noerr && $raw->{return_code} < 0; + die "error with '$cmd->{prefix}': mon_cmd failed - $raw->{status_message}\n" + if !$no_result_catch && $raw->{return_code} < 0; my $data = ''; if ($cmd->{format} && $cmd->{format} eq 'json') { @@ -272,6 +270,14 @@ sub mon_command { }; } +# for backward compatibillity or if one just doesn't care about actual RADOS error details +sub mon_command { + my ($self, $cmd) = @_; + + my $res = mon_cmd($self, $cmd); + + return $res->{data}; +} 1; __END__