]> git.proxmox.com Git - pve-manager.git/commitdiff
ceph: extend pveceph pool ls
authorAlwin Antreich <a.antreich@proxmox.com>
Wed, 3 Jun 2020 13:28:59 +0000 (15:28 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 3 Jun 2020 14:08:27 +0000 (16:08 +0200)
to present more data on pools and a nicer formated output on the command
line.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
PVE/API2/Ceph.pm
PVE/CLI/pveceph.pm

index d872c7c03b8c82197383ec067b901daa4a13f0e2..d7e5892cd03dce3217cce4ab3e9bbe580c47ad27 100644 (file)
@@ -604,10 +604,16 @@ __PACKAGE__->register_method ({
        items => {
            type => "object",
            properties => {
-               pool => { type => 'integer' },
-               pool_name => { type => 'string' },
-               size => { type => 'integer' },
-               pg_autoscale_mode => { type => 'string', optional => 1 },
+               pool => { type => 'integer', title => 'ID' },
+               pool_name => { type => 'string', title => 'Name' },
+               size => { type => 'integer', title => 'Size' },
+               min_size => { type => 'integer', title => 'Min Size' },
+               pg_num => { type => 'integer', title => 'PG Num' },
+               pg_autoscale_mode => { type => 'string', optional => 1, title => 'PG Autoscale Mode' },
+               crush_rule => { type => 'integer', title => 'Crush Rule' },
+               crush_rule_name => { type => 'string', title => 'Crush Rule Name' },
+               percent_used => { type => 'number', title => '%-Used' },
+               bytes_used => { type => 'integer', title => 'Used' },
            },
        },
        links => [ { rel => 'child', href => "{pool_name}" } ],
index c94c5ac9b455aaf0511587e76332621872339b30..af14cbc0227ea40d8b15b68f2dc2c4ceeae8b0a0 100755 (executable)
@@ -182,16 +182,20 @@ our $cmddef = {
     init => [ 'PVE::API2::Ceph', 'init', [], { node => $nodename } ],
     pool => {
        ls => [ 'PVE::API2::Ceph', 'lspools', [], { node => $nodename }, sub {
-           my $res = shift;
-
-           printf("%-20s %10s %10s %10s %10s %20s\n", "Name", "size", "min_size",
-                   "pg_num", "%-used", "used");
-           foreach my $p (sort {$a->{pool_name} cmp $b->{pool_name}} @$res) {
-               printf("%-20s %10d %10d %10d %10.2f %20d\n", $p->{pool_name},
-                       $p->{size}, $p->{min_size}, $p->{pg_num},
-                       $p->{percent_used}, $p->{bytes_used});
-           }
-       }],
+           my ($data, $schema, $options) = @_;
+           PVE::CLIFormatter::print_api_result($data, $schema,
+               [
+                   'pool_name',
+                   'size',
+                   'min_size',
+                   'pg_num',
+                   'pg_autoscale_mode',
+                   'crush_rule_name',
+                   'percent_used',
+                   'bytes_used',
+               ],
+               $options);
+       }, $PVE::RESTHandler::standard_output_options],
        create => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }],
        destroy => [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node => $nodename } ],
     },