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

Dominik Csapak d.csapak at proxmox.com
Mon Jul 31 15:15:28 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 7b520357..929604d2 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1436,6 +1436,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}}) {
@@ -1443,6 +1449,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 7757c307..bf8cf8a9 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