Commit 45c04975 authored by Dietmar Maurer's avatar Dietmar Maurer

display crush map

parent 9432f732
...@@ -158,16 +158,16 @@ my $run_ceph_cmd = sub { ...@@ -158,16 +158,16 @@ my $run_ceph_cmd = sub {
die $err if $err; die $err if $err;
}; };
my $run_ceph_cmd_json = sub { my $run_ceph_cmd_text = sub {
my ($cmd, %opts) = @_; my ($cmd, %opts) = @_;
my $json = ''; my $out = '';
my $quiet = delete $opts{quiet}; my $quiet = delete $opts{quiet};
my $parser = sub { my $parser = sub {
my $line = shift; my $line = shift;
$json .= $line; $out .= "$line\n";
}; };
my $errfunc = sub { my $errfunc = sub {
...@@ -175,12 +175,17 @@ my $run_ceph_cmd_json = sub { ...@@ -175,12 +175,17 @@ my $run_ceph_cmd_json = sub {
print "$line\n" if !$quiet; print "$line\n" if !$quiet;
}; };
&$run_ceph_cmd([@$cmd, '--format', 'json'], &$run_ceph_cmd($cmd, outfunc => $parser, errfunc => $errfunc);
outfunc => $parser, errfunc => $errfunc);
return $out;
};
my $run_ceph_cmd_json = sub {
my ($cmd, %opts) = @_;
my $res = decode_json($json); my $json = &$run_ceph_cmd_text([@$cmd, '--format', 'json'], %opts);
return $res; return decode_json($json);
}; };
sub ceph_mon_status { sub ceph_mon_status {
...@@ -261,6 +266,7 @@ __PACKAGE__->register_method ({ ...@@ -261,6 +266,7 @@ __PACKAGE__->register_method ({
{ name => 'stop' }, { name => 'stop' },
{ name => 'start' }, { name => 'start' },
{ name => 'status' }, { name => 'status' },
{ name => 'crush' },
]; ];
return $result; return $result;
...@@ -678,3 +684,29 @@ __PACKAGE__->register_method ({ ...@@ -678,3 +684,29 @@ __PACKAGE__->register_method ({
return undef; return undef;
}}); }});
__PACKAGE__->register_method ({
name => 'crush',
path => 'crush',
method => 'GET',
description => "Get OSD crush map",
proxyto => 'node',
protected => 1,
parameters => {
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
},
},
returns => { type => 'string' },
code => sub {
my ($param) = @_;
&$check_ceph_inited();
my $txt = &$run_ceph_cmd_text(['osd', 'crush', 'dump'], quiet => 1);
return $txt;
}});
Ext.define('PVE.node.CephCrushMap', {
extend: 'Ext.panel.Panel',
alias: 'widget.pveNodeCephCrushMap',
load: function() {
var me = this;
PVE.Utils.API2Request({
url: me.url,
waitMsgTarget: me,
failure: function(response, opts) {
me.update(gettext('Error') + " " + response.htmlStatus);
},
success: function(response, opts) {
var data = response.result.data;
me.update(data);
}
});
},
initComponent: function() {
var me = this;
var nodename = me.pveSelNode.data.node;
if (!nodename) {
throw "no node name specified";
}
Ext.apply(me, {
url: '/api2/extjs/nodes/' + nodename + '/ceph/crush',
style: 'padding-left:10px',
bodyStyle: 'white-space:pre',
bodyPadding: 5,
autoScroll: true,
listeners: {
show: function() {
me.load();
}
}
});
me.callParent();
me.load();
}
});
Ext.define('PVE.node.CephStatus', { Ext.define('PVE.node.CephStatus', {
extend: 'PVE.grid.ObjectGrid', extend: 'PVE.grid.ObjectGrid',
alias: 'widget.pveNodeCephStatus', alias: 'widget.pveNodeCephStatus',
...@@ -178,8 +225,8 @@ Ext.define('PVE.node.Ceph', { ...@@ -178,8 +225,8 @@ Ext.define('PVE.node.Ceph', {
}, },
{ {
title: 'Crush', title: 'Crush',
itemId: 'test5', xtype: 'pveNodeCephCrushMap',
html: "ABCD" itemId: 'crushmap'
} }
], ],
listeners: { listeners: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment