X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PVE%2FRADOS.pm;h=bec502812e98843fcf2ac03174f0ad954a63fa8f;hb=f65e5245f717ce51ef156b5f5960cbf05a8527f6;hp=463abc785398ffabd33e0c62b2111418d790f143;hpb=9f08da02c6e1833c11f5f0cc83d3527a806dccda;p=librados2-perl.git diff --git a/PVE/RADOS.pm b/PVE/RADOS.pm index 463abc7..bec5028 100644 --- a/PVE/RADOS.pm +++ b/PVE/RADOS.pm @@ -201,7 +201,7 @@ sub new { my $res; eval { if ($cmd eq 'M') { # rados monitor commands - $res = pve_rados_mon_command($self->{conn}, [ $data ]); + $res = encode_json(pve_rados_mon_command($self->{conn}, [ $data ])); } elsif ($cmd eq 'C') { # class methods my $aref = decode_json($data); my $method = shift @$aref; @@ -265,13 +265,25 @@ sub mon_command { my $json = encode_json($cmd); - my $raw = eval { $sendcmd->($self, 'M', $json) }; + my $ret = $sendcmd->($self, 'M', $json); die "error with '$cmd->{prefix}': $@" if $@; + my $raw = decode_json($ret); + + die "error with '$cmd->{prefix}': mon_command failed - $raw->{status_message}\n" + if $raw->{return_code} < 0; + + my $data = ''; if ($cmd->{format} && $cmd->{format} eq 'json') { - return length($raw) ? decode_json($raw) : undef; + $data = length($raw->{data}) ? decode_json($raw->{data}) : undef; + } else { + $data = $raw->{data}; } - return $raw; + return { + return_code => $raw->{return_code}, + status_message => $raw->{status_message}, + data => $data, + }; }