]> git.proxmox.com Git - pve-manager.git/commitdiff
adapt osd api call for ceph nautilus
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 19 Apr 2019 14:02:05 +0000 (16:02 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 24 Apr 2019 10:06:28 +0000 (10:06 +0000)
ceph nautilus changed the structure of 'pg dump osds'
they moved the data one level below

parse both new and old format, and bail if it returns anything else

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
PVE/API2/Ceph/OSD.pm

index 4b386ebebbc621cd9dd5e35c17879c9638939163..9f1e677975e6c28fd169ee1539ce74b2f61a5e91 100644 (file)
@@ -45,7 +45,16 @@ my $get_osd_status = sub {
 my $get_osd_usage = sub {
     my ($rados) = @_;
 
-    my $osdlist = $rados->mon_command({ prefix => 'pg dump', dumpcontents => [ 'osds' ]}) || [];
+    my $res = $rados->mon_command({ prefix => 'pg dump', dumpcontents => [ 'osds' ]}) || [];
+    my $osdlist;
+
+    if (ref($res) eq "HASH") { # since nautilus
+       $osdlist = $res->{osd_stats};
+    } elsif (ref($res) eq "ARRAY") { # until luminous
+       $osdlist = $res;
+    } else { # bail
+       die "unknown format of pg dump osds\n";
+    }
 
     my $osdstat;
     foreach my $d (@$osdlist) {