mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-05 19:59:24 +00:00
fix #1465: use a combobox for the crush rule instead of the id
this patch does a few things 1. we introduce a new api call /nodes/nodename/ceph/rules which gets us a list of crush rules 2. we introduce a new CephRuleSelector which is a simple combobox with the data from the api call ceph/rules 3. we use this in the create pool window Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
2db28c036e
commit
d2692b86e2
@ -580,6 +580,7 @@ __PACKAGE__->register_method ({
|
||||
{ name => 'log' },
|
||||
{ name => 'disks' },
|
||||
{ name => 'flags' },
|
||||
{ name => 'rules' },
|
||||
];
|
||||
|
||||
return $result;
|
||||
@ -1842,4 +1843,44 @@ __PACKAGE__->register_method({
|
||||
return $lines;
|
||||
}});
|
||||
|
||||
__PACKAGE__->register_method ({
|
||||
name => 'rules',
|
||||
path => 'rules',
|
||||
method => 'GET',
|
||||
description => "List ceph rules.",
|
||||
proxyto => 'node',
|
||||
protected => 1,
|
||||
permissions => {
|
||||
check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1],
|
||||
},
|
||||
parameters => {
|
||||
additionalProperties => 0,
|
||||
properties => {
|
||||
node => get_standard_option('pve-node'),
|
||||
},
|
||||
},
|
||||
returns => {
|
||||
type => 'array',
|
||||
items => {
|
||||
type => "object",
|
||||
properties => {},
|
||||
},
|
||||
links => [ { rel => 'child', href => "{name}" } ],
|
||||
},
|
||||
code => sub {
|
||||
my ($param) = @_;
|
||||
|
||||
PVE::CephTools::check_ceph_inited();
|
||||
|
||||
my $rados = PVE::RADOS->new();
|
||||
|
||||
my $rules = $rados->mon_command({ prefix => 'osd crush rule ls' });
|
||||
|
||||
my $res = [];
|
||||
|
||||
foreach my $rule (@$rules) {
|
||||
push @$res, { name => $rule };
|
||||
}
|
||||
|
||||
return $res;
|
||||
}});
|
||||
|
@ -31,12 +31,9 @@ Ext.define('PVE.CephCreatePool', {
|
||||
allowBlank: false
|
||||
},
|
||||
{
|
||||
xtype: 'pveIntegerField',
|
||||
fieldLabel: 'Crush RuleSet', // do not localize
|
||||
name: 'crush_ruleset',
|
||||
value: 0,
|
||||
minValue: 0,
|
||||
maxValue: 32768,
|
||||
xtype: 'pveCephRuleSelector',
|
||||
fieldLabel: 'Crush Rule', // do not localize
|
||||
name: 'crush_rule',
|
||||
allowBlank: false
|
||||
},
|
||||
{
|
||||
@ -57,8 +54,11 @@ Ext.define('PVE.CephCreatePool', {
|
||||
throw "no node name specified";
|
||||
}
|
||||
|
||||
Ext.applyIf(me, {
|
||||
url: "/nodes/" + me.nodename + "/ceph/pools"
|
||||
Ext.apply(me, {
|
||||
url: "/nodes/" + me.nodename + "/ceph/pools",
|
||||
defaults: {
|
||||
nodename: me.nodename
|
||||
}
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
@ -205,8 +205,51 @@ Ext.define('PVE.node.CephPoolList', {
|
||||
{ name: 'pg_num', type: 'integer'},
|
||||
{ name: 'bytes_used', type: 'integer'},
|
||||
{ name: 'percent_used', type: 'number'},
|
||||
{ name: 'crush_ruleset', type: 'integer'}
|
||||
{ name: 'crush_rule', type: 'integer'},
|
||||
],
|
||||
idProperty: 'pool_name'
|
||||
});
|
||||
});
|
||||
|
||||
Ext.define('PVE.form.CephRuleSelector', {
|
||||
extend: 'Ext.form.field.ComboBox',
|
||||
alias: 'widget.pveCephRuleSelector',
|
||||
|
||||
allowBlank: false,
|
||||
valueField: 'name',
|
||||
displayField: 'name',
|
||||
editable: false,
|
||||
queryMode: 'local',
|
||||
|
||||
initComponent: function() {
|
||||
var me = this;
|
||||
|
||||
if (!me.nodename) {
|
||||
throw "no nodename given";
|
||||
}
|
||||
|
||||
var store = Ext.create('Ext.data.Store', {
|
||||
fields: ['name'],
|
||||
sorters: 'name',
|
||||
proxy: {
|
||||
type: 'pve',
|
||||
url: '/api2/json/nodes/' + me.nodename + '/ceph/rules'
|
||||
}
|
||||
});
|
||||
|
||||
Ext.apply(me, {
|
||||
store: store,
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
|
||||
store.load({
|
||||
callback: function(rec, op, success){
|
||||
if (success && rec.length > 0) {
|
||||
me.select(rec[0]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -202,9 +202,9 @@ Ext.define('PVE.window.Edit', {
|
||||
trackResetOnLoad: true,
|
||||
bodyPadding: 10,
|
||||
border: false,
|
||||
defaults: {
|
||||
defaults: Ext.apply({}, me.defaults, {
|
||||
border: false
|
||||
},
|
||||
}),
|
||||
fieldDefaults: Ext.apply({}, me.fieldDefaults, {
|
||||
labelWidth: 100,
|
||||
anchor: '100%'
|
||||
|
Loading…
Reference in New Issue
Block a user