]> git.proxmox.com Git - pve-manager.git/commitdiff
fix #3451 ui: ceph create osd: show custom device classes
authorAaron Lauterer <a.lauterer@proxmox.com>
Tue, 25 Jan 2022 08:51:53 +0000 (09:51 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 28 Jan 2022 11:31:39 +0000 (12:31 +0100)
Showing already configured custom device classes makes it easier to
create new OSDs with custom device classes.

The Crush map contains a list of all OSDs in the cluster, including
their device class.
This means we can create a list of used device classes from it, avoiding
adding another API endpoint.

Fetching the crushmap should also be quite a bit less data that needs to
be transferred, compared to the other possible nodes/<node>/ceph/osd
endpoint, especially in larger clusters.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
www/manager6/ceph/OSD.js

index 30671dc4072bae68072926772fa7511ed92869df..9651de1b4b6b4209cbca77da952e7a97eb91f73a 100644 (file)
@@ -17,6 +17,27 @@ Ext.define('PVE.CephCreateOsd', {
 
        me.isCreate = true;
 
+       Proxmox.Utils.API2Request({
+           url: `/nodes/${me.nodename}/ceph/crush`,
+           method: 'GET',
+           failure: response => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+           success: function({ result: { data } }) {
+               let classes = [...new Set(
+                   Array.from(
+                       data.matchAll(/^device\s[0-9]*\sosd\.[0-9]*\sclass\s(.*)$/gim),
+                       m => m[1],
+                   ).filter(v => !['hdd', 'ssd', 'nvme'].includes(v)),
+               )].map(v => [v, v]);
+
+               if (classes.length) {
+                   let kvField = me.down('field[name=crush-device-class]');
+                   classes.unshift(...kvField.comboItems);
+
+                   kvField.setComboItems(classes);
+               }
+           },
+       });
+
         Ext.applyIf(me, {
            url: "/nodes/" + me.nodename + "/ceph/osd",
            method: 'POST',