[pve-devel] [PATCH manager] ceph: extend the pool view
Alwin Antreich
a.antreich at proxmox.com
Fri May 29 17:12:11 CEST 2020
to add the pg_autoscale_mode since its activated in Ceph Octopus by
default and emmits a waring (ceph status) if a pool has too many PGs.
Also present a nicer formated output on the command line.
Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
---
PVE/API2/Ceph.pm | 25 +++++++++++++++++++++----
PVE/CLI/pveceph.pm | 24 ++++++++++++++----------
www/manager6/ceph/Pool.js | 19 +++++++++++++++----
3 files changed, 50 insertions(+), 18 deletions(-)
diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index fc4ee535..4d66c88a 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -605,9 +605,16 @@ __PACKAGE__->register_method ({
items => {
type => "object",
properties => {
- pool => { type => 'integer' },
- pool_name => { type => 'string' },
- size => { type => 'integer' },
+ 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}" } ],
@@ -637,9 +644,19 @@ __PACKAGE__->register_method ({
}
my $data = [];
+ my $attr_list = [
+ 'pool',
+ 'pool_name',
+ 'size',
+ 'min_size',
+ 'pg_num',
+ 'crush_rule',
+ 'pg_autoscale_mode',
+ ];
+
foreach my $e (@{$res->{pools}}) {
my $d = {};
- foreach my $attr (qw(pool pool_name size min_size pg_num crush_rule)) {
+ foreach my $attr (@$attr_list) {
$d->{$attr} = $e->{$attr} if defined($e->{$attr});
}
diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm
index eac3743a..eda3dfc2 100755
--- a/PVE/CLI/pveceph.pm
+++ b/PVE/CLI/pveceph.pm
@@ -170,16 +170,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 } ],
},
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index e81b5974..db1828a6 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -107,10 +107,21 @@ Ext.define('PVE.node.CephPoolList', {
dataIndex: 'size'
},
{
- text: '# Placement Groups', // pg_num',
- width: 180,
- align: 'right',
- dataIndex: 'pg_num'
+ text: 'Placement Groups',
+ columns: [
+ {
+ text: '# of PGs', // pg_num',
+ width: 100,
+ align: 'right',
+ dataIndex: 'pg_num'
+ },
+ {
+ text: 'Autoscale Mode',
+ width: 140,
+ align: 'right',
+ dataIndex: 'pg_autoscale_mode'
+ },
+ ]
},
{
text: 'CRUSH Rule',
--
2.26.2
More information about the pve-devel
mailing list