[pve-devel] [PATCH manager 06/10] also get the crush rule name in the ceph pool list

Dominik Csapak d.csapak at proxmox.com
Mon Jul 31 11:28:38 CEST 2017


we get the names in the backend, and give them as an additional field
in the api call, and use it in the grid

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/API2/Ceph.pm          | 11 +++++++++++
 www/manager6/ceph/Pool.js |  7 +++++++
 2 files changed, 18 insertions(+)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 8644de85..ba8f15fe 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1434,6 +1434,12 @@ __PACKAGE__->register_method ({
 	}
 
 	$res = $rados->mon_command({ prefix => 'osd dump' });
+	my $rulestmp = $rados->mon_command({ prefix => 'osd crush rule dump'});
+
+	my $rules = {};
+	for my $rule (@$rulestmp) {
+	    $rules->{$rule->{rule_id}} = $rule->{rule_name};
+	}
 
 	my $data = [];
 	foreach my $e (@{$res->{pools}}) {
@@ -1441,6 +1447,11 @@ __PACKAGE__->register_method ({
 	    foreach my $attr (qw(pool pool_name size min_size pg_num crush_rule)) {
 		$d->{$attr} = $e->{$attr} if defined($e->{$attr});
 	    }
+
+	    if (defined($d->{crush_rule}) && defined($rules->{$d->{crush_rule}})) {
+		$d->{crush_rule_name} = $rules->{$d->{crush_rule}};
+	    }
+
 	    if (my $s = $stats->{$d->{pool}}) {
 		$d->{bytes_used} = $s->{bytes_used};
 		$d->{percent_used} = ($s->{bytes_used} / $total)*100
diff --git a/www/manager6/ceph/Pool.js b/www/manager6/ceph/Pool.js
index 4eedb8b5..a4247bfd 100644
--- a/www/manager6/ceph/Pool.js
+++ b/www/manager6/ceph/Pool.js
@@ -103,6 +103,12 @@ Ext.define('PVE.node.CephPoolList', {
 	    dataIndex: 'crush_rule'
 	},
 	{
+	    header: 'rule_name',
+	    width: 50,
+	    sortable: false,
+	    dataIndex: 'crush_rule_name'
+	},
+	{
 	    header: gettext('Used'),
 	    columns: [
 		{
@@ -206,6 +212,7 @@ Ext.define('PVE.node.CephPoolList', {
 		  { name: 'bytes_used', type: 'integer'},
 		  { name: 'percent_used', type: 'number'},
 		  { name: 'crush_rule', type: 'integer'},
+		  { name: 'crush_rule_name', type: 'string'}
 		],
 	idProperty: 'pool_name'
     });
-- 
2.11.0





More information about the pve-devel mailing list