mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-07 12:43:00 +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 => 'log' },
|
||||||
{ name => 'disks' },
|
{ name => 'disks' },
|
||||||
{ name => 'flags' },
|
{ name => 'flags' },
|
||||||
|
{ name => 'rules' },
|
||||||
];
|
];
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -1842,4 +1843,44 @@ __PACKAGE__->register_method({
|
|||||||
return $lines;
|
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
|
allowBlank: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
xtype: 'pveIntegerField',
|
xtype: 'pveCephRuleSelector',
|
||||||
fieldLabel: 'Crush RuleSet', // do not localize
|
fieldLabel: 'Crush Rule', // do not localize
|
||||||
name: 'crush_ruleset',
|
name: 'crush_rule',
|
||||||
value: 0,
|
|
||||||
minValue: 0,
|
|
||||||
maxValue: 32768,
|
|
||||||
allowBlank: false
|
allowBlank: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -57,8 +54,11 @@ Ext.define('PVE.CephCreatePool', {
|
|||||||
throw "no node name specified";
|
throw "no node name specified";
|
||||||
}
|
}
|
||||||
|
|
||||||
Ext.applyIf(me, {
|
Ext.apply(me, {
|
||||||
url: "/nodes/" + me.nodename + "/ceph/pools"
|
url: "/nodes/" + me.nodename + "/ceph/pools",
|
||||||
|
defaults: {
|
||||||
|
nodename: me.nodename
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
me.callParent();
|
me.callParent();
|
||||||
@ -205,8 +205,51 @@ Ext.define('PVE.node.CephPoolList', {
|
|||||||
{ name: 'pg_num', type: 'integer'},
|
{ name: 'pg_num', type: 'integer'},
|
||||||
{ name: 'bytes_used', type: 'integer'},
|
{ name: 'bytes_used', type: 'integer'},
|
||||||
{ name: 'percent_used', type: 'number'},
|
{ name: 'percent_used', type: 'number'},
|
||||||
{ name: 'crush_ruleset', type: 'integer'}
|
{ name: 'crush_rule', type: 'integer'},
|
||||||
],
|
],
|
||||||
idProperty: 'pool_name'
|
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,
|
trackResetOnLoad: true,
|
||||||
bodyPadding: 10,
|
bodyPadding: 10,
|
||||||
border: false,
|
border: false,
|
||||||
defaults: {
|
defaults: Ext.apply({}, me.defaults, {
|
||||||
border: false
|
border: false
|
||||||
},
|
}),
|
||||||
fieldDefaults: Ext.apply({}, me.fieldDefaults, {
|
fieldDefaults: Ext.apply({}, me.fieldDefaults, {
|
||||||
labelWidth: 100,
|
labelWidth: 100,
|
||||||
anchor: '100%'
|
anchor: '100%'
|
||||||
|
Loading…
Reference in New Issue
Block a user