From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 1C48762A13 for ; Fri, 21 Jan 2022 15:51:24 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1236132608 for ; Fri, 21 Jan 2022 15:51:24 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D5E36325FC for ; Fri, 21 Jan 2022 15:51:22 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 876BC46D13 for ; Fri, 21 Jan 2022 15:51:16 +0100 (CET) From: Aaron Lauterer To: pve-devel@lists.proxmox.com Date: Fri, 21 Jan 2022 15:51:15 +0100 Message-Id: <20220121145115.1374455-1-a.lauterer@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.002 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager] fix #3451 ui: ceph create osd: show custom device classes X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jan 2022 14:51:24 -0000 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//ceph/osd endpoint, especially in larger clusters. Signed-off-by: Aaron Lauterer --- www/manager6/ceph/OSD.js | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/www/manager6/ceph/OSD.js b/www/manager6/ceph/OSD.js index 30671dc4..eb27d3b3 100644 --- a/www/manager6/ceph/OSD.js +++ b/www/manager6/ceph/OSD.js @@ -17,6 +17,38 @@ Ext.define('PVE.CephCreateOsd', { me.isCreate = true; + let deviceClasses = [ + ['hdd', 'HDD'], + ['ssd', 'SSD'], + ['nvme', 'NVMe'], + ]; + + Proxmox.Utils.API2Request({ + url: "/nodes/" + me.nodename + "/ceph/crush", + method: 'GET', + failure: function(response, opts) { + let msg = response.htmlStatus; + console.error('Failed to load crushmap', msg); + // We still need to show the default list of device classes + me.down('field[name=crush-device-class]').setComboItems(deviceClasses); + }, + success: function(response, opts) { + let data = response.result.data; + + let classes = new Set(); + for (const match of data.matchAll(/^device\s[0-9]*\sosd\.[0-9]*\sclass\s(.*)$/gim)) { + classes.add(match[1]); + } + for (const v of ['hdd', 'ssd', 'nvme']) { + classes.delete(v); + } + for (const v of classes) { + deviceClasses.push([v, v]); + } + me.down('field[name=crush-device-class]').setComboItems(deviceClasses); + }, + }); + Ext.applyIf(me, { url: "/nodes/" + me.nodename + "/ceph/osd", method: 'POST', @@ -81,11 +113,6 @@ Ext.define('PVE.CephCreateOsd', { }, { xtype: 'proxmoxKVComboBox', - comboItems: [ - ['hdd', 'HDD'], - ['ssd', 'SSD'], - ['nvme', 'NVMe'], - ], name: 'crush-device-class', nodename: me.nodename, fieldLabel: gettext('Device Class'), -- 2.30.2