The mon_command now returns a hash ref but current calls are only
interested in the 'data'.

Signed-off-by: Aaron Lauterer <a.laute...@proxmox.com>
---
Needs to be coordinated with librados2-perl changes from patch 1

 PVE/API2/Ceph.pm         |  6 +++---
 PVE/API2/Ceph/MGR.pm     |  2 +-
 PVE/API2/Ceph/MON.pm     | 19 +++++++++++++------
 PVE/API2/Ceph/OSD.pm     | 14 +++++++-------
 PVE/API2/Ceph/Pools.pm   | 18 ++++++++++--------
 PVE/API2/Cluster/Ceph.pm |  6 +++---
 PVE/CLI/pveceph.pm       |  4 ++--
 PVE/Ceph/Services.pm     | 10 +++++-----
 PVE/Ceph/Tools.pm        | 16 ++++++++--------
 9 files changed, 52 insertions(+), 43 deletions(-)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 3bbcfe4c..1e1b1edd 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -168,7 +168,7 @@ __PACKAGE__->register_method ({
        PVE::Ceph::Tools::check_ceph_inited();
 
        my $rados = PVE::RADOS->new();
-       my $res = $rados->mon_command( { prefix => 'config dump', format => 
'json' });
+       my $res = $rados->mon_command( { prefix => 'config dump', format => 
'json' })->{data};
        foreach my $entry (@$res) {
            $entry->{can_update_at_runtime} = $entry->{can_update_at_runtime}? 
1 : 0; # JSON::true/false -> 1/0
        }
@@ -525,7 +525,7 @@ __PACKAGE__->register_method ({
        my $rados = PVE::RADOS->new();
 
        eval {
-           my $bindata = $rados->mon_command({ prefix => 'osd getcrushmap', 
format => 'plain' });
+           my $bindata = $rados->mon_command({ prefix => 'osd getcrushmap', 
format => 'plain' })->{data};
            file_set_contents($mapfile, $bindata);
            run_command(['crushtool', '-d', $mapfile, '-o', $mapdata]);
            $txt = file_get_contents($mapdata);
@@ -630,7 +630,7 @@ __PACKAGE__->register_method ({
 
        my $rados = PVE::RADOS->new();
 
-       my $rules = $rados->mon_command({ prefix => 'osd crush rule ls' });
+       my $rules = $rados->mon_command({ prefix => 'osd crush rule ls' 
})->{data};
 
        my $res = [];
 
diff --git a/PVE/API2/Ceph/MGR.pm b/PVE/API2/Ceph/MGR.pm
index 2dc679ef..5b9087c9 100644
--- a/PVE/API2/Ceph/MGR.pm
+++ b/PVE/API2/Ceph/MGR.pm
@@ -67,7 +67,7 @@ __PACKAGE__->register_method ({
 
        my $mgr_hash = PVE::Ceph::Services::get_services_info("mgr", $cfg, 
$rados);
 
-       my $mgr_dump = $rados->mon_command({ prefix => 'mgr dump' });
+       my $mgr_dump = $rados->mon_command({ prefix => 'mgr dump' })->{data};
 
        my $active_name = $mgr_dump->{active_name};
        $mgr_hash->{$active_name}->{state} = 'active' if $active_name;
diff --git a/PVE/API2/Ceph/MON.pm b/PVE/API2/Ceph/MON.pm
index 12c9caf0..943ba0a0 100644
--- a/PVE/API2/Ceph/MON.pm
+++ b/PVE/API2/Ceph/MON.pm
@@ -28,8 +28,12 @@ my $find_mon_ips = sub {
 
     my $pubnet;
     if ($rados) {
-       $pubnet = $rados->mon_command({ prefix => "config get" , who => "mon.",
-               key => "public_network", format => 'plain' });
+       $pubnet = $rados->mon_command({
+               prefix => "config get",
+               who => "mon.",
+               key => "public_network",
+               format => 'plain',
+           })->{data};
        # if not defined in the db, the result is empty, it is also always
        # followed by a newline
        ($pubnet) = $pubnet =~ m/^(\S+)$/;
@@ -231,7 +235,7 @@ __PACKAGE__->register_method ({
        my $monhash = PVE::Ceph::Services::get_services_info("mon", $cfg, 
$rados);
 
        if ($rados) {
-           my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
+           my $monstat = $rados->mon_command({ prefix => 'quorum_status' 
})->{data};
 
            my $mons = $monstat->{monmap}->{mons};
            foreach my $d (@$mons) {
@@ -391,7 +395,10 @@ __PACKAGE__->register_method ({
                    ];
 
                    if (defined($rados)) { # we can only have a RADOS object if 
we have a monitor
-                       my $mapdata = $rados->mon_command({ prefix => 'mon 
getmap', format => 'plain' });
+                       my $mapdata = $rados->mon_command({
+                               prefix => 'mon getmap',
+                               format => 'plain',
+                           })->{data};
                        file_set_contents($monmap, $mapdata);
                        run_command($monmaptool_cmd);
                    } else { # we need to create a monmap for the first monitor
@@ -502,7 +509,7 @@ __PACKAGE__->register_method ({
        my $monsection = "mon.$monid";
 
        my $rados = PVE::RADOS->new();
-       my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
+       my $monstat = $rados->mon_command({ prefix => 'quorum_status' 
})->{data};
        my $monlist = $monstat->{monmap}->{mons};
        my $monhash = PVE::Ceph::Services::get_services_info('mon', $cfg, 
$rados);
 
@@ -520,7 +527,7 @@ __PACKAGE__->register_method ({
                # reopen with longer timeout
                $rados = PVE::RADOS->new(timeout => 
PVE::Ceph::Tools::get_config('long_rados_timeout'));
                $monhash = PVE::Ceph::Services::get_services_info('mon', $cfg, 
$rados);
-               $monstat = $rados->mon_command({ prefix => 'quorum_status' });
+               $monstat = $rados->mon_command({ prefix => 'quorum_status' 
})->{data};
                $monlist = $monstat->{monmap}->{mons};
 
                my $addrs = [];
diff --git a/PVE/API2/Ceph/OSD.pm b/PVE/API2/Ceph/OSD.pm
index 93433b3a..d38c4ced 100644
--- a/PVE/API2/Ceph/OSD.pm
+++ b/PVE/API2/Ceph/OSD.pm
@@ -30,7 +30,7 @@ my $nodename = PVE::INotify::nodename();
 my $get_osd_status = sub {
     my ($rados, $osdid) = @_;
 
-    my $stat = $rados->mon_command({ prefix => 'osd dump' });
+    my $stat = $rados->mon_command({ prefix => 'osd dump' })->{data};
 
     my $osdlist = $stat->{osds} || [];
 
@@ -51,7 +51,7 @@ my $get_osd_status = sub {
 my $get_osd_usage = sub {
     my ($rados) = @_;
 
-    my $osdlist = $rados->mon_command({ prefix => 'pg dump', dumpcontents => [ 
'osds' ]});
+    my $osdlist = $rados->mon_command({ prefix => 'pg dump', dumpcontents => [ 
'osds' ]})->{data};
     if (!($osdlist && ref($osdlist))) {
        warn "got unknown result format for 'pg dump osds' command\n";
        return [];
@@ -95,7 +95,7 @@ __PACKAGE__->register_method ({
        PVE::Ceph::Tools::check_ceph_inited();
 
        my $rados = PVE::RADOS->new();
-       my $res = $rados->mon_command({ prefix => 'osd tree' });
+       my $res = $rados->mon_command({ prefix => 'osd tree' })->{data};
 
         die "no tree nodes found\n" if !($res && $res->{nodes});
 
@@ -103,7 +103,7 @@ __PACKAGE__->register_method ({
 
        my $osd_usage = $get_osd_usage->($rados);
 
-       my $osdmetadata_res = $rados->mon_command({ prefix => 'osd metadata' });
+       my $osdmetadata_res = $rados->mon_command({ prefix => 'osd metadata' 
})->{data};
        my $osdmetadata = { map { $_->{id} => $_ } @$osdmetadata_res };
 
        my $hostversions = PVE::Ceph::Services::get_ceph_versions();
@@ -350,7 +350,7 @@ __PACKAGE__->register_method ({
 
        # get necessary ceph infos
        my $rados = PVE::RADOS->new();
-       my $monstat = $rados->mon_command({ prefix => 'quorum_status' });
+       my $monstat = $rados->mon_command({ prefix => 'quorum_status' 
})->{data};
 
        die "unable to get fsid\n" if !$monstat->{monmap} || 
!$monstat->{monmap}->{fsid};
        my $fsid = $monstat->{monmap}->{fsid};
@@ -366,7 +366,7 @@ __PACKAGE__->register_method ({
                        'mon' => 'allow profile bootstrap-osd'
                    ],
                    format => 'plain',
-               });
+               })->{data};
            file_set_contents($ceph_bootstrap_osd_keyring, $bindata);
        };
 
@@ -574,7 +574,7 @@ __PACKAGE__->register_method ({
        my $rados = PVE::RADOS->new();
 
        my $osd_belongs_to_node = osd_belongs_to_node(
-           $rados->mon_command({ prefix => 'osd tree' }),
+           $rados->mon_command({ prefix => 'osd tree' })->{data},
            $param->{node},
            $osdid,
        );
diff --git a/PVE/API2/Ceph/Pools.pm b/PVE/API2/Ceph/Pools.pm
index 002f7893..ed384d6f 100644
--- a/PVE/API2/Ceph/Pools.pm
+++ b/PVE/API2/Ceph/Pools.pm
@@ -21,8 +21,7 @@ my $get_autoscale_status = sub {
 
     $rados = PVE::RADOS->new() if !defined($rados);
 
-    my $autoscale = $rados->mon_command({
-           prefix => 'osd pool autoscale-status'});
+    my $autoscale = $rados->mon_command({ prefix => 'osd pool 
autoscale-status' })->{data};
 
     my $data;
     foreach my $p (@$autoscale) {
@@ -132,7 +131,7 @@ __PACKAGE__->register_method ({
        my $rados = PVE::RADOS->new();
 
        my $stats = {};
-       my $res = $rados->mon_command({ prefix => 'df' });
+       my $res = $rados->mon_command({ prefix => 'df' })->{data};
 
        foreach my $d (@{$res->{pools}}) {
            next if !$d->{stats};
@@ -140,8 +139,8 @@ __PACKAGE__->register_method ({
            $stats->{$d->{id}} = $d->{stats};
        }
 
-       $res = $rados->mon_command({ prefix => 'osd dump' });
-       my $rulestmp = $rados->mon_command({ prefix => 'osd crush rule dump'});
+       $res = $rados->mon_command({ prefix => 'osd dump' })->{data};
+       my $rulestmp = $rados->mon_command({ prefix => 'osd crush rule 
dump'})->{data};
 
        my $rules = {};
        for my $rule (@$rulestmp) {
@@ -566,7 +565,7 @@ __PACKAGE__->register_method ({
                prefix => 'osd pool get',
                pool   => "$pool",
                var    => 'all',
-           });
+           })->{data};
 
        my $data = {
            id                     => $res->{pool_id},
@@ -593,7 +592,7 @@ __PACKAGE__->register_method ({
 
        if ($verbose) {
            my $stats;
-           my $res = $rados->mon_command({ prefix => 'df' });
+           my $res = $rados->mon_command({ prefix => 'df' })->{data};
 
            # pg_autoscaler module is not enabled in Nautilus
            # avoid partial read further down, use new rados instance
@@ -606,7 +605,10 @@ __PACKAGE__->register_method ({
                $data->{statistics} = $d->{stats};
            }
 
-           my $apps = $rados->mon_command({ prefix => "osd pool application 
get", pool => "$pool", });
+           my $apps = $rados->mon_command({
+                   prefix => "osd pool application get",
+                   pool => "$pool",
+               })->{data};
            $data->{application_list} = [ keys %$apps ];
        }
 
diff --git a/PVE/API2/Cluster/Ceph.pm b/PVE/API2/Cluster/Ceph.pm
index 7f825003..e48626eb 100644
--- a/PVE/API2/Cluster/Ceph.pm
+++ b/PVE/API2/Cluster/Ceph.pm
@@ -96,7 +96,7 @@ __PACKAGE__->register_method ({
            }
 
            # get data from metadata call and merge 'our' data
-           my $services = $rados->mon_command({ prefix => "$type metadata" });
+           my $services = $rados->mon_command({ prefix => "$type metadata" 
})->{data};
            for my $service ( @$services ) {
                my $hostname = $service->{hostname};
                next if !defined($hostname); # can happen if node is dead
@@ -115,7 +115,7 @@ __PACKAGE__->register_method ({
            $res->{$type} = $data;
        }
 
-       $res->{osd} = $rados->mon_command({ prefix => "osd metadata" });
+       $res->{osd} = $rados->mon_command({ prefix => "osd metadata" })->{data};
 
        return $res;
     }
@@ -152,7 +152,7 @@ my $get_current_set_flags = sub {
 
     $rados //= PVE::RADOS->new();
 
-    my $stat = $rados->mon_command({ prefix => 'osd dump' });
+    my $stat = $rados->mon_command({ prefix => 'osd dump' })->{data};
     my $setflags = $stat->{flags} // '';
     return { map { $_ => 1 } PVE::Tools::split_list($setflags) };
 };
diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index 995cfcd5..0aa390ef 100755
--- a/PVE/CLI/pveceph.pm
+++ b/PVE/CLI/pveceph.pm
@@ -77,7 +77,7 @@ __PACKAGE__->register_method ({
            $pools = PVE::Ceph::Tools::ls_pools(undef, $rados);
            $monstat = PVE::Ceph::Services::get_services_info('mon', undef, 
$rados);
            $mdsstat = PVE::Ceph::Services::get_services_info('mds', undef, 
$rados);
-           $osdstat = $rados->mon_command({ prefix => 'osd metadata' });
+           $osdstat = $rados->mon_command({ prefix => 'osd metadata' 
})->{data};
        };
        warn "Error gathering ceph info, already purged? Message: $@" if $@;
 
@@ -291,7 +291,7 @@ __PACKAGE__->register_method ({
 
            if ($param->{'remove-storages'}) {
                my $defaultfs;
-               my $fs_dump = $rados->mon_command({ prefix => "fs dump" });
+               my $fs_dump = $rados->mon_command({ prefix => "fs dump" 
})->{data};
                for my $fs ($fs_dump->{filesystems}->@*) {
                    next if $fs->{id} != $fs_dump->{default_fscid};
                    $defaultfs = $fs->{mdsmap}->{fs_name};
diff --git a/PVE/Ceph/Services.pm b/PVE/Ceph/Services.pm
index cda13c6a..8fe62cb1 100644
--- a/PVE/Ceph/Services.pm
+++ b/PVE/Ceph/Services.pm
@@ -147,7 +147,7 @@ sub get_services_info {
        return $result;
     }
 
-    my $metadata = $rados->mon_command({ prefix => "$type metadata" });
+    my $metadata = $rados->mon_command({ prefix => "$type metadata" })->{data};
     foreach my $info (@$metadata) {
        my $id = $info->{name} // $info->{id};
        my $service = $result->{$id};
@@ -197,7 +197,7 @@ sub get_cluster_mds_state {
        $mds_state->{$mds->{name}} = $state;
     };
 
-    my $mds_dump = $rados->mon_command({ prefix => 'mds stat' });
+    my $mds_dump = $rados->mon_command({ prefix => 'mds stat' })->{data};
     my $fsmap = $mds_dump->{fsmap};
 
 
@@ -225,7 +225,7 @@ sub is_mds_active {
        $rados = PVE::RADOS->new();
     }
 
-    my $mds_dump = $rados->mon_command({ prefix => 'mds stat' });
+    my $mds_dump = $rados->mon_command({ prefix => 'mds stat' })->{data};
     my $fsmap = $mds_dump->{fsmap}->{filesystems};
 
     if (!($fsmap && scalar(@$fsmap) > 0)) {
@@ -280,7 +280,7 @@ sub create_mds {
        entity => $service_name,
        caps => $priv,
        format => 'plain',
-    });
+    })->{data};
 
     PVE::Tools::file_set_contents($service_keyring, $output);
 
@@ -357,7 +357,7 @@ sub create_mgr {
            mds => 'allow *',
        ],
        format => 'plain'
-    });
+    })->{data};
     PVE::Tools::file_set_contents($mgrkeyring, $output);
 
     print "setting owner for directory\n";
diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index 36d7788a..85306328 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -78,7 +78,7 @@ sub get_cluster_versions {
 
     my $rados = PVE::RADOS->new();
     my $cmd = $service ? "$service versions" : 'versions';
-    return $rados->mon_command({ prefix => $cmd });
+    return $rados->mon_command({ prefix => $cmd })->{data};
 }
 
 sub get_config {
@@ -282,7 +282,7 @@ sub ls_pools {
        $rados = PVE::RADOS->new();
     }
 
-    my $res = $rados->mon_command({ prefix => "osd lspools" });
+    my $res = $rados->mon_command({ prefix => "osd lspools" })->{data};
 
     return $res;
 }
@@ -319,7 +319,7 @@ sub ls_fs {
        $rados = PVE::RADOS->new();
     }
 
-    my $res = $rados->mon_command({ prefix => "fs ls" });
+    my $res = $rados->mon_command({ prefix => "fs ls" })->{data};
 
     return $res;
 }
@@ -420,7 +420,7 @@ sub get_db_wal_sizes {
     my $res = {};
 
     my $rados = PVE::RADOS->new();
-    my $db_config = $rados->mon_command({ prefix => 'config-key dump', key => 
'config/' });
+    my $db_config = $rados->mon_command({ prefix => 'config-key dump', key => 
'config/' })->{data};
 
     $res->{db} = $db_config->{"config/osd/bluestore_block_db_size"} //
                 $db_config->{"config/global/bluestore_block_db_size"};
@@ -520,12 +520,12 @@ sub ceph_cluster_status {
     my ($rados) = @_;
     $rados = PVE::RADOS->new() if !$rados;
 
-    my $status = $rados->mon_command({ prefix => 'status' });
-    $status->{health} = $rados->mon_command({ prefix => 'health', detail => 
'detail' });
+    my $status = $rados->mon_command({ prefix => 'status' })->{data};
+    $status->{health} = $rados->mon_command({ prefix => 'health', detail => 
'detail' })->{data};
 
     if (!exists $status->{monmap}->{mons}) { # octopus moved most info out of 
status, re-add
-       $status->{monmap} = $rados->mon_command({ prefix => 'mon dump' });
-       $status->{mgrmap} = $rados->mon_command({ prefix => 'mgr dump' });
+       $status->{monmap} = $rados->mon_command({ prefix => 'mon dump' 
})->{data};
+       $status->{mgrmap} = $rados->mon_command({ prefix => 'mgr dump' 
})->{data};
     }
 
     return $status;
-- 
2.30.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to